Skip to content

Commit

Permalink
Fix missing OtelSpanEvent helper when using Event API from inside @Wi…
Browse files Browse the repository at this point in the history
…thSpan annotated method (#8019)
  • Loading branch information
mcculls authored and PerfectSlayer committed Nov 28, 2024
1 parent e616734 commit 057c48b
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ public String[] helperClassNames() {
"datadog.opentelemetry.shim.trace.OtelSpanBuilder",
"datadog.opentelemetry.shim.trace.OtelSpanBuilder$1",
"datadog.opentelemetry.shim.trace.OtelSpanContext",
"datadog.opentelemetry.shim.trace.OtelSpanEvent",
"datadog.opentelemetry.shim.trace.OtelSpanEvent$AttributesJsonParser",
"datadog.opentelemetry.shim.trace.OtelSpanLink",
"datadog.opentelemetry.shim.trace.OtelTracer",
"datadog.opentelemetry.shim.trace.OtelTracerBuilder",
"datadog.opentelemetry.shim.trace.OtelTracerProvider",
"datadog.opentelemetry.shim.trace.OtelSpanEvent",
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public String[] helperClassNames() {
"datadog.opentelemetry.shim.trace.OtelSpanBuilder",
"datadog.opentelemetry.shim.trace.OtelSpanBuilder$1",
"datadog.opentelemetry.shim.trace.OtelSpanContext",
"datadog.opentelemetry.shim.trace.OtelSpanEvent",
"datadog.opentelemetry.shim.trace.OtelSpanEvent$AttributesJsonParser",
"datadog.opentelemetry.shim.trace.OtelSpanLink",
"datadog.opentelemetry.shim.trace.OtelTracer",
"datadog.opentelemetry.shim.trace.OtelTracerBuilder",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public String[] helperClassNames() {
"datadog.opentelemetry.shim.trace.OtelSpanBuilder",
"datadog.opentelemetry.shim.trace.OtelSpanBuilder$1",
"datadog.opentelemetry.shim.trace.OtelSpanContext",
"datadog.opentelemetry.shim.trace.OtelSpanEvent",
"datadog.opentelemetry.shim.trace.OtelSpanEvent$AttributesJsonParser",
"datadog.opentelemetry.shim.trace.OtelSpanLink",
"datadog.opentelemetry.shim.trace.OtelTracer",
"datadog.opentelemetry.shim.trace.OtelTracerBuilder",
Expand Down
1 change: 1 addition & 0 deletions dd-smoke-tests/opentelemetry/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ application {

dependencies {
implementation group: 'io.opentelemetry', name: 'opentelemetry-api', version: '1.4.0'
implementation group: 'io.opentelemetry.instrumentation', name: 'opentelemetry-instrumentation-annotations', version: '1.20.0'
testImplementation project(':dd-smoke-tests')
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,26 @@
import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.Tracer;
import io.opentelemetry.instrumentation.annotations.WithSpan;

/**
* This application is a minimalistic application to create a trace with Open Telemetry Tracer API.
*/
public class Application {

@WithSpan
static void annotatedSpan() {
Span.current().addEvent("annotated-span-event");
}

public static void main(String[] args) throws InterruptedException {
// Start trace without touching GlobalOpenTelemetry
annotatedSpan();

// Get an Open Telemetry tracer
Tracer tracer = GlobalOpenTelemetry.getTracerProvider().tracerBuilder("smoketests").build();
// Create a trace with few spans

// Start some manual traces
for (int i = 0; i < 10; i++) {
Span span = tracer.spanBuilder("span-" + i).startSpan();
Thread.sleep(20);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package datadog.smoketest

import static java.util.concurrent.TimeUnit.SECONDS

class OpenTelemetrySmokeTest extends AbstractSmokeTest {
public static final int TIMEOUT_SECS = 30

@Override
ProcessBuilder createProcessBuilder() {
def jarPath = System.getProperty("datadog.smoketest.shadowJar.path")
def command = new ArrayList<String>()
command.add(javaPath())
command.addAll(defaultJavaProperties)
command.add("-Ddd.integration.opentelemetry.experimental.enabled=true")
command.add("-Ddd.trace.otel.enabled=true")
command.addAll(["-jar", jarPath])

ProcessBuilder processBuilder = new ProcessBuilder(command)
Expand All @@ -16,6 +20,8 @@ class OpenTelemetrySmokeTest extends AbstractSmokeTest {

def 'receive trace'() {
expect:
waitForTraceCount(1)
waitForTraceCount(11) // 1 annotated, 10 manual
assert testedProcess.waitFor(TIMEOUT_SECS, SECONDS)
assert testedProcess.exitValue() == 0
}
}

0 comments on commit 057c48b

Please sign in to comment.