Skip to content

Commit

Permalink
Taking account of Fabian's propositions
Browse files Browse the repository at this point in the history
Signed-off-by: Fabrice Scellos <[email protected]>
  • Loading branch information
fscellos authored and fstab committed Apr 12, 2022
1 parent 4edf911 commit ca6145f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 35 deletions.
27 changes: 7 additions & 20 deletions integration_tests/it_exemplars_otel_agent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_bom</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

Expand All @@ -33,26 +40,6 @@
<artifactId>okhttp</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_tracer_common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_tracer_otel</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_tracer_otel_agent</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_hotspot</artifactId>
Expand Down
5 changes: 5 additions & 0 deletions simpleclient_bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@
<artifactId>simpleclient_httpserver</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_tracer_common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_jetty</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@

public class OpenTelemetrySpanContextSupplier implements SpanContextSupplier {

public static boolean isAvailable() {
public static boolean isAvailable() {
try {
if ("inactive".equalsIgnoreCase(System.getProperties().getProperty("io.prometheus.otelExemplars"))) {
return false;
}
OpenTelemetrySpanContextSupplier test = new OpenTelemetrySpanContextSupplier();
test.getSpanId();
test.getTraceId();
test.isSampled();
return true;
} catch (LinkageError ignored) {
// NoClassDefFoundError:
Expand All @@ -25,20 +26,20 @@ public static boolean isAvailable() {
}
}

@Override
public String getTraceId() {
String traceId = Span.current().getSpanContext().getTraceId();
return TraceId.isValid(traceId) ? traceId : null;
}
@Override
public String getTraceId() {
String traceId = Span.current().getSpanContext().getTraceId();
return TraceId.isValid(traceId) ? traceId : null;
}

@Override
public String getSpanId() {
String spanId = Span.current().getSpanContext().getSpanId();
return SpanId.isValid(spanId) ? spanId : null;
}
@Override
public String getSpanId() {
String spanId = Span.current().getSpanContext().getSpanId();
return SpanId.isValid(spanId) ? spanId : null;
}

@Override
public boolean isSampled() {
return Span.current().getSpanContext().isSampled();
}
@Override
public boolean isSampled() {
return Span.current().getSpanContext().isSampled();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public static boolean isAvailable() {
OpenTelemetryAgentSpanContextSupplier test = new OpenTelemetryAgentSpanContextSupplier();
test.getSpanId();
test.getTraceId();
test.isSampled();
return true;
} catch (LinkageError ignored) {
// NoClassDefFoundError:
Expand Down

0 comments on commit ca6145f

Please sign in to comment.