Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support using OpenTelemetry Event API inside @WithSpan annotated method #8019

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
mcculls marked this conversation as resolved.
Show resolved Hide resolved
"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
}
}
Loading