Skip to content

Commit

Permalink
review improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
zeitlinger committed Apr 11, 2024
1 parent cea2ac1 commit 5fb82c5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public Object postProcessAfterInitialization(Object bean, String beanName) {
return bean;
}

return RestTemplateInterceptor.addIfNotPresent(
return RestTemplateInstrumentation.addIfNotPresent(
(RestTemplate) bean, openTelemetryProvider.getObject());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.web.client.RestTemplate;

class RestTemplateInterceptor {
class RestTemplateInstrumentation {

private RestTemplateInterceptor() {}
private RestTemplateInstrumentation() {}

@CanIgnoreReturnValue
static RestTemplate addIfNotPresent(RestTemplate restTemplate, OpenTelemetry openTelemetry) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ static RestTemplateBeanPostProcessor otelRestTemplateBeanPostProcessor(
static RestTemplateCustomizer otelRestTemplateCustomizer(
ObjectProvider<OpenTelemetry> openTelemetryProvider) {
return restTemplate ->
RestTemplateInterceptor.addIfNotPresent(restTemplate, openTelemetryProvider.getObject());
RestTemplateInstrumentation.addIfNotPresent(restTemplate, openTelemetryProvider.getObject());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import org.awaitility.core.ConditionEvaluationLogger;
import org.awaitility.core.EvaluatedCondition;
import org.awaitility.core.TimeoutEvent;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
Expand Down Expand Up @@ -81,11 +80,11 @@
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class OtelSpringStarterSmokeTest {

public static final InMemoryMetricExporter METRIC_EXPORTER =
private static final InMemoryMetricExporter METRIC_EXPORTER =
InMemoryMetricExporter.create(AggregationTemporality.DELTA);
private static final InMemoryLogRecordExporter LOG_RECORD_EXPORTER =
InMemoryLogRecordExporter.create();
public static final InMemorySpanExporter SPAN_EXPORTER = InMemorySpanExporter.create();
private static final InMemorySpanExporter SPAN_EXPORTER = InMemorySpanExporter.create();
private static final Logger logger = LoggerFactory.getLogger(OtelSpringStarterSmokeTest.class);

@Autowired private TestRestTemplate testRestTemplate;
Expand Down Expand Up @@ -168,12 +167,7 @@ AutoConfigurationCustomizerProvider propagatorCustomizer() {
}
}

@AfterEach
void tearDown() {
reset();
}

private static void reset() {
private static void resetExporters() {
SPAN_EXPORTER.reset();
METRIC_EXPORTER.reset();
LOG_RECORD_EXPORTER.reset();
Expand Down Expand Up @@ -259,7 +253,7 @@ void shouldSendTelemetry() {
@Test
@org.junit.jupiter.api.Order(2)
void restTemplateClient() {
reset(); // ignore the telemetry from application startup
resetExporters(); // ignore the telemetry from application startup

testRestTemplate.getForObject(OtelSpringStarterSmokeTestController.REST_TEMPLATE, String.class);

Expand Down

0 comments on commit 5fb82c5

Please sign in to comment.