Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Add simple OTel spans for now.
  • Loading branch information
sarahchen6 committed Feb 24, 2025
commit 11758ff22b6acb16cce1f9fcb490e7538e3e3628
9 changes: 3 additions & 6 deletions dd-smoke-tests/concurrent/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,19 @@ apply from: "$rootDir/gradle/java.gradle"

description = 'Concurrent Integration Tests.'

repositories {
mavenCentral()
application {
mainClassName = 'datadog.smoketest.concurrent.ConcurrentApp'
}

dependencies {
implementation('io.opentelemetry.instrumentation:opentelemetry-instrumentation-annotations:2.13.1')
implementation project(':dd-trace-api')
testImplementation project(':dd-smoke-tests')

testImplementation platform('org.junit:junit-bom:5.10.0')
testImplementation 'org.junit.jupiter:junit-jupiter'
}

application {
mainClassName = 'datadog.smoketest.concurrent.ConcurrentApp'
}

test {
useJUnitPlatform()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,38 @@
package datadog.smoketest.concurrent;

import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.Tracer;
import io.opentelemetry.instrumentation.annotations.WithSpan;

public class ConcurrentApp {
public static void main(String[] args) {

@WithSpan
static void startSpan() {
System.out.println("=====startSpan=====");
}

public static void main(String[] args) throws InterruptedException {
System.out.println("=====ConcurrentApp start=====");

// start parent span
startSpan();

// get an Open Telemetry tracer
Tracer tracer = GlobalOpenTelemetry.getTracerProvider().tracerBuilder("smoketests").build();

// demo ExecutorService
demoExecutorService.main(args);

// demo ForkJoin
demoForkJoin.main(args);

// demo custom spans
for (int i = 0; i < 10; i++) {
Span span = tracer.spanBuilder("span-" + i).startSpan();
Thread.sleep(20);
span.end();
}

// demo something else?

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package datadog.smoketest

import static java.util.concurrent.TimeUnit.SECONDS

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

Expand All @@ -9,6 +11,7 @@ class DemoExecutorServiceTest extends AbstractSmokeTest {
def command = new ArrayList<String>()
command.add(javaPath())
command.addAll(defaultJavaProperties)
command.add("-Ddd.trace.otel.enabled=true")
command.addAll(["-jar", jarPath])

ProcessBuilder processBuilder = new ProcessBuilder(command)
Expand All @@ -19,4 +22,11 @@ class DemoExecutorServiceTest extends AbstractSmokeTest {
expect:
assert true == true
}

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