Skip to content

Commit

Permalink
Assert on instrumentation version (open-telemetry#6773)
Browse files Browse the repository at this point in the history
To catch issues like open-telemetry#6770
  • Loading branch information
trask committed Sep 29, 2022
1 parent 8fd7ef6 commit 0d32150
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private static Scheduler createScheduler(String name) throws Exception {
public static class SuccessfulJob implements Job {
@Override
public void execute(JobExecutionContext context) {
GlobalOpenTelemetry.getTracer("jobtracer").spanBuilder("child").startSpan().end();
GlobalOpenTelemetry.getTracer("test").spanBuilder("child").startSpan().end();
// ensure that JobExecutionContext is serializable
try {
new ObjectOutputStream(new ByteArrayOutputStream()).writeObject(context);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id("otel.java-conventions")
id("otel.publish-conventions")
id("otel.library-instrumentation")
}

// Name the Spring Boot modules in accordance with https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.developing-auto-configuration.custom-starter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package io.opentelemetry.instrumentation.testing.util;

import static java.util.stream.Collectors.toList;
import static org.assertj.core.api.Assertions.assertThat;

import io.opentelemetry.api.trace.SpanId;
import io.opentelemetry.api.trace.SpanKind;
Expand Down Expand Up @@ -73,6 +74,14 @@ public static List<List<SpanData>> waitForTraces(
+ " total trace(s): "
+ allTraces);
}
// TODO (trask) is there a better location for this assertion?
for (List<SpanData> trace : completeTraces) {
for (SpanData span : trace) {
if (!span.getInstrumentationScopeInfo().getName().equals("test")) {
assertThat(span.getInstrumentationScopeInfo().getVersion()).isNotNull();
}
}
}
return completeTraces;
}

Expand Down

0 comments on commit 0d32150

Please sign in to comment.