From 9247ce3d8177cc5b5df176d82935afc482b84b34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20=C3=81lvarez=20=C3=81lvarez?= Date: Wed, 8 Jan 2025 13:45:02 +0100 Subject: [PATCH 1/2] Add propagation to URI#toURL method (#8146) --- .../instrumentation/java/net/URICallSite.java | 16 ++++++++++++++++ .../java/net/URICallSIteTest.groovy | 1 + .../test/java/foo/bar/TestURICallSiteSuite.java | 9 +++++++++ ...txRxCircuitBreakerHttpServerForkedTest.groovy | 5 +++++ .../springboot/controller/SsrfController.java | 16 ++++++++++++++++ .../smoketest/AbstractIastSpringBootTest.groovy | 10 ++++++---- 6 files changed, 53 insertions(+), 4 deletions(-) diff --git a/dd-java-agent/instrumentation/java-net/src/main/java/datadog/trace/instrumentation/java/net/URICallSite.java b/dd-java-agent/instrumentation/java-net/src/main/java/datadog/trace/instrumentation/java/net/URICallSite.java index adab398831a..b0244563f59 100644 --- a/dd-java-agent/instrumentation/java-net/src/main/java/datadog/trace/instrumentation/java/net/URICallSite.java +++ b/dd-java-agent/instrumentation/java-net/src/main/java/datadog/trace/instrumentation/java/net/URICallSite.java @@ -9,6 +9,7 @@ import datadog.trace.api.iast.propagation.CodecModule; import datadog.trace.api.iast.propagation.PropagationModule; import java.net.URI; +import java.net.URL; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -105,4 +106,19 @@ public static URI afterNormalize( } return result; } + + @Propagation + @CallSite.After("java.net.URL java.net.URI.toURL()") + public static URL afterToURL(@CallSite.This final URI uri, @CallSite.Return final URL result) { + final PropagationModule module = InstrumentationBridge.PROPAGATION; + if (module != null && result != null) { + try { + boolean keepRanges = uri.toString().equals(result.toString()); + module.taintObjectIfTainted(result, uri, keepRanges, NOT_MARKED); + } catch (final Throwable e) { + module.onUnexpectedException("After toURL threw", e); + } + } + return result; + } } diff --git a/dd-java-agent/instrumentation/java-net/src/test/groovy/datadog/trace/instrumentation/java/net/URICallSIteTest.groovy b/dd-java-agent/instrumentation/java-net/src/test/groovy/datadog/trace/instrumentation/java/net/URICallSIteTest.groovy index 7ba0764dbd6..882f8dc7605 100644 --- a/dd-java-agent/instrumentation/java-net/src/test/groovy/datadog/trace/instrumentation/java/net/URICallSIteTest.groovy +++ b/dd-java-agent/instrumentation/java-net/src/test/groovy/datadog/trace/instrumentation/java/net/URICallSIteTest.groovy @@ -69,5 +69,6 @@ class URICallSIteTest extends AgentTestRunner { 'toASCIIString' | 'String' | [new URI('http://test.com/index?name=value#fragment')] | true 'toASCIIString' | 'String' | [new URI('http://test.com/漢/index?name=value#fragment')] | false 'toString' | 'String' | [new URI('http://test.com/index?name=value#fragment')] | true + 'toURL' | 'Object' | [new URI('http://test.com/index?name=value#fragment')] | true } } diff --git a/dd-java-agent/instrumentation/java-net/src/test/java/foo/bar/TestURICallSiteSuite.java b/dd-java-agent/instrumentation/java-net/src/test/java/foo/bar/TestURICallSiteSuite.java index 84effd9d680..4dce0724886 100644 --- a/dd-java-agent/instrumentation/java-net/src/test/java/foo/bar/TestURICallSiteSuite.java +++ b/dd-java-agent/instrumentation/java-net/src/test/java/foo/bar/TestURICallSiteSuite.java @@ -1,7 +1,9 @@ package foo.bar; +import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; +import java.net.URL; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -105,4 +107,11 @@ public static String toASCIIString(final URI uri) { LOGGER.debug("After toAsciiString {}", result); return result; } + + public static URL toURL(final URI uri) throws MalformedURLException { + LOGGER.debug("Before toURL {}", uri); + final URL result = uri.toURL(); + LOGGER.debug("After toURL {}", result); + return result; + } } diff --git a/dd-java-agent/instrumentation/vertx-rx-3.5/src/test/groovy/server/VertxRxCircuitBreakerHttpServerForkedTest.groovy b/dd-java-agent/instrumentation/vertx-rx-3.5/src/test/groovy/server/VertxRxCircuitBreakerHttpServerForkedTest.groovy index 694ae1bf7c4..01479aad752 100644 --- a/dd-java-agent/instrumentation/vertx-rx-3.5/src/test/groovy/server/VertxRxCircuitBreakerHttpServerForkedTest.groovy +++ b/dd-java-agent/instrumentation/vertx-rx-3.5/src/test/groovy/server/VertxRxCircuitBreakerHttpServerForkedTest.groovy @@ -49,6 +49,11 @@ class VertxRxCircuitBreakerHttpServerForkedTest extends VertxHttpServerForkedTes false } + @Override + boolean testSessionId() { + false + } + static class VertxRxCircuitBreakerWebTestServer extends AbstractVerticle { @Override diff --git a/dd-smoke-tests/iast-util/src/main/java/datadog/smoketest/springboot/controller/SsrfController.java b/dd-smoke-tests/iast-util/src/main/java/datadog/smoketest/springboot/controller/SsrfController.java index 64bcdc4ce66..4b180706aa1 100644 --- a/dd-smoke-tests/iast-util/src/main/java/datadog/smoketest/springboot/controller/SsrfController.java +++ b/dd-smoke-tests/iast-util/src/main/java/datadog/smoketest/springboot/controller/SsrfController.java @@ -3,6 +3,7 @@ import com.squareup.okhttp.OkHttpClient; import com.squareup.okhttp.Request; import java.net.HttpURLConnection; +import java.net.URI; import java.net.URL; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpMethod; @@ -39,6 +40,21 @@ public String ssrf( return "ok"; } + @PostMapping("/uri") + public String uri( + @RequestParam(value = "url", required = false) final String url, + @RequestParam(value = "host", required = false) final String host) { + try { + final URI uri = + url != null ? new URI(url) : new URI("https", null, host, 443, "/test", null, null); + final URL target = uri.toURL(); + final HttpURLConnection conn = (HttpURLConnection) target.openConnection(); + conn.disconnect(); + } catch (final Exception e) { + } + return "ok"; + } + @PostMapping("/apache-httpclient4") public String apacheHttpClient4( @RequestParam(value = "url", required = false) final String url, diff --git a/dd-smoke-tests/iast-util/src/testFixtures/groovy/datadog/smoketest/AbstractIastSpringBootTest.groovy b/dd-smoke-tests/iast-util/src/testFixtures/groovy/datadog/smoketest/AbstractIastSpringBootTest.groovy index 806d8e2bdf9..916dedf17cf 100644 --- a/dd-smoke-tests/iast-util/src/testFixtures/groovy/datadog/smoketest/AbstractIastSpringBootTest.groovy +++ b/dd-smoke-tests/iast-util/src/testFixtures/groovy/datadog/smoketest/AbstractIastSpringBootTest.groovy @@ -688,7 +688,7 @@ abstract class AbstractIastSpringBootTest extends AbstractIastServerSmokeTest { void 'ssrf is present'() { setup: - final url = "http://localhost:${httpPort}/ssrf" + final url = "http://localhost:${httpPort}/ssrf${path}" final body = new FormBody.Builder().add(parameter, value).build() final request = new Request.Builder().url(url).post(body).build() @@ -715,9 +715,11 @@ abstract class AbstractIastSpringBootTest extends AbstractIastServerSmokeTest { } where: - parameter | value - 'url' | 'https://dd.datad0g.com/' - 'host' | 'dd.datad0g.com' + path | parameter | value + '' | 'url' | 'https://dd.datad0g.com/' + '' | 'host' | 'dd.datad0g.com' + '/uri' | 'url' | 'https://dd.datad0g.com/' + '/uri' | 'host' | 'dd.datad0g.com' } void 'ssrf is present (#path) (#parameter)'() { From d3d6f9c5e09d1fc5c243dab56f74520b9573029e Mon Sep 17 00:00:00 2001 From: Stuart McCulloch Date: Wed, 8 Jan 2025 14:21:39 +0000 Subject: [PATCH 2/2] Refactor AgentSpan.Context to be AgentSpanContext (#8168) --- .../decorator/HttpServerDecorator.java | 13 +-- .../http/ClientIpAddressResolver.java | 6 +- .../rmi/ContextDispatcher.java | 4 +- .../rmi/ThreadLocalContext.java | 10 +- .../decorator/HttpServerDecoratorTest.groovy | 13 +-- ...lientIpAddressResolverSpecification.groovy | 14 +-- .../trace/civisibility/ProcessHierarchy.java | 4 +- .../domain/AbstractTestModule.java | 3 +- .../domain/AbstractTestSession.java | 3 +- .../trace/civisibility/domain/TestImpl.java | 5 +- .../civisibility/domain/TestSuiteImpl.java | 5 +- .../buildsystem/BuildSystemModuleImpl.java | 3 +- .../domain/buildsystem/ProxyTestModule.java | 5 +- .../domain/buildsystem/ProxyTestSession.java | 6 +- .../domain/headless/HeadlessTestModule.java | 3 +- .../domain/manualapi/ManualApiTestModule.java | 3 +- .../civisibility/domain/TestImplTest.groovy | 4 +- .../domain/TestSuiteImplTest.groovy | 4 +- .../buildsystem/ProxyTestModuleTest.groovy | 4 +- .../headless/HeadlessTestModuleTest.groovy | 6 +- .../main/java/com/datadog/iast/Reporter.java | 2 +- .../com/datadog/iast/ReporterTest.groovy | 3 +- .../propagation/AgentTextMapPropagator.java | 6 +- .../shim/trace/OtelExtractedContext.java | 6 +- .../opentelemetry/shim/trace/OtelSpan.java | 3 +- .../shim/trace/OtelSpanBuilder.java | 3 +- .../shim/trace/OtelSpanContext.java | 9 +- .../akkahttp/DatadogWrapperHelper.java | 3 +- .../grpc/server/TracingServerInterceptor.java | 7 +- .../aws/v1/sqs/TracingIterator.java | 5 +- .../aws/v2/sqs/TracingIterator.java | 5 +- .../lambda/LambdaHandlerInstrumentation.java | 3 +- .../googlepubsub/PubSubDecorator.java | 4 +- .../GrizzlyHttpHandlerInstrumentation.java | 4 +- .../grizzlyhttp232/GrizzlyDecorator.java | 3 +- .../grpc/server/TracingServerInterceptor.java | 7 +- .../ExtLogRecordInstrumentation.java | 12 +-- .../LoggerNodeInstrumentation.java | 5 +- .../jetty11/JettyServerAdvice.java | 3 +- .../jetty12/JettyServerAdvice.java | 3 +- .../jetty70/JettyServerInstrumentation.java | 3 +- .../jetty76/JettyServerInstrumentation.java | 3 +- .../jetty9/JettyServerInstrumentation.java | 3 +- .../instrumentation/jetty10/HandleAdvice.java | 3 +- .../jms/DatadogMessageListener.java | 3 +- .../JMSMessageConsumerInstrumentation.java | 3 +- .../MDBMessageConsumerInstrumentation.java | 3 +- .../kafka_clients/TracingIterator.java | 4 +- .../kafka_clients38/TracingIterator.java | 4 +- .../KafkaStreamTaskInstrumentation.java | 5 +- .../LibertyServerInstrumentation.java | 3 +- .../LibertyServerInstrumentation.java | 3 +- .../log4j1/CategoryInstrumentation.java | 5 +- .../log4j1/LoggingEventInstrumentation.java | 16 ++-- .../logback/LogbackLoggerInstrumentation.java | 5 +- .../logback/LoggingEventInstrumentation.java | 8 +- .../HttpServerRequestTracingHandler.java | 4 +- .../HttpServerRequestTracingHandler.java | 4 +- .../HttpServerRequestTracingHandler.java | 4 +- .../opentelemetry/OtelContextPropagators.java | 4 +- .../opentelemetry/OtelSpanContext.java | 8 +- .../opentelemetry/TypeConverter.java | 5 +- .../opentracing31/OTSpanContext.java | 8 +- .../opentracing31/OTTracer.java | 7 +- .../opentracing31/TypeConverter.java | 5 +- .../opentracing32/OTSpanContext.java | 8 +- .../opentracing32/OTTracer.java | 7 +- .../opentracing32/TypeConverter.java | 5 +- .../pekkohttp/DatadogWrapperHelper.java | 3 +- .../instrumentation/play23/PlayAdvice.java | 4 +- .../play23/PlayHttpServerDecorator.java | 3 +- .../instrumentation/play24/PlayAdvice.java | 4 +- .../play24/PlayHttpServerDecorator.java | 3 +- .../instrumentation/play26/PlayAdvice.java | 6 +- .../play26/PlayHttpServerDecorator.java | 3 +- .../rabbitmq/amqp/RabbitDecorator.java | 3 +- .../restlet/RestletInstrumentation.java | 3 +- .../rmi/server/RmiServerInstrumentation.java | 3 +- .../servlet2/Servlet2Advice.java | 3 +- .../servlet2/Servlet2Decorator.java | 3 +- .../servlet3/Servlet3Advice.java | 3 +- .../servlet3/Servlet3Decorator.java | 3 +- .../RequestDispatcherInstrumentation.java | 3 +- .../spark/AbstractDatadogSparkListener.java | 3 +- .../spark/DatabricksParentContext.java | 4 +- .../spark/OpenlineageParentContext.java | 4 +- .../instrumentation/spray/SprayHelper.scala | 3 +- .../SprayHttpServerRunSealedRouteAdvice.java | 3 +- .../SpringMessageHandlerInstrumentation.java | 3 +- .../SpringWebHttpServerDecorator.java | 3 +- .../SpringWebHttpServerDecorator.java | 3 +- .../SynapseServerInstrumentation.java | 3 +- .../tinylog2/LogEntryInstrumentation.java | 8 +- ...TinylogLoggingProviderInstrumentation.java | 5 +- .../tomcat/TomcatDecorator.java | 3 +- .../tomcat/TomcatServerInstrumentation.java | 9 +- .../undertow/HandlerInstrumentation.java | 3 +- .../HttpRequestParserInstrumentation.java | 3 +- .../vertx_3_4/server/VertxDecorator.java | 3 +- .../vertx_4_0/server/VertxDecorator.java | 3 +- .../test/server/http/TestHttpServer.groovy | 4 +- .../java/datadog/trace/core/CoreTracer.java | 20 ++-- .../main/java/datadog/trace/core/DDSpan.java | 7 +- .../datadog/trace/core/DDSpanContext.java | 4 +- .../datastreams/DataStreamsMonitoring.java | 4 +- .../core/propagation/CorePropagation.java | 7 +- .../datadog/trace/lambda/LambdaHandler.java | 3 +- .../DDSpanContextPropagationTagsTest.groovy | 10 +- .../trace/core/DDSpanContextTest.groovy | 4 +- .../datadog/trace/core/DDSpanTest.groovy | 6 +- .../java/datadog/opentracing/DDTracer.java | 9 +- .../datadog/opentracing/OTSpanContext.java | 8 +- .../datadog/opentracing/TypeConverter.java | 5 +- internal-api/build.gradle | 2 +- .../instrumentation/api/AgentPropagation.java | 4 +- .../instrumentation/api/AgentSpan.java | 83 +---------------- .../instrumentation/api/AgentSpanContext.java | 92 +++++++++++++++++++ .../instrumentation/api/AgentTracer.java | 47 +++++----- .../instrumentation/api/SpanLink.java | 4 +- .../instrumentation/api/TagContext.java | 2 +- .../instrumentation/api/SpanLinkTest.groovy | 2 +- 121 files changed, 438 insertions(+), 362 deletions(-) create mode 100644 internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentSpanContext.java diff --git a/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/decorator/HttpServerDecorator.java b/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/decorator/HttpServerDecorator.java index d4b57da9808..9383c9f1f29 100644 --- a/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/decorator/HttpServerDecorator.java +++ b/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/decorator/HttpServerDecorator.java @@ -20,6 +20,7 @@ import datadog.trace.bootstrap.ActiveSubsystems; import datadog.trace.bootstrap.instrumentation.api.AgentPropagation; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.bootstrap.instrumentation.api.ErrorPriorities; import datadog.trace.bootstrap.instrumentation.api.InternalSpanTypes; @@ -121,7 +122,7 @@ protected AgentTracer.TracerAPI tracer() { return AgentTracer.get(); } - public AgentSpan.Context.Extracted extract(REQUEST_CARRIER carrier) { + public AgentSpanContext.Extracted extract(REQUEST_CARRIER carrier) { AgentPropagation.ContextVisitor getter = getter(); if (null == carrier || null == getter) { return null; @@ -129,14 +130,14 @@ public AgentSpan.Context.Extracted extract(REQUEST_CARRIER carrier) { return tracer().propagate().extract(carrier, getter); } - /** Deprecated. Use {@link #startSpan(String, Object, AgentSpan.Context.Extracted)} instead. */ + /** Deprecated. Use {@link #startSpan(String, Object, AgentSpanContext.Extracted)} instead. */ @Deprecated - public AgentSpan startSpan(REQUEST_CARRIER carrier, AgentSpan.Context.Extracted context) { + public AgentSpan startSpan(REQUEST_CARRIER carrier, AgentSpanContext.Extracted context) { return startSpan("http-server", carrier, context); } public AgentSpan startSpan( - String instrumentationName, REQUEST_CARRIER carrier, AgentSpan.Context.Extracted context) { + String instrumentationName, REQUEST_CARRIER carrier, AgentSpanContext.Extracted context) { AgentSpan span = tracer() .startSpan(instrumentationName, spanName(), callIGCallbackStart(context)) @@ -156,7 +157,7 @@ public AgentSpan onRequest( final AgentSpan span, final CONNECTION connection, final REQUEST request, - final AgentSpan.Context.Extracted context) { + final AgentSpanContext.Extracted context) { Config config = Config.get(); boolean clientIpResolverEnabled = config.isClientIpEnabled() @@ -379,7 +380,7 @@ public AgentSpan onResponse(final AgentSpan span, final RESPONSE response) { // return super.onError(span, throwable); // } - private AgentSpan.Context.Extracted callIGCallbackStart(AgentSpan.Context.Extracted context) { + private AgentSpanContext.Extracted callIGCallbackStart(AgentSpanContext.Extracted context) { AgentTracer.TracerAPI tracer = tracer(); Supplier> startedCbAppSec = tracer.getCallbackProvider(RequestContextSlot.APPSEC).getCallback(EVENTS.requestStarted()); diff --git a/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/decorator/http/ClientIpAddressResolver.java b/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/decorator/http/ClientIpAddressResolver.java index 4c8ec9c9911..c78ece62197 100644 --- a/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/decorator/http/ClientIpAddressResolver.java +++ b/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/decorator/http/ClientIpAddressResolver.java @@ -1,7 +1,7 @@ package datadog.trace.bootstrap.instrumentation.decorator.http; import datadog.trace.api.interceptor.MutableSpan; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.decorator.http.utils.IPAddressUtil; import java.net.Inet4Address; import java.net.Inet6Address; @@ -28,7 +28,7 @@ public class ClientIpAddressResolver { * @param context extracted context with http headers * @return the inferred IP address, if any */ - public static InetAddress resolve(AgentSpan.Context.Extracted context, MutableSpan span) { + public static InetAddress resolve(AgentSpanContext.Extracted context, MutableSpan span) { try { return doResolve(context, span); } catch (RuntimeException rte) { @@ -37,7 +37,7 @@ public static InetAddress resolve(AgentSpan.Context.Extracted context, MutableSp } } - private static InetAddress doResolve(AgentSpan.Context.Extracted context, MutableSpan span) { + private static InetAddress doResolve(AgentSpanContext.Extracted context, MutableSpan span) { if (context == null) { return null; } diff --git a/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/rmi/ContextDispatcher.java b/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/rmi/ContextDispatcher.java index 7acd70ee533..ea3feb30f63 100644 --- a/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/rmi/ContextDispatcher.java +++ b/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/rmi/ContextDispatcher.java @@ -5,7 +5,7 @@ import static datadog.trace.bootstrap.instrumentation.rmi.ContextPropagator.PROPAGATOR; import static datadog.trace.bootstrap.instrumentation.rmi.ThreadLocalContext.THREAD_LOCAL_CONTEXT; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.ContextVisitors; import java.io.IOException; import java.io.ObjectInput; @@ -42,7 +42,7 @@ public void dispatch(final Remote obj, final RemoteCall call) throws IOException if (PROPAGATOR.isOperationWithPayload(operationId)) { final ContextPayload payload = ContextPayload.read(in); if (payload != null) { - final AgentSpan.Context context = + final AgentSpanContext context = propagate().extract(payload.getContext(), ContextVisitors.stringValuesMap()); THREAD_LOCAL_CONTEXT.set(context); } diff --git a/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/rmi/ThreadLocalContext.java b/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/rmi/ThreadLocalContext.java index 3910b391cbb..4458c6ae561 100644 --- a/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/rmi/ThreadLocalContext.java +++ b/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/rmi/ThreadLocalContext.java @@ -1,21 +1,21 @@ package datadog.trace.bootstrap.instrumentation.rmi; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; public class ThreadLocalContext { public static final ThreadLocalContext THREAD_LOCAL_CONTEXT = new ThreadLocalContext(); - private final ThreadLocal local; + private final ThreadLocal local; public ThreadLocalContext() { local = new ThreadLocal<>(); } - public void set(final AgentSpan.Context context) { + public void set(final AgentSpanContext context) { local.set(context); } - public AgentSpan.Context getAndResetContext() { - final AgentSpan.Context context = local.get(); + public AgentSpanContext getAndResetContext() { + final AgentSpanContext context = local.get(); if (context != null) { local.remove(); } diff --git a/dd-java-agent/agent-bootstrap/src/test/groovy/datadog/trace/bootstrap/instrumentation/decorator/HttpServerDecoratorTest.groovy b/dd-java-agent/agent-bootstrap/src/test/groovy/datadog/trace/bootstrap/instrumentation/decorator/HttpServerDecoratorTest.groovy index 7c453155330..aefddc1a1c3 100644 --- a/dd-java-agent/agent-bootstrap/src/test/groovy/datadog/trace/bootstrap/instrumentation/decorator/HttpServerDecoratorTest.groovy +++ b/dd-java-agent/agent-bootstrap/src/test/groovy/datadog/trace/bootstrap/instrumentation/decorator/HttpServerDecoratorTest.groovy @@ -10,6 +10,7 @@ import datadog.trace.api.gateway.RequestContextSlot import datadog.trace.bootstrap.ActiveSubsystems import datadog.trace.bootstrap.instrumentation.api.AgentPropagation import datadog.trace.bootstrap.instrumentation.api.AgentSpan +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext import datadog.trace.bootstrap.instrumentation.api.AgentTracer import datadog.trace.bootstrap.instrumentation.api.AgentTracer.TracerAPI import datadog.trace.bootstrap.instrumentation.api.ContextVisitors @@ -174,7 +175,7 @@ class HttpServerDecoratorTest extends ServerDecoratorTest { def "test onConnection"() { setup: - def ctx = Mock(AgentSpan.Context.Extracted) + def ctx = Mock(AgentSpanContext.Extracted) def decorator = newDecorator() when: @@ -227,7 +228,7 @@ class HttpServerDecoratorTest extends ServerDecoratorTest { void 'preference for header derived vs peer ip address'() { setup: - def ctx = Mock(AgentSpan.Context.Extracted) + def ctx = Mock(AgentSpanContext.Extracted) def decorator = newDecorator() when: @@ -249,7 +250,7 @@ class HttpServerDecoratorTest extends ServerDecoratorTest { setup: injectSysConfig('dd.trace.client-ip.resolver.enabled', 'false') - def ctx = Mock(AgentSpan.Context.Extracted) + def ctx = Mock(AgentSpanContext.Extracted) def decorator = newDecorator() when: @@ -265,7 +266,7 @@ class HttpServerDecoratorTest extends ServerDecoratorTest { setup: ActiveSubsystems.APPSEC_ACTIVE = false - def ctx = Mock(AgentSpan.Context.Extracted) + def ctx = Mock(AgentSpanContext.Extracted) def decorator = newDecorator() when: @@ -282,7 +283,7 @@ class HttpServerDecoratorTest extends ServerDecoratorTest { injectSysConfig('dd.trace.client-ip.enabled', 'true') ActiveSubsystems.APPSEC_ACTIVE = false - def ctx = Mock(AgentSpan.Context.Extracted) + def ctx = Mock(AgentSpanContext.Extracted) def decorator = newDecorator() when: @@ -303,7 +304,7 @@ class HttpServerDecoratorTest extends ServerDecoratorTest { setup: injectSysConfig('dd.trace.client-ip-header', 'my-header') - def ctx = Mock(AgentSpan.Context.Extracted) + def ctx = Mock(AgentSpanContext.Extracted) def decorator = newDecorator() when: diff --git a/dd-java-agent/agent-bootstrap/src/test/groovy/datadog/trace/bootstrap/instrumentation/decorator/http/ClientIpAddressResolverSpecification.groovy b/dd-java-agent/agent-bootstrap/src/test/groovy/datadog/trace/bootstrap/instrumentation/decorator/http/ClientIpAddressResolverSpecification.groovy index 34607783f13..29e12001bc4 100644 --- a/dd-java-agent/agent-bootstrap/src/test/groovy/datadog/trace/bootstrap/instrumentation/decorator/http/ClientIpAddressResolverSpecification.groovy +++ b/dd-java-agent/agent-bootstrap/src/test/groovy/datadog/trace/bootstrap/instrumentation/decorator/http/ClientIpAddressResolverSpecification.groovy @@ -1,7 +1,7 @@ package datadog.trace.bootstrap.instrumentation.decorator.http import datadog.trace.api.interceptor.MutableSpan -import datadog.trace.bootstrap.instrumentation.api.AgentSpan +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext import spock.lang.Specification class ClientIpAddressResolverSpecification extends Specification { @@ -9,7 +9,7 @@ class ClientIpAddressResolverSpecification extends Specification { void 'test with custom header value=#headerValue'() { setup: MutableSpan span = Stub() - def context = Mock(AgentSpan.Context.Extracted) + def context = Mock(AgentSpanContext.Extracted) 1 * context.getCustomIpHeader() >> headerValue expect: @@ -34,7 +34,7 @@ class ClientIpAddressResolverSpecification extends Specification { setup: MutableSpan span = Stub() def method = "get${headerToCamelCase(header)}" - def context = Mock(AgentSpan.Context.Extracted) + def context = Mock(AgentSpanContext.Extracted) 1 * context."$method"() >> headerValue expect: @@ -75,7 +75,7 @@ class ClientIpAddressResolverSpecification extends Specification { void 'test recognition strategy with custom header'() { setup: MutableSpan span = Stub() - def context = Mock(AgentSpan.Context.Extracted) + def context = Mock(AgentSpanContext.Extracted) when: def ip = ClientIpAddressResolver.resolve(context, span) @@ -90,7 +90,7 @@ class ClientIpAddressResolverSpecification extends Specification { void 'test recognition strategy without custom header'() { setup: MutableSpan span = Mock() - def context = Mock(AgentSpan.Context.Extracted) + def context = Mock(AgentSpanContext.Extracted) when: def ip = ClientIpAddressResolver.resolve(context, span) @@ -132,7 +132,7 @@ class ClientIpAddressResolverSpecification extends Specification { void 'no custom header public IP address is preferred'() { setup: MutableSpan span = Mock() - def context = Mock(AgentSpan.Context.Extracted) + def context = Mock(AgentSpanContext.Extracted) when: def ip = ClientIpAddressResolver.resolve(context, span) @@ -150,7 +150,7 @@ class ClientIpAddressResolverSpecification extends Specification { void 'no custom header all headers are reported'() { setup: MutableSpan span = Mock() - def context = Mock(AgentSpan.Context.Extracted) + def context = Mock(AgentSpanContext.Extracted) when: def ip = ClientIpAddressResolver.resolve(context, span) diff --git a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/ProcessHierarchy.java b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/ProcessHierarchy.java index 240164f2e23..3c22585591d 100644 --- a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/ProcessHierarchy.java +++ b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/ProcessHierarchy.java @@ -4,7 +4,7 @@ import datadog.trace.api.config.CiVisibilityConfig; import datadog.trace.bootstrap.instrumentation.api.AgentPropagation; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.util.Strings; import java.net.InetSocketAddress; import java.util.Properties; @@ -29,7 +29,7 @@ public void forEachKey(Properties carrier, AgentPropagation.KeyClassifier classi } } - @Nullable public final AgentSpan.Context.Extracted parentProcessModuleContext; + @Nullable public final AgentSpanContext.Extracted parentProcessModuleContext; ProcessHierarchy() { parentProcessModuleContext = diff --git a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/AbstractTestModule.java b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/AbstractTestModule.java index 559c7317f7a..18f383106bd 100644 --- a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/AbstractTestModule.java +++ b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/AbstractTestModule.java @@ -7,6 +7,7 @@ import datadog.trace.api.civisibility.telemetry.CiVisibilityMetricCollector; import datadog.trace.api.civisibility.telemetry.tag.EventType; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.bootstrap.instrumentation.api.InternalSpanTypes; import datadog.trace.bootstrap.instrumentation.api.Tags; @@ -30,7 +31,7 @@ public abstract class AbstractTestModule { private final Consumer onSpanFinish; public AbstractTestModule( - AgentSpan.Context sessionSpanContext, + AgentSpanContext sessionSpanContext, String moduleName, @Nullable Long startTime, InstrumentationType instrumentationType, diff --git a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/AbstractTestSession.java b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/AbstractTestSession.java index 407f5042119..90681d6a02e 100644 --- a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/AbstractTestSession.java +++ b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/AbstractTestSession.java @@ -20,6 +20,7 @@ import datadog.trace.api.civisibility.telemetry.tag.Provider; import datadog.trace.api.sampling.PrioritySampling; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.bootstrap.instrumentation.api.InternalSpanTypes; import datadog.trace.bootstrap.instrumentation.api.TagContext; @@ -68,7 +69,7 @@ public AbstractTestSession( // CI Test Cycle protocol requires session's trace ID and span ID to be the same IdGenerationStrategy idGenerationStrategy = config.getIdGenerationStrategy(); DDTraceId traceId = idGenerationStrategy.generateTraceId(); - AgentSpan.Context traceContext = + AgentSpanContext traceContext = new TagContext( CIConstants.CIAPP_TEST_ORIGIN, Collections.emptyMap(), diff --git a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/TestImpl.java b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/TestImpl.java index 5f9dbc76a41..8300bb9afd8 100644 --- a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/TestImpl.java +++ b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/TestImpl.java @@ -25,6 +25,7 @@ import datadog.trace.api.gateway.RequestContextSlot; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.bootstrap.instrumentation.api.InternalSpanTypes; import datadog.trace.bootstrap.instrumentation.api.TagContext; @@ -55,7 +56,7 @@ public class TestImpl implements DDTest { private final TestContext context; public TestImpl( - AgentSpan.Context moduleSpanContext, + AgentSpanContext moduleSpanContext, long suiteId, String moduleName, String testSuiteName, @@ -87,7 +88,7 @@ public TestImpl( this.context = new TestContextImpl(coverageStore); - AgentSpan.Context traceContext = + AgentSpanContext traceContext = new TagContext(CIConstants.CIAPP_TEST_ORIGIN, Collections.emptyMap()); AgentTracer.SpanBuilder spanBuilder = AgentTracer.get() diff --git a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/TestSuiteImpl.java b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/TestSuiteImpl.java index 7caae522969..3318f799e1a 100644 --- a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/TestSuiteImpl.java +++ b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/TestSuiteImpl.java @@ -13,6 +13,7 @@ import datadog.trace.api.civisibility.telemetry.tag.TestFrameworkInstrumentation; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.bootstrap.instrumentation.api.InternalSpanTypes; import datadog.trace.bootstrap.instrumentation.api.Tags; @@ -33,7 +34,7 @@ public class TestSuiteImpl implements DDTestSuite { private static final Logger log = LoggerFactory.getLogger(TestSuiteImpl.class); - private final AgentSpan.Context moduleSpanContext; + private final AgentSpanContext moduleSpanContext; private final AgentSpan span; private final String moduleName; private final String testSuiteName; @@ -52,7 +53,7 @@ public class TestSuiteImpl implements DDTestSuite { private final Consumer onSpanFinish; public TestSuiteImpl( - AgentSpan.Context moduleSpanContext, + AgentSpanContext moduleSpanContext, String moduleName, String testSuiteName, String itrCorrelationId, diff --git a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/buildsystem/BuildSystemModuleImpl.java b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/buildsystem/BuildSystemModuleImpl.java index a4a5384f2a2..9e460bea0a9 100644 --- a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/buildsystem/BuildSystemModuleImpl.java +++ b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/buildsystem/BuildSystemModuleImpl.java @@ -14,6 +14,7 @@ import datadog.trace.api.config.CiVisibilityConfig; import datadog.trace.bootstrap.instrumentation.api.AgentPropagation; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.Tags; import datadog.trace.civisibility.codeowners.Codeowners; import datadog.trace.civisibility.config.ExecutionSettings; @@ -49,7 +50,7 @@ public class BuildSystemModuleImpl extends AbstractTestModule implements BuildSy private volatile boolean testSkippingEnabled; public BuildSystemModuleImpl( - AgentSpan.Context sessionSpanContext, + AgentSpanContext sessionSpanContext, String moduleName, String startCommand, @Nullable Long startTime, diff --git a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/buildsystem/ProxyTestModule.java b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/buildsystem/ProxyTestModule.java index cc0fb403234..0ea5235c523 100644 --- a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/buildsystem/ProxyTestModule.java +++ b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/buildsystem/ProxyTestModule.java @@ -8,6 +8,7 @@ import datadog.trace.api.civisibility.telemetry.CiVisibilityMetricCollector; import datadog.trace.api.civisibility.telemetry.tag.TestFrameworkInstrumentation; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.Tags; import datadog.trace.civisibility.codeowners.Codeowners; import datadog.trace.civisibility.config.EarlyFlakeDetectionSettings; @@ -41,7 +42,7 @@ public class ProxyTestModule implements TestFrameworkModule { private static final Logger log = LoggerFactory.getLogger(ProxyTestModule.class); - private final AgentSpan.Context parentProcessModuleContext; + private final AgentSpanContext parentProcessModuleContext; private final String moduleName; private final ExecutionStrategy executionStrategy; private final SignalClient.Factory signalClientFactory; @@ -56,7 +57,7 @@ public class ProxyTestModule implements TestFrameworkModule { private final Collection testFrameworks = ConcurrentHashMap.newKeySet(); public ProxyTestModule( - AgentSpan.Context parentProcessModuleContext, + AgentSpanContext parentProcessModuleContext, String moduleName, ExecutionStrategy executionStrategy, Config config, diff --git a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/buildsystem/ProxyTestSession.java b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/buildsystem/ProxyTestSession.java index 3ef61b75624..25a7f86b119 100644 --- a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/buildsystem/ProxyTestSession.java +++ b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/buildsystem/ProxyTestSession.java @@ -3,7 +3,7 @@ import datadog.trace.api.Config; import datadog.trace.api.civisibility.coverage.CoverageStore; import datadog.trace.api.civisibility.telemetry.CiVisibilityMetricCollector; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.civisibility.codeowners.Codeowners; import datadog.trace.civisibility.coverage.percentage.child.ChildProcessCoverageReporter; @@ -23,7 +23,7 @@ */ public class ProxyTestSession implements TestFrameworkSession { - private final AgentSpan.Context parentProcessModuleContext; + private final AgentSpanContext parentProcessModuleContext; private final Config config; private final CiVisibilityMetricCollector metricCollector; private final TestDecorator testDecorator; @@ -36,7 +36,7 @@ public class ProxyTestSession implements TestFrameworkSession { private final ExecutionStrategy executionStrategy; public ProxyTestSession( - AgentSpan.Context parentProcessModuleContext, + AgentSpanContext parentProcessModuleContext, Config config, CiVisibilityMetricCollector metricCollector, TestDecorator testDecorator, diff --git a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/headless/HeadlessTestModule.java b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/headless/HeadlessTestModule.java index 2a527fa5580..50d81c9c932 100644 --- a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/headless/HeadlessTestModule.java +++ b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/headless/HeadlessTestModule.java @@ -9,6 +9,7 @@ import datadog.trace.api.civisibility.telemetry.CiVisibilityMetricCollector; import datadog.trace.api.civisibility.telemetry.tag.TestFrameworkInstrumentation; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.Tags; import datadog.trace.civisibility.codeowners.Codeowners; import datadog.trace.civisibility.config.EarlyFlakeDetectionSettings; @@ -39,7 +40,7 @@ public class HeadlessTestModule extends AbstractTestModule implements TestFramew private final ExecutionStrategy executionStrategy; public HeadlessTestModule( - AgentSpan.Context sessionSpanContext, + AgentSpanContext sessionSpanContext, String moduleName, @Nullable Long startTime, Config config, diff --git a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/manualapi/ManualApiTestModule.java b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/manualapi/ManualApiTestModule.java index d33bb675c57..5c5df7d18c1 100644 --- a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/manualapi/ManualApiTestModule.java +++ b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/manualapi/ManualApiTestModule.java @@ -6,6 +6,7 @@ import datadog.trace.api.civisibility.telemetry.CiVisibilityMetricCollector; import datadog.trace.api.civisibility.telemetry.tag.TestFrameworkInstrumentation; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.civisibility.codeowners.Codeowners; import datadog.trace.civisibility.decorator.TestDecorator; import datadog.trace.civisibility.domain.AbstractTestModule; @@ -26,7 +27,7 @@ public class ManualApiTestModule extends AbstractTestModule implements DDTestMod private final CoverageStore.Factory coverageStoreFactory; public ManualApiTestModule( - AgentSpan.Context sessionSpanContext, + AgentSpanContext sessionSpanContext, String moduleName, @Nullable Long startTime, Config config, diff --git a/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/domain/TestImplTest.groovy b/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/domain/TestImplTest.groovy index 1eeff0387f1..80026ece26d 100644 --- a/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/domain/TestImplTest.groovy +++ b/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/domain/TestImplTest.groovy @@ -9,7 +9,7 @@ import datadog.trace.api.civisibility.coverage.CoverageProbes import datadog.trace.api.civisibility.coverage.CoverageStore import datadog.trace.api.civisibility.coverage.NoOpCoverageStore import datadog.trace.api.civisibility.telemetry.tag.TestFrameworkInstrumentation -import datadog.trace.bootstrap.instrumentation.api.AgentSpan +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext import datadog.trace.bootstrap.instrumentation.api.AgentTracer import datadog.trace.civisibility.codeowners.NoCodeowners import datadog.trace.civisibility.decorator.TestDecoratorImpl @@ -89,7 +89,7 @@ class TestImplTest extends SpanWriterTest { def traceId = Stub(DDTraceId) traceId.toLong() >> 123 - def moduleSpanContext = Stub(AgentSpan.Context) + def moduleSpanContext = Stub(AgentSpanContext) moduleSpanContext.getSpanId() >> 456 moduleSpanContext.getTraceId() >> traceId def suiteId = 789 diff --git a/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/domain/TestSuiteImplTest.groovy b/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/domain/TestSuiteImplTest.groovy index a60cb54f512..78d53f7364b 100644 --- a/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/domain/TestSuiteImplTest.groovy +++ b/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/domain/TestSuiteImplTest.groovy @@ -7,7 +7,7 @@ import datadog.trace.api.DDTraceId import datadog.trace.api.civisibility.coverage.CoverageStore import datadog.trace.api.civisibility.coverage.NoOpCoverageStore import datadog.trace.api.civisibility.telemetry.tag.TestFrameworkInstrumentation -import datadog.trace.bootstrap.instrumentation.api.AgentSpan +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext import datadog.trace.bootstrap.instrumentation.api.Tags import datadog.trace.civisibility.codeowners.NoCodeowners import datadog.trace.civisibility.decorator.TestDecoratorImpl @@ -46,7 +46,7 @@ class TestSuiteImplTest extends SpanWriterTest { def traceId = Stub(DDTraceId) traceId.toLong() >> 123 - def moduleSpanContext = Stub(AgentSpan.Context) + def moduleSpanContext = Stub(AgentSpanContext) moduleSpanContext.getSpanId() >> 456 moduleSpanContext.getTraceId() >> traceId diff --git a/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/domain/buildsystem/ProxyTestModuleTest.groovy b/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/domain/buildsystem/ProxyTestModuleTest.groovy index 029e2886d2f..8f360f60f7e 100644 --- a/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/domain/buildsystem/ProxyTestModuleTest.groovy +++ b/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/domain/buildsystem/ProxyTestModuleTest.groovy @@ -2,7 +2,7 @@ package datadog.trace.civisibility.domain.buildsystem import datadog.trace.api.Config import datadog.trace.api.DDTraceId -import datadog.trace.bootstrap.instrumentation.api.AgentSpan +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext import datadog.trace.civisibility.config.EarlyFlakeDetectionSettings import datadog.trace.api.civisibility.config.TestIdentifier import datadog.trace.api.civisibility.coverage.CoverageStore @@ -34,7 +34,7 @@ class ProxyTestModuleTest extends DDSpecification { def traceId = Stub(DDTraceId) traceId.toLong() >> 123 - def moduleSpanContext = Stub(AgentSpan.Context) + def moduleSpanContext = Stub(AgentSpanContext) moduleSpanContext.getSpanId() >> 456 moduleSpanContext.getTraceId() >> traceId diff --git a/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/domain/headless/HeadlessTestModuleTest.groovy b/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/domain/headless/HeadlessTestModuleTest.groovy index cba3f63f529..af803cdbf2d 100644 --- a/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/domain/headless/HeadlessTestModuleTest.groovy +++ b/dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/domain/headless/HeadlessTestModuleTest.groovy @@ -1,12 +1,12 @@ package datadog.trace.civisibility.domain.headless import datadog.trace.api.Config -import datadog.trace.civisibility.config.EarlyFlakeDetectionSettings import datadog.trace.api.civisibility.config.TestIdentifier import datadog.trace.api.civisibility.coverage.CoverageStore import datadog.trace.api.civisibility.telemetry.CiVisibilityMetricCollector -import datadog.trace.bootstrap.instrumentation.api.AgentSpan +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext import datadog.trace.civisibility.codeowners.Codeowners +import datadog.trace.civisibility.config.EarlyFlakeDetectionSettings import datadog.trace.civisibility.config.ExecutionSettings import datadog.trace.civisibility.decorator.TestDecorator import datadog.trace.civisibility.source.LinesResolver @@ -32,7 +32,7 @@ class HeadlessTestModuleTest extends DDSpecification { given: def headlessTestModule = new HeadlessTestModule( - Stub(AgentSpan.Context), + Stub(AgentSpanContext), "test-module", null, config, diff --git a/dd-java-agent/agent-iast/src/main/java/com/datadog/iast/Reporter.java b/dd-java-agent/agent-iast/src/main/java/com/datadog/iast/Reporter.java index 01f7d991b80..db6632b6d88 100644 --- a/dd-java-agent/agent-iast/src/main/java/com/datadog/iast/Reporter.java +++ b/dd-java-agent/agent-iast/src/main/java/com/datadog/iast/Reporter.java @@ -135,7 +135,7 @@ private VulnerabilityBatch getOrCreateVulnerabilityBatch(final AgentSpan span) { } private AgentSpan startNewSpan() { - final AgentSpan.Context tagContext = + final AgentSpanContext tagContext = new TagContext() .withRequestContextDataIast(new IastRequestContext(TaintedObjects.NoOp.INSTANCE)); final AgentSpan span = diff --git a/dd-java-agent/agent-iast/src/test/groovy/com/datadog/iast/ReporterTest.groovy b/dd-java-agent/agent-iast/src/test/groovy/com/datadog/iast/ReporterTest.groovy index 3f3fa6f7a31..fdba6f7f157 100644 --- a/dd-java-agent/agent-iast/src/test/groovy/com/datadog/iast/ReporterTest.groovy +++ b/dd-java-agent/agent-iast/src/test/groovy/com/datadog/iast/ReporterTest.groovy @@ -11,6 +11,7 @@ import datadog.trace.api.gateway.RequestContextSlot import datadog.trace.api.internal.TraceSegment import datadog.trace.bootstrap.instrumentation.api.AgentScope import datadog.trace.bootstrap.instrumentation.api.AgentSpan +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext import datadog.trace.bootstrap.instrumentation.api.AgentTracer import datadog.trace.bootstrap.instrumentation.api.AgentTracer.TracerAPI import datadog.trace.bootstrap.instrumentation.api.InternalSpanTypes @@ -229,7 +230,7 @@ class ReporterTest extends DDSpecification { then: noExceptionThrown() - 1 * tracerAPI.startSpan('iast', 'vulnerability', _ as AgentSpan.Context) >> span + 1 * tracerAPI.startSpan('iast', 'vulnerability', _ as AgentSpanContext) >> span 1 * tracerAPI.activateSpan(span, ScopeSource.MANUAL) >> scope 1 * span.getRequestContext() >> reqCtx 1 * span.setSpanType(InternalSpanTypes.VULNERABILITY) >> span diff --git a/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/context/propagation/AgentTextMapPropagator.java b/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/context/propagation/AgentTextMapPropagator.java index d2589e63064..6f38be0d30b 100644 --- a/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/context/propagation/AgentTextMapPropagator.java +++ b/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/context/propagation/AgentTextMapPropagator.java @@ -7,8 +7,8 @@ import datadog.opentelemetry.shim.trace.OtelExtractedContext; import datadog.opentelemetry.shim.trace.OtelSpan; import datadog.trace.api.TracePropagationStyle; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan.Context.Extracted; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext.Extracted; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.bootstrap.instrumentation.api.TagContext; import datadog.trace.util.PropagationUtils; @@ -38,7 +38,7 @@ public void inject(Context context, @Nullable C carrier, TextMapSetter se } Span span = Span.fromContext(context); if (span.getSpanContext().isValid()) { - AgentSpan.Context agentSpanContext = OtelExtractedContext.extract(context); + AgentSpanContext agentSpanContext = OtelExtractedContext.extract(context); AgentTracer.propagate().inject(agentSpanContext, carrier, setter::set); } } diff --git a/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/trace/OtelExtractedContext.java b/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/trace/OtelExtractedContext.java index 95692743894..a00a0990751 100644 --- a/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/trace/OtelExtractedContext.java +++ b/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/trace/OtelExtractedContext.java @@ -3,7 +3,7 @@ import datadog.trace.api.DDSpanId; import datadog.trace.api.DDTraceId; import datadog.trace.api.sampling.PrioritySampling; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTraceCollector; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.bootstrap.instrumentation.api.PathwayContext; @@ -14,7 +14,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class OtelExtractedContext implements AgentSpan.Context { +public class OtelExtractedContext implements AgentSpanContext { private static final Logger LOGGER = LoggerFactory.getLogger(OtelExtractedContext.class); private final DDTraceId traceId; private final long spanId; @@ -27,7 +27,7 @@ private OtelExtractedContext(SpanContext context) { context.isSampled() ? PrioritySampling.SAMPLER_KEEP : PrioritySampling.UNSET; } - public static AgentSpan.Context extract(Context context) { + public static AgentSpanContext extract(Context context) { Span span = Span.fromContext(context); if (span instanceof OtelSpan) { // avoid creating unnecessary OtelSpanContext diff --git a/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/trace/OtelSpan.java b/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/trace/OtelSpan.java index a140a39ebfe..da3ae4906ea 100644 --- a/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/trace/OtelSpan.java +++ b/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/trace/OtelSpan.java @@ -13,6 +13,7 @@ import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AttachableWrapper; import datadog.trace.bootstrap.instrumentation.api.WithAgentSpan; import io.opentelemetry.api.common.AttributeKey; @@ -165,7 +166,7 @@ public AgentScope activate() { return activateSpan(this.delegate); } - public AgentSpan.Context getAgentSpanContext() { + public AgentSpanContext getAgentSpanContext() { return this.delegate.context(); } diff --git a/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/trace/OtelSpanBuilder.java b/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/trace/OtelSpanBuilder.java index 64f22653e5e..3d3bfa78aaa 100644 --- a/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/trace/OtelSpanBuilder.java +++ b/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/trace/OtelSpanBuilder.java @@ -13,6 +13,7 @@ import datadog.opentelemetry.shim.context.OtelContext; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.common.Attributes; @@ -58,7 +59,7 @@ public OtelSpanBuilder(AgentTracer.SpanBuilder delegate) { @Override public SpanBuilder setParent(Context context) { - AgentSpan.Context extractedContext = extract(context); + AgentSpanContext extractedContext = extract(context); if (extractedContext != null) { this.delegate.asChildOf(extractedContext); this.ignoreActiveSpan = true; diff --git a/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/trace/OtelSpanContext.java b/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/trace/OtelSpanContext.java index 5b18f1931a5..759e3ac4910 100644 --- a/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/trace/OtelSpanContext.java +++ b/dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/trace/OtelSpanContext.java @@ -2,12 +2,13 @@ import datadog.trace.api.DDSpanId; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import io.opentelemetry.api.trace.SpanContext; import io.opentelemetry.api.trace.TraceFlags; import io.opentelemetry.api.trace.TraceState; public class OtelSpanContext implements SpanContext { - final AgentSpan.Context delegate; + final AgentSpanContext delegate; private final boolean sampled; private final boolean remote; private final TraceState traceState; @@ -15,7 +16,7 @@ public class OtelSpanContext implements SpanContext { private String spanId; public OtelSpanContext( - AgentSpan.Context delegate, boolean sampled, boolean remote, TraceState traceState) { + AgentSpanContext delegate, boolean sampled, boolean remote, TraceState traceState) { this.delegate = delegate; this.sampled = sampled; this.remote = remote; @@ -23,14 +24,14 @@ public OtelSpanContext( } public static SpanContext fromLocalSpan(AgentSpan span) { - AgentSpan.Context delegate = span.context(); + AgentSpanContext delegate = span.context(); AgentSpan localRootSpan = span.getLocalRootSpan(); Integer samplingPriority = localRootSpan.getSamplingPriority(); boolean sampled = samplingPriority != null && samplingPriority > 0; return new OtelSpanContext(delegate, sampled, false, TraceState.getDefault()); } - public static SpanContext fromRemote(AgentSpan.Context extracted, TraceState traceState) { + public static SpanContext fromRemote(AgentSpanContext extracted, TraceState traceState) { return new OtelSpanContext(extracted, extracted.getSamplingPriority() > 0, true, traceState); } diff --git a/dd-java-agent/instrumentation/akka-http/akka-http-10.0/src/main/java/datadog/trace/instrumentation/akkahttp/DatadogWrapperHelper.java b/dd-java-agent/instrumentation/akka-http/akka-http-10.0/src/main/java/datadog/trace/instrumentation/akkahttp/DatadogWrapperHelper.java index 1717189e1b2..5741b8dd945 100644 --- a/dd-java-agent/instrumentation/akka-http/akka-http-10.0/src/main/java/datadog/trace/instrumentation/akkahttp/DatadogWrapperHelper.java +++ b/dd-java-agent/instrumentation/akka-http/akka-http-10.0/src/main/java/datadog/trace/instrumentation/akkahttp/DatadogWrapperHelper.java @@ -7,10 +7,11 @@ import akka.http.scaladsl.model.HttpResponse; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; public class DatadogWrapperHelper { public static AgentScope createSpan(final HttpRequest request) { - final AgentSpan.Context.Extracted extractedContext = DECORATE.extract(request); + final AgentSpanContext.Extracted extractedContext = DECORATE.extract(request); final AgentSpan span = DECORATE.startSpan(request, extractedContext); DECORATE.afterStart(span); DECORATE.onRequest(span, request, request, extractedContext); diff --git a/dd-java-agent/instrumentation/armeria-grpc/src/main/java/datadog/trace/instrumentation/armeria/grpc/server/TracingServerInterceptor.java b/dd-java-agent/instrumentation/armeria-grpc/src/main/java/datadog/trace/instrumentation/armeria/grpc/server/TracingServerInterceptor.java index 8e60fecaf30..c5b0cee8e9b 100644 --- a/dd-java-agent/instrumentation/armeria-grpc/src/main/java/datadog/trace/instrumentation/armeria/grpc/server/TracingServerInterceptor.java +++ b/dd-java-agent/instrumentation/armeria-grpc/src/main/java/datadog/trace/instrumentation/armeria/grpc/server/TracingServerInterceptor.java @@ -20,7 +20,7 @@ import datadog.trace.api.gateway.RequestContextSlot; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan.Context; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.bootstrap.instrumentation.api.TagContext; import io.grpc.ForwardingServerCall; @@ -61,7 +61,7 @@ public ServerCall.Listener interceptCall( return next.startCall(call, headers); } - Context spanContext = propagate().extract(headers, GETTER); + AgentSpanContext spanContext = propagate().extract(headers, GETTER); AgentTracer.TracerAPI tracer = tracer(); spanContext = callIGCallbackRequestStarted(tracer, spanContext); @@ -239,7 +239,8 @@ public void onReady() { // IG helpers follow - private static Context callIGCallbackRequestStarted(AgentTracer.TracerAPI cbp, Context context) { + private static AgentSpanContext callIGCallbackRequestStarted( + AgentTracer.TracerAPI cbp, AgentSpanContext context) { Supplier> startedCbAppSec = cbp.getCallbackProvider(RequestContextSlot.APPSEC).getCallback(EVENTS.requestStarted()); Supplier> startedCbIast = diff --git a/dd-java-agent/instrumentation/aws-java-sqs-1.0/src/main/java/datadog/trace/instrumentation/aws/v1/sqs/TracingIterator.java b/dd-java-agent/instrumentation/aws-java-sqs-1.0/src/main/java/datadog/trace/instrumentation/aws/v1/sqs/TracingIterator.java index 44b6425bca4..ab7067801df 100644 --- a/dd-java-agent/instrumentation/aws-java-sqs-1.0/src/main/java/datadog/trace/instrumentation/aws/v1/sqs/TracingIterator.java +++ b/dd-java-agent/instrumentation/aws-java-sqs-1.0/src/main/java/datadog/trace/instrumentation/aws/v1/sqs/TracingIterator.java @@ -20,6 +20,7 @@ import com.amazonaws.services.sqs.model.Message; import datadog.trace.api.Config; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import java.util.Iterator; import java.util.LinkedHashMap; @@ -31,7 +32,7 @@ public class TracingIterator> implements Iterator> implements Iterator sortedTags = new LinkedHashMap<>(3); diff --git a/dd-java-agent/instrumentation/grizzly-2/src/main/java/datadog/trace/instrumentation/grizzly/GrizzlyHttpHandlerInstrumentation.java b/dd-java-agent/instrumentation/grizzly-2/src/main/java/datadog/trace/instrumentation/grizzly/GrizzlyHttpHandlerInstrumentation.java index 7177fdae214..fa38d172261 100644 --- a/dd-java-agent/instrumentation/grizzly-2/src/main/java/datadog/trace/instrumentation/grizzly/GrizzlyHttpHandlerInstrumentation.java +++ b/dd-java-agent/instrumentation/grizzly-2/src/main/java/datadog/trace/instrumentation/grizzly/GrizzlyHttpHandlerInstrumentation.java @@ -15,7 +15,7 @@ import datadog.trace.api.gateway.Flow; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan.Context; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import net.bytebuddy.asm.Advice; import org.glassfish.grizzly.http.server.Request; import org.glassfish.grizzly.http.server.Response; @@ -73,7 +73,7 @@ public static class HandleAdvice { return false; } - final Context.Extracted parentContext = DECORATE.extract(request); + final AgentSpanContext.Extracted parentContext = DECORATE.extract(request); final AgentSpan span = DECORATE.startSpan(request, parentContext); DECORATE.afterStart(span); DECORATE.onRequest(span, request, request, parentContext); diff --git a/dd-java-agent/instrumentation/grizzly-http-2.3.20/src/main/java/datadog/trace/instrumentation/grizzlyhttp232/GrizzlyDecorator.java b/dd-java-agent/instrumentation/grizzly-http-2.3.20/src/main/java/datadog/trace/instrumentation/grizzlyhttp232/GrizzlyDecorator.java index f80d2291d5a..4b4e4f3addd 100644 --- a/dd-java-agent/instrumentation/grizzly-http-2.3.20/src/main/java/datadog/trace/instrumentation/grizzlyhttp232/GrizzlyDecorator.java +++ b/dd-java-agent/instrumentation/grizzly-http-2.3.20/src/main/java/datadog/trace/instrumentation/grizzlyhttp232/GrizzlyDecorator.java @@ -11,6 +11,7 @@ import datadog.trace.bootstrap.instrumentation.api.AgentPropagation; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.URIDataAdapter; import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString; import datadog.trace.bootstrap.instrumentation.decorator.HttpServerDecorator; @@ -113,7 +114,7 @@ public static NextAction onHttpCodecFilterExit( } HttpRequestPacket httpRequest = (HttpRequestPacket) httpHeader; HttpResponsePacket httpResponse = httpRequest.getResponse(); - AgentSpan.Context.Extracted context = DECORATE.extract(httpRequest); + AgentSpanContext.Extracted context = DECORATE.extract(httpRequest); AgentSpan span = DECORATE.startSpan(httpRequest, context); AgentScope scope = activateSpan(span, true); DECORATE.afterStart(span); diff --git a/dd-java-agent/instrumentation/grpc-1.5/src/main/java/datadog/trace/instrumentation/grpc/server/TracingServerInterceptor.java b/dd-java-agent/instrumentation/grpc-1.5/src/main/java/datadog/trace/instrumentation/grpc/server/TracingServerInterceptor.java index 276524a098a..aaf5385619d 100644 --- a/dd-java-agent/instrumentation/grpc-1.5/src/main/java/datadog/trace/instrumentation/grpc/server/TracingServerInterceptor.java +++ b/dd-java-agent/instrumentation/grpc-1.5/src/main/java/datadog/trace/instrumentation/grpc/server/TracingServerInterceptor.java @@ -20,7 +20,7 @@ import datadog.trace.api.gateway.RequestContextSlot; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan.Context; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.bootstrap.instrumentation.api.TagContext; import io.grpc.ForwardingServerCall; @@ -61,7 +61,7 @@ public ServerCall.Listener interceptCall( return next.startCall(call, headers); } - Context spanContext = propagate().extract(headers, GETTER); + AgentSpanContext spanContext = propagate().extract(headers, GETTER); AgentTracer.TracerAPI tracer = tracer(); spanContext = callIGCallbackRequestStarted(tracer, spanContext); @@ -238,7 +238,8 @@ public void onReady() { // IG helpers follow - private static Context callIGCallbackRequestStarted(AgentTracer.TracerAPI cbp, Context context) { + private static AgentSpanContext callIGCallbackRequestStarted( + AgentTracer.TracerAPI cbp, AgentSpanContext context) { Supplier> startedCbAppSec = cbp.getCallbackProvider(RequestContextSlot.APPSEC).getCallback(EVENTS.requestStarted()); Supplier> startedCbIast = diff --git a/dd-java-agent/instrumentation/jboss-logmanager/src/main/java/datadog/trace/instrumentation/jbosslogmanager/ExtLogRecordInstrumentation.java b/dd-java-agent/instrumentation/jboss-logmanager/src/main/java/datadog/trace/instrumentation/jbosslogmanager/ExtLogRecordInstrumentation.java index 009e513ca46..49256005b4b 100644 --- a/dd-java-agent/instrumentation/jboss-logmanager/src/main/java/datadog/trace/instrumentation/jbosslogmanager/ExtLogRecordInstrumentation.java +++ b/dd-java-agent/instrumentation/jboss-logmanager/src/main/java/datadog/trace/instrumentation/jbosslogmanager/ExtLogRecordInstrumentation.java @@ -17,7 +17,7 @@ import datadog.trace.api.DDTraceId; import datadog.trace.api.InstrumenterConfig; import datadog.trace.bootstrap.InstrumentationContext; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.bootstrap.instrumentation.api.Tags; import java.util.HashMap; @@ -47,7 +47,7 @@ public ElementMatcher hierarchyMatcher() { @Override public Map contextStore() { - return singletonMap("org.jboss.logmanager.ExtLogRecord", AgentSpan.Context.class.getName()); + return singletonMap("org.jboss.logmanager.ExtLogRecord", AgentSpanContext.class.getName()); } @Override @@ -83,8 +83,8 @@ public static void getMdcValue( return; } - AgentSpan.Context context = - InstrumentationContext.get(ExtLogRecord.class, AgentSpan.Context.class).get(record); + AgentSpanContext context = + InstrumentationContext.get(ExtLogRecord.class, AgentSpanContext.class).get(record); // Nothing to add so return early if (context == null && !AgentTracer.traceConfig().isLogsInjectionEnabled()) { @@ -142,8 +142,8 @@ public static void onExit( return; } - AgentSpan.Context context = - InstrumentationContext.get(ExtLogRecord.class, AgentSpan.Context.class).get(record); + AgentSpanContext context = + InstrumentationContext.get(ExtLogRecord.class, AgentSpanContext.class).get(record); // Nothing to add so return early if (context == null && !AgentTracer.traceConfig().isLogsInjectionEnabled()) { diff --git a/dd-java-agent/instrumentation/jboss-logmanager/src/main/java/datadog/trace/instrumentation/jbosslogmanager/LoggerNodeInstrumentation.java b/dd-java-agent/instrumentation/jboss-logmanager/src/main/java/datadog/trace/instrumentation/jbosslogmanager/LoggerNodeInstrumentation.java index 1190823b508..ea9bf2758ae 100644 --- a/dd-java-agent/instrumentation/jboss-logmanager/src/main/java/datadog/trace/instrumentation/jbosslogmanager/LoggerNodeInstrumentation.java +++ b/dd-java-agent/instrumentation/jboss-logmanager/src/main/java/datadog/trace/instrumentation/jbosslogmanager/LoggerNodeInstrumentation.java @@ -13,6 +13,7 @@ import datadog.trace.bootstrap.CallDepthThreadLocalMap; import datadog.trace.bootstrap.InstrumentationContext; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import java.util.Map; import net.bytebuddy.asm.Advice; import org.jboss.logmanager.ExtLogRecord; @@ -31,7 +32,7 @@ public String instrumentedType() { @Override public Map contextStore() { - return singletonMap("org.jboss.logmanager.ExtLogRecord", AgentSpan.Context.class.getName()); + return singletonMap("org.jboss.logmanager.ExtLogRecord", AgentSpanContext.class.getName()); } @Override @@ -54,7 +55,7 @@ public static boolean attachContext(@Advice.Argument(0) ExtLogRecord record) { AgentSpan span = activeSpan(); if (span != null && traceConfig(span).isLogsInjectionEnabled()) { - InstrumentationContext.get(ExtLogRecord.class, AgentSpan.Context.class) + InstrumentationContext.get(ExtLogRecord.class, AgentSpanContext.class) .put(record, span.context()); } diff --git a/dd-java-agent/instrumentation/jetty-11/src/main/java11/datadog/trace/instrumentation/jetty11/JettyServerAdvice.java b/dd-java-agent/instrumentation/jetty-11/src/main/java11/datadog/trace/instrumentation/jetty11/JettyServerAdvice.java index 72e2444e7c5..17bd8826594 100644 --- a/dd-java-agent/instrumentation/jetty-11/src/main/java11/datadog/trace/instrumentation/jetty11/JettyServerAdvice.java +++ b/dd-java-agent/instrumentation/jetty-11/src/main/java11/datadog/trace/instrumentation/jetty11/JettyServerAdvice.java @@ -8,6 +8,7 @@ import datadog.trace.api.GlobalTracer; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import net.bytebuddy.asm.Advice; import org.eclipse.jetty.server.HttpChannel; import org.eclipse.jetty.server.Request; @@ -25,7 +26,7 @@ public static AgentScope onEnter( return activateSpan((AgentSpan) existingSpan); } - final AgentSpan.Context.Extracted extractedContext = DECORATE.extract(req); + final AgentSpanContext.Extracted extractedContext = DECORATE.extract(req); span = DECORATE.startSpan(req, extractedContext); final AgentScope scope = activateSpan(span, true); span.setMeasured(true); diff --git a/dd-java-agent/instrumentation/jetty-12/src/main/java17/datadog/trace/instrumentation/jetty12/JettyServerAdvice.java b/dd-java-agent/instrumentation/jetty-12/src/main/java17/datadog/trace/instrumentation/jetty12/JettyServerAdvice.java index a6f8f462c58..86145b59ce9 100644 --- a/dd-java-agent/instrumentation/jetty-12/src/main/java17/datadog/trace/instrumentation/jetty12/JettyServerAdvice.java +++ b/dd-java-agent/instrumentation/jetty-12/src/main/java17/datadog/trace/instrumentation/jetty12/JettyServerAdvice.java @@ -7,6 +7,7 @@ import datadog.trace.api.GlobalTracer; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import net.bytebuddy.asm.Advice; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.internal.HttpChannelState; @@ -27,7 +28,7 @@ public static void onExit( } } - final AgentSpan.Context.Extracted extractedContext = JettyDecorator.DECORATE.extract(req); + final AgentSpanContext.Extracted extractedContext = JettyDecorator.DECORATE.extract(req); final AgentSpan span = JettyDecorator.DECORATE.startSpan(req, extractedContext); try (final AgentScope scope = activateSpan(span, true)) { span.setMeasured(true); diff --git a/dd-java-agent/instrumentation/jetty-7.0/src/main/java/datadog/trace/instrumentation/jetty70/JettyServerInstrumentation.java b/dd-java-agent/instrumentation/jetty-7.0/src/main/java/datadog/trace/instrumentation/jetty70/JettyServerInstrumentation.java index d9315332101..1439aa10912 100644 --- a/dd-java-agent/instrumentation/jetty-7.0/src/main/java/datadog/trace/instrumentation/jetty70/JettyServerInstrumentation.java +++ b/dd-java-agent/instrumentation/jetty-7.0/src/main/java/datadog/trace/instrumentation/jetty70/JettyServerInstrumentation.java @@ -19,6 +19,7 @@ import datadog.trace.bootstrap.InstrumentationContext; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.instrumentation.jetty.ConnectionHandleRequestVisitor; import java.util.Map; import net.bytebuddy.asm.Advice; @@ -155,7 +156,7 @@ public static AgentScope onEnter( return activateSpan((AgentSpan) existingSpan); } - final AgentSpan.Context.Extracted extractedContext = DECORATE.extract(req); + final AgentSpanContext.Extracted extractedContext = DECORATE.extract(req); span = DECORATE.startSpan(req, extractedContext); final AgentScope scope = activateSpan(span, true); DECORATE.afterStart(span); diff --git a/dd-java-agent/instrumentation/jetty-7.6/src/main/java/datadog/trace/instrumentation/jetty76/JettyServerInstrumentation.java b/dd-java-agent/instrumentation/jetty-7.6/src/main/java/datadog/trace/instrumentation/jetty76/JettyServerInstrumentation.java index 30359485db9..00daf86582e 100644 --- a/dd-java-agent/instrumentation/jetty-7.6/src/main/java/datadog/trace/instrumentation/jetty76/JettyServerInstrumentation.java +++ b/dd-java-agent/instrumentation/jetty-7.6/src/main/java/datadog/trace/instrumentation/jetty76/JettyServerInstrumentation.java @@ -19,6 +19,7 @@ import datadog.trace.bootstrap.InstrumentationContext; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.instrumentation.jetty.ConnectionHandleRequestVisitor; import java.util.Map; import net.bytebuddy.asm.Advice; @@ -156,7 +157,7 @@ public static AgentScope onEnter( return activateSpan((AgentSpan) existingSpan); } - final AgentSpan.Context.Extracted extractedContext = DECORATE.extract(req); + final AgentSpanContext.Extracted extractedContext = DECORATE.extract(req); span = DECORATE.startSpan(req, extractedContext); final AgentScope scope = activateSpan(span, true); DECORATE.afterStart(span); diff --git a/dd-java-agent/instrumentation/jetty-9/src/main/java/datadog/trace/instrumentation/jetty9/JettyServerInstrumentation.java b/dd-java-agent/instrumentation/jetty-9/src/main/java/datadog/trace/instrumentation/jetty9/JettyServerInstrumentation.java index e3f0115ca85..8890769c5e2 100644 --- a/dd-java-agent/instrumentation/jetty-9/src/main/java/datadog/trace/instrumentation/jetty9/JettyServerInstrumentation.java +++ b/dd-java-agent/instrumentation/jetty-9/src/main/java/datadog/trace/instrumentation/jetty9/JettyServerInstrumentation.java @@ -24,6 +24,7 @@ import datadog.trace.api.ProductActivation; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.bootstrap.instrumentation.java.concurrent.ExcludeFilter; import java.util.Arrays; @@ -170,7 +171,7 @@ public static AgentScope onEnter( return activateSpan((AgentSpan) existingSpan); } - final AgentSpan.Context.Extracted extractedContext = DECORATE.extract(req); + final AgentSpanContext.Extracted extractedContext = DECORATE.extract(req); span = DECORATE.startSpan(req, extractedContext); final AgentScope scope = activateSpan(span, true); DECORATE.afterStart(span); diff --git a/dd-java-agent/instrumentation/jetty-9/src/main/java_jetty10/datadog/trace/instrumentation/jetty10/HandleAdvice.java b/dd-java-agent/instrumentation/jetty-9/src/main/java_jetty10/datadog/trace/instrumentation/jetty10/HandleAdvice.java index e9e851da803..fb55788e974 100644 --- a/dd-java-agent/instrumentation/jetty-9/src/main/java_jetty10/datadog/trace/instrumentation/jetty10/HandleAdvice.java +++ b/dd-java-agent/instrumentation/jetty-9/src/main/java_jetty10/datadog/trace/instrumentation/jetty10/HandleAdvice.java @@ -8,6 +8,7 @@ import datadog.trace.api.GlobalTracer; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import net.bytebuddy.asm.Advice; import org.eclipse.jetty.server.HttpChannel; import org.eclipse.jetty.server.Request; @@ -24,7 +25,7 @@ public static AgentScope onEnter( return activateSpan((AgentSpan) existingSpan); } - final AgentSpan.Context.Extracted extractedContext = DECORATE.extract(req); + final AgentSpanContext.Extracted extractedContext = DECORATE.extract(req); span = DECORATE.startSpan(req, extractedContext); DECORATE.afterStart(span); DECORATE.onRequest(span, req, req, extractedContext); diff --git a/dd-java-agent/instrumentation/jms/src/main/java/datadog/trace/instrumentation/jms/DatadogMessageListener.java b/dd-java-agent/instrumentation/jms/src/main/java/datadog/trace/instrumentation/jms/DatadogMessageListener.java index b79bd026e38..6951b3707e1 100644 --- a/dd-java-agent/instrumentation/jms/src/main/java/datadog/trace/instrumentation/jms/DatadogMessageListener.java +++ b/dd-java-agent/instrumentation/jms/src/main/java/datadog/trace/instrumentation/jms/DatadogMessageListener.java @@ -14,6 +14,7 @@ import datadog.trace.bootstrap.ContextStore; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.jms.MessageConsumerState; import datadog.trace.bootstrap.instrumentation.jms.SessionState; import javax.jms.Message; @@ -37,7 +38,7 @@ public DatadogMessageListener( @Override public void onMessage(Message message) { AgentSpan span; - AgentSpan.Context propagatedContext = null; + AgentSpanContext propagatedContext = null; if (!consumerState.isPropagationDisabled()) { propagatedContext = propagate().extract(message, GETTER); } diff --git a/dd-java-agent/instrumentation/jms/src/main/java/datadog/trace/instrumentation/jms/JMSMessageConsumerInstrumentation.java b/dd-java-agent/instrumentation/jms/src/main/java/datadog/trace/instrumentation/jms/JMSMessageConsumerInstrumentation.java index f71cf372b61..105c325f638 100644 --- a/dd-java-agent/instrumentation/jms/src/main/java/datadog/trace/instrumentation/jms/JMSMessageConsumerInstrumentation.java +++ b/dd-java-agent/instrumentation/jms/src/main/java/datadog/trace/instrumentation/jms/JMSMessageConsumerInstrumentation.java @@ -23,6 +23,7 @@ import datadog.trace.bootstrap.CallDepthThreadLocalMap; import datadog.trace.bootstrap.InstrumentationContext; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.jms.MessageConsumerState; import datadog.trace.bootstrap.instrumentation.jms.SessionState; import javax.jms.Message; @@ -117,7 +118,7 @@ public static void afterReceive( } AgentSpan span; - AgentSpan.Context propagatedContext = null; + AgentSpanContext propagatedContext = null; if (!consumerState.isPropagationDisabled()) { propagatedContext = propagate().extract(message, GETTER); } diff --git a/dd-java-agent/instrumentation/jms/src/main/java/datadog/trace/instrumentation/jms/MDBMessageConsumerInstrumentation.java b/dd-java-agent/instrumentation/jms/src/main/java/datadog/trace/instrumentation/jms/MDBMessageConsumerInstrumentation.java index dae0d88efb6..20db57e3132 100644 --- a/dd-java-agent/instrumentation/jms/src/main/java/datadog/trace/instrumentation/jms/MDBMessageConsumerInstrumentation.java +++ b/dd-java-agent/instrumentation/jms/src/main/java/datadog/trace/instrumentation/jms/MDBMessageConsumerInstrumentation.java @@ -20,6 +20,7 @@ import datadog.trace.bootstrap.CallDepthThreadLocalMap; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.Message; @@ -66,7 +67,7 @@ public static AgentScope methodEnter(@Advice.Argument(0) final Message message) if (CallDepthThreadLocalMap.incrementCallDepth(MessageListener.class) > 0) { return null; } - AgentSpan.Context propagatedContext = propagate().extract(message, GETTER); + AgentSpanContext propagatedContext = propagate().extract(message, GETTER); AgentSpan span = startSpan(JMS_CONSUME, propagatedContext); CONSUMER_DECORATE.afterStart(span); CharSequence consumerResourceName; diff --git a/dd-java-agent/instrumentation/kafka-clients-0.11/src/main/java/datadog/trace/instrumentation/kafka_clients/TracingIterator.java b/dd-java-agent/instrumentation/kafka-clients-0.11/src/main/java/datadog/trace/instrumentation/kafka_clients/TracingIterator.java index 72f4234d606..67c89158442 100644 --- a/dd-java-agent/instrumentation/kafka-clients-0.11/src/main/java/datadog/trace/instrumentation/kafka_clients/TracingIterator.java +++ b/dd-java-agent/instrumentation/kafka-clients-0.11/src/main/java/datadog/trace/instrumentation/kafka_clients/TracingIterator.java @@ -21,7 +21,7 @@ import datadog.trace.api.Config; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan.Context; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.bootstrap.instrumentation.api.InstrumentationTags; import java.util.Iterator; @@ -79,7 +79,7 @@ protected void startNewRecordSpan(ConsumerRecord val) { AgentSpan span, queueSpan = null; if (val != null) { if (!Config.get().isKafkaClientPropagationDisabledForTopic(val.topic())) { - final Context spanContext = propagate().extract(val.headers(), GETTER); + final AgentSpanContext spanContext = propagate().extract(val.headers(), GETTER); long timeInQueueStart = GETTER.extractTimeInQueueStart(val.headers()); if (timeInQueueStart == 0 || !TIME_IN_QUEUE_ENABLED) { span = startSpan(operationName, spanContext); diff --git a/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java17/datadog/trace/instrumentation/kafka_clients38/TracingIterator.java b/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java17/datadog/trace/instrumentation/kafka_clients38/TracingIterator.java index e30bc02ecd3..ea154f61d2b 100644 --- a/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java17/datadog/trace/instrumentation/kafka_clients38/TracingIterator.java +++ b/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java17/datadog/trace/instrumentation/kafka_clients38/TracingIterator.java @@ -16,7 +16,7 @@ import datadog.trace.api.Config; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan.Context; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.bootstrap.instrumentation.api.InstrumentationTags; import datadog.trace.instrumentation.kafka_common.StreamingContext; @@ -76,7 +76,7 @@ protected void startNewRecordSpan(ConsumerRecord val) { AgentSpan span, queueSpan = null; if (val != null) { if (!Config.get().isKafkaClientPropagationDisabledForTopic(val.topic())) { - final Context spanContext = propagate().extract(val.headers(), GETTER); + final AgentSpanContext spanContext = propagate().extract(val.headers(), GETTER); long timeInQueueStart = GETTER.extractTimeInQueueStart(val.headers()); if (timeInQueueStart == 0 || !KafkaDecorator.TIME_IN_QUEUE_ENABLED) { span = startSpan(operationName, spanContext); diff --git a/dd-java-agent/instrumentation/kafka-streams-0.11/src/main/java/datadog/trace/instrumentation/kafka_streams/KafkaStreamTaskInstrumentation.java b/dd-java-agent/instrumentation/kafka-streams-0.11/src/main/java/datadog/trace/instrumentation/kafka_streams/KafkaStreamTaskInstrumentation.java index de6d392b200..a1307051605 100644 --- a/dd-java-agent/instrumentation/kafka-streams-0.11/src/main/java/datadog/trace/instrumentation/kafka_streams/KafkaStreamTaskInstrumentation.java +++ b/dd-java-agent/instrumentation/kafka-streams-0.11/src/main/java/datadog/trace/instrumentation/kafka_streams/KafkaStreamTaskInstrumentation.java @@ -35,6 +35,7 @@ import datadog.trace.bootstrap.InstrumentationContext; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.instrumentation.kafka_clients.TracingIterableDelegator; import java.util.LinkedHashMap; @@ -228,7 +229,7 @@ public static void start( StreamTaskContext streamTaskContext = InstrumentationContext.get(StreamTask.class, StreamTaskContext.class).get(task); if (!Config.get().isKafkaClientPropagationDisabledForTopic(record.topic())) { - final AgentSpan.Context extractedContext = propagate().extract(record, SR_GETTER); + final AgentSpanContext extractedContext = propagate().extract(record, SR_GETTER); long timeInQueueStart = SR_GETTER.extractTimeInQueueStart(record); if (timeInQueueStart == 0 || !TIME_IN_QUEUE_ENABLED) { span = startSpan(KAFKA_CONSUME, extractedContext); @@ -303,7 +304,7 @@ public static void start( StreamTaskContext streamTaskContext = InstrumentationContext.get(StreamTask.class, StreamTaskContext.class).get(task); if (!Config.get().isKafkaClientPropagationDisabledForTopic(record.topic())) { - final AgentSpan.Context extractedContext = propagate().extract(record, PR_GETTER); + final AgentSpanContext extractedContext = propagate().extract(record, PR_GETTER); long timeInQueueStart = PR_GETTER.extractTimeInQueueStart(record); if (timeInQueueStart == 0 || !TIME_IN_QUEUE_ENABLED) { span = startSpan(KAFKA_CONSUME, extractedContext); diff --git a/dd-java-agent/instrumentation/liberty-20/src/main/java/datadog/trace/instrumentation/liberty20/LibertyServerInstrumentation.java b/dd-java-agent/instrumentation/liberty-20/src/main/java/datadog/trace/instrumentation/liberty20/LibertyServerInstrumentation.java index 8624d67bf56..87960ac1940 100644 --- a/dd-java-agent/instrumentation/liberty-20/src/main/java/datadog/trace/instrumentation/liberty20/LibertyServerInstrumentation.java +++ b/dd-java-agent/instrumentation/liberty-20/src/main/java/datadog/trace/instrumentation/liberty20/LibertyServerInstrumentation.java @@ -26,6 +26,7 @@ import datadog.trace.bootstrap.InstrumentationContext; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.instrumentation.servlet.ServletBlockingHelper; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.Collections; @@ -104,7 +105,7 @@ public static class HandleRequestAdvice { } catch (NullPointerException e) { } - final AgentSpan.Context.Extracted extractedContext = DECORATE.extract(request); + final AgentSpanContext.Extracted extractedContext = DECORATE.extract(request); request.setAttribute(DD_EXTRACTED_CONTEXT_ATTRIBUTE, extractedContext); final AgentSpan span = DECORATE.startSpan(request, extractedContext); scope = activateSpan(span, true); diff --git a/dd-java-agent/instrumentation/liberty-23/src/main/java/datadog/trace/instrumentation/liberty23/LibertyServerInstrumentation.java b/dd-java-agent/instrumentation/liberty-23/src/main/java/datadog/trace/instrumentation/liberty23/LibertyServerInstrumentation.java index 2d8a25b9a8f..9591f2d50e1 100644 --- a/dd-java-agent/instrumentation/liberty-23/src/main/java/datadog/trace/instrumentation/liberty23/LibertyServerInstrumentation.java +++ b/dd-java-agent/instrumentation/liberty-23/src/main/java/datadog/trace/instrumentation/liberty23/LibertyServerInstrumentation.java @@ -26,6 +26,7 @@ import datadog.trace.bootstrap.InstrumentationContext; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.instrumentation.servlet5.JakartaServletBlockingHelper; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import jakarta.servlet.ServletRequest; @@ -106,7 +107,7 @@ public static class HandleRequestAdvice { } catch (NullPointerException e) { } - final AgentSpan.Context.Extracted extractedContext = DECORATE.extract(request); + final AgentSpanContext.Extracted extractedContext = DECORATE.extract(request); request.setAttribute(DD_EXTRACTED_CONTEXT_ATTRIBUTE, extractedContext); final AgentSpan span = DECORATE.startSpan(request, extractedContext); scope = activateSpan(span, true); diff --git a/dd-java-agent/instrumentation/log4j1/src/main/java/datadog/trace/instrumentation/log4j1/CategoryInstrumentation.java b/dd-java-agent/instrumentation/log4j1/src/main/java/datadog/trace/instrumentation/log4j1/CategoryInstrumentation.java index 529afbcbca9..9455d230850 100644 --- a/dd-java-agent/instrumentation/log4j1/src/main/java/datadog/trace/instrumentation/log4j1/CategoryInstrumentation.java +++ b/dd-java-agent/instrumentation/log4j1/src/main/java/datadog/trace/instrumentation/log4j1/CategoryInstrumentation.java @@ -19,6 +19,7 @@ import datadog.trace.agent.tooling.InstrumenterModule; import datadog.trace.bootstrap.InstrumentationContext; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import java.util.Map; import net.bytebuddy.asm.Advice; import org.apache.log4j.spi.LoggingEvent; @@ -37,7 +38,7 @@ public String instrumentedType() { @Override public Map contextStore() { - return singletonMap("org.apache.log4j.spi.LoggingEvent", AgentSpan.Context.class.getName()); + return singletonMap("org.apache.log4j.spi.LoggingEvent", AgentSpanContext.class.getName()); } @Override @@ -57,7 +58,7 @@ public static void onEnter(@Advice.Argument(0) LoggingEvent event) { AgentSpan span = activeSpan(); if (span != null && traceConfig(span).isLogsInjectionEnabled()) { - InstrumentationContext.get(LoggingEvent.class, AgentSpan.Context.class) + InstrumentationContext.get(LoggingEvent.class, AgentSpanContext.class) .put(event, span.context()); } } diff --git a/dd-java-agent/instrumentation/log4j1/src/main/java/datadog/trace/instrumentation/log4j1/LoggingEventInstrumentation.java b/dd-java-agent/instrumentation/log4j1/src/main/java/datadog/trace/instrumentation/log4j1/LoggingEventInstrumentation.java index e9e37411010..91762a7d498 100644 --- a/dd-java-agent/instrumentation/log4j1/src/main/java/datadog/trace/instrumentation/log4j1/LoggingEventInstrumentation.java +++ b/dd-java-agent/instrumentation/log4j1/src/main/java/datadog/trace/instrumentation/log4j1/LoggingEventInstrumentation.java @@ -15,7 +15,7 @@ import datadog.trace.api.DDTraceId; import datadog.trace.api.InstrumenterConfig; import datadog.trace.bootstrap.InstrumentationContext; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.bootstrap.instrumentation.api.Tags; import java.util.Hashtable; @@ -37,7 +37,7 @@ public String instrumentedType() { @Override public Map contextStore() { - return singletonMap("org.apache.log4j.spi.LoggingEvent", AgentSpan.Context.class.getName()); + return singletonMap("org.apache.log4j.spi.LoggingEvent", AgentSpanContext.class.getName()); } @Override @@ -65,8 +65,8 @@ public static void getMdcValue( return; } - AgentSpan.Context context = - InstrumentationContext.get(LoggingEvent.class, AgentSpan.Context.class).get(event); + AgentSpanContext context = + InstrumentationContext.get(LoggingEvent.class, AgentSpanContext.class).get(event); // Nothing to add so return early if (context == null && !AgentTracer.traceConfig().isLogsInjectionEnabled()) { @@ -122,8 +122,8 @@ public static boolean onEnter( if (!copyRequired) { return false; } - AgentSpan.Context context = - InstrumentationContext.get(LoggingEvent.class, AgentSpan.Context.class).get(event); + AgentSpanContext context = + InstrumentationContext.get(LoggingEvent.class, AgentSpanContext.class).get(event); return (context != null || AgentTracer.traceConfig().isLogsInjectionEnabled()); } @@ -151,8 +151,8 @@ public static void onExit( mdc.put(Tags.DD_VERSION, version); } - AgentSpan.Context context = - InstrumentationContext.get(LoggingEvent.class, AgentSpan.Context.class).get(event); + AgentSpanContext context = + InstrumentationContext.get(LoggingEvent.class, AgentSpanContext.class).get(event); if (context != null) { DDTraceId traceId = context.getTraceId(); diff --git a/dd-java-agent/instrumentation/logback-1/src/main/java/datadog/trace/instrumentation/logback/LogbackLoggerInstrumentation.java b/dd-java-agent/instrumentation/logback-1/src/main/java/datadog/trace/instrumentation/logback/LogbackLoggerInstrumentation.java index c3ad66247bd..09cf9772c34 100644 --- a/dd-java-agent/instrumentation/logback-1/src/main/java/datadog/trace/instrumentation/logback/LogbackLoggerInstrumentation.java +++ b/dd-java-agent/instrumentation/logback-1/src/main/java/datadog/trace/instrumentation/logback/LogbackLoggerInstrumentation.java @@ -20,6 +20,7 @@ import datadog.trace.agent.tooling.InstrumenterModule; import datadog.trace.bootstrap.InstrumentationContext; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import java.util.Map; import net.bytebuddy.asm.Advice; @@ -39,7 +40,7 @@ public String instrumentedType() { @Override public Map contextStore() { return singletonMap( - "ch.qos.logback.classic.spi.ILoggingEvent", AgentSpan.Context.class.getName()); + "ch.qos.logback.classic.spi.ILoggingEvent", AgentSpanContext.class.getName()); } @Override @@ -59,7 +60,7 @@ public static void onEnter(@Advice.Argument(0) ILoggingEvent event) { AgentSpan span = activeSpan(); if (span != null && traceConfig(span).isLogsInjectionEnabled()) { - InstrumentationContext.get(ILoggingEvent.class, AgentSpan.Context.class) + InstrumentationContext.get(ILoggingEvent.class, AgentSpanContext.class) .put(event, span.context()); } } diff --git a/dd-java-agent/instrumentation/logback-1/src/main/java/datadog/trace/instrumentation/logback/LoggingEventInstrumentation.java b/dd-java-agent/instrumentation/logback-1/src/main/java/datadog/trace/instrumentation/logback/LoggingEventInstrumentation.java index 34888eaaa3b..ba9c2a85bee 100644 --- a/dd-java-agent/instrumentation/logback-1/src/main/java/datadog/trace/instrumentation/logback/LoggingEventInstrumentation.java +++ b/dd-java-agent/instrumentation/logback-1/src/main/java/datadog/trace/instrumentation/logback/LoggingEventInstrumentation.java @@ -17,7 +17,7 @@ import datadog.trace.api.DDTraceId; import datadog.trace.api.InstrumenterConfig; import datadog.trace.bootstrap.InstrumentationContext; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.bootstrap.instrumentation.api.Tags; import java.util.HashMap; @@ -47,7 +47,7 @@ public ElementMatcher hierarchyMatcher() { @Override public Map contextStore() { return singletonMap( - "ch.qos.logback.classic.spi.ILoggingEvent", AgentSpan.Context.class.getName()); + "ch.qos.logback.classic.spi.ILoggingEvent", AgentSpanContext.class.getName()); } @Override @@ -77,8 +77,8 @@ public static void onExit( return; } - AgentSpan.Context context = - InstrumentationContext.get(ILoggingEvent.class, AgentSpan.Context.class).get(event); + AgentSpanContext context = + InstrumentationContext.get(ILoggingEvent.class, AgentSpanContext.class).get(event); // Nothing to add so return early if (context == null && !AgentTracer.traceConfig().isLogsInjectionEnabled()) { diff --git a/dd-java-agent/instrumentation/netty-3.8/src/main/java/datadog/trace/instrumentation/netty38/server/HttpServerRequestTracingHandler.java b/dd-java-agent/instrumentation/netty-3.8/src/main/java/datadog/trace/instrumentation/netty38/server/HttpServerRequestTracingHandler.java index 6524d01a707..75f62379c21 100644 --- a/dd-java-agent/instrumentation/netty-3.8/src/main/java/datadog/trace/instrumentation/netty38/server/HttpServerRequestTracingHandler.java +++ b/dd-java-agent/instrumentation/netty-3.8/src/main/java/datadog/trace/instrumentation/netty38/server/HttpServerRequestTracingHandler.java @@ -7,7 +7,7 @@ import datadog.trace.bootstrap.ContextStore; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan.Context; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.instrumentation.netty38.ChannelTraceContext; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; @@ -44,7 +44,7 @@ public void messageReceived(final ChannelHandlerContext ctx, final MessageEvent final HttpRequest request = (HttpRequest) msg.getMessage(); final HttpHeaders headers = request.headers(); - final Context.Extracted context = DECORATE.extract(headers); + final AgentSpanContext.Extracted context = DECORATE.extract(headers); final AgentSpan span = DECORATE.startSpan(headers, context); channelTraceContext.reset(); diff --git a/dd-java-agent/instrumentation/netty-4.0/src/main/java/datadog/trace/instrumentation/netty40/server/HttpServerRequestTracingHandler.java b/dd-java-agent/instrumentation/netty-4.0/src/main/java/datadog/trace/instrumentation/netty40/server/HttpServerRequestTracingHandler.java index c2dc2613bf7..bbf9fea7011 100644 --- a/dd-java-agent/instrumentation/netty-4.0/src/main/java/datadog/trace/instrumentation/netty40/server/HttpServerRequestTracingHandler.java +++ b/dd-java-agent/instrumentation/netty-4.0/src/main/java/datadog/trace/instrumentation/netty40/server/HttpServerRequestTracingHandler.java @@ -10,7 +10,7 @@ import datadog.trace.api.gateway.Flow; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan.Context; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import io.netty.channel.Channel; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; @@ -40,7 +40,7 @@ public void channelRead(final ChannelHandlerContext ctx, final Object msg) { final HttpRequest request = (HttpRequest) msg; final HttpHeaders headers = request.headers(); - final Context.Extracted extractedContext = DECORATE.extract(headers); + final AgentSpanContext.Extracted extractedContext = DECORATE.extract(headers); final AgentSpan span = DECORATE.startSpan(headers, extractedContext); try (final AgentScope scope = activateSpan(span, true)) { diff --git a/dd-java-agent/instrumentation/netty-4.1/src/main/java/datadog/trace/instrumentation/netty41/server/HttpServerRequestTracingHandler.java b/dd-java-agent/instrumentation/netty-4.1/src/main/java/datadog/trace/instrumentation/netty41/server/HttpServerRequestTracingHandler.java index e8e33f7148b..cca0c608b72 100644 --- a/dd-java-agent/instrumentation/netty-4.1/src/main/java/datadog/trace/instrumentation/netty41/server/HttpServerRequestTracingHandler.java +++ b/dd-java-agent/instrumentation/netty-4.1/src/main/java/datadog/trace/instrumentation/netty41/server/HttpServerRequestTracingHandler.java @@ -10,7 +10,7 @@ import datadog.trace.api.gateway.Flow; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan.Context; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import io.netty.channel.Channel; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; @@ -39,7 +39,7 @@ public void channelRead(final ChannelHandlerContext ctx, final Object msg) { final HttpRequest request = (HttpRequest) msg; final HttpHeaders headers = request.headers(); - final Context.Extracted extractedContext = DECORATE.extract(headers); + final AgentSpanContext.Extracted extractedContext = DECORATE.extract(headers); final AgentSpan span = DECORATE.startSpan(headers, extractedContext); try (final AgentScope scope = activateSpan(span, true)) { diff --git a/dd-java-agent/instrumentation/opentelemetry/opentelemetry-0.3/src/main/java/datadog/trace/instrumentation/opentelemetry/OtelContextPropagators.java b/dd-java-agent/instrumentation/opentelemetry/opentelemetry-0.3/src/main/java/datadog/trace/instrumentation/opentelemetry/OtelContextPropagators.java index ad7ad954aa6..98259733809 100644 --- a/dd-java-agent/instrumentation/opentelemetry/opentelemetry-0.3/src/main/java/datadog/trace/instrumentation/opentelemetry/OtelContextPropagators.java +++ b/dd-java-agent/instrumentation/opentelemetry/opentelemetry-0.3/src/main/java/datadog/trace/instrumentation/opentelemetry/OtelContextPropagators.java @@ -1,7 +1,7 @@ package datadog.trace.instrumentation.opentelemetry; import datadog.trace.bootstrap.instrumentation.api.AgentPropagation; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import io.grpc.Context; import io.opentelemetry.context.propagation.ContextPropagators; @@ -44,7 +44,7 @@ public void inject(final Context context, final C carrier, final Setter s @Override public Context extract(final Context context, final C carrier, final Getter getter) { - final AgentSpan.Context agentContext = + final AgentSpanContext agentContext = tracer.propagate().extract(carrier, new OtelGetter<>(getter)); return TracingContextUtils.withSpan( DefaultSpan.create(converter.toSpanContext(agentContext)), context); diff --git a/dd-java-agent/instrumentation/opentelemetry/opentelemetry-0.3/src/main/java/datadog/trace/instrumentation/opentelemetry/OtelSpanContext.java b/dd-java-agent/instrumentation/opentelemetry/opentelemetry-0.3/src/main/java/datadog/trace/instrumentation/opentelemetry/OtelSpanContext.java index 067dd215943..d2156bbfa96 100644 --- a/dd-java-agent/instrumentation/opentelemetry/opentelemetry-0.3/src/main/java/datadog/trace/instrumentation/opentelemetry/OtelSpanContext.java +++ b/dd-java-agent/instrumentation/opentelemetry/opentelemetry-0.3/src/main/java/datadog/trace/instrumentation/opentelemetry/OtelSpanContext.java @@ -1,6 +1,6 @@ package datadog.trace.instrumentation.opentelemetry; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import io.opentelemetry.trace.SpanContext; import io.opentelemetry.trace.SpanId; import io.opentelemetry.trace.TraceFlags; @@ -9,9 +9,9 @@ public class OtelSpanContext extends SpanContext { private static final TraceFlags FLAGS = TraceFlags.builder().setIsSampled(true).build(); - private final AgentSpan.Context delegate; + private final AgentSpanContext delegate; - OtelSpanContext(final AgentSpan.Context delegate) { + OtelSpanContext(final AgentSpanContext delegate) { this.delegate = delegate; } @@ -41,7 +41,7 @@ public boolean isRemote() { return false; } - AgentSpan.Context getDelegate() { + AgentSpanContext getDelegate() { return delegate; } } diff --git a/dd-java-agent/instrumentation/opentelemetry/opentelemetry-0.3/src/main/java/datadog/trace/instrumentation/opentelemetry/TypeConverter.java b/dd-java-agent/instrumentation/opentelemetry/opentelemetry-0.3/src/main/java/datadog/trace/instrumentation/opentelemetry/TypeConverter.java index de139c498bf..4aa57231e3d 100644 --- a/dd-java-agent/instrumentation/opentelemetry/opentelemetry-0.3/src/main/java/datadog/trace/instrumentation/opentelemetry/TypeConverter.java +++ b/dd-java-agent/instrumentation/opentelemetry/opentelemetry-0.3/src/main/java/datadog/trace/instrumentation/opentelemetry/TypeConverter.java @@ -2,6 +2,7 @@ import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.bootstrap.instrumentation.api.AttachableWrapper; import io.opentelemetry.context.Scope; @@ -67,7 +68,7 @@ public Scope toScope(final AgentScope scope) { return new OtelScope(scope); } - public SpanContext toSpanContext(final AgentSpan.Context context) { + public SpanContext toSpanContext(final AgentSpanContext context) { if (context == null) { return null; } @@ -78,7 +79,7 @@ public SpanContext toSpanContext(final AgentSpan.Context context) { return new OtelSpanContext(context); } - public AgentSpan.Context toContext(final SpanContext spanContext) { + public AgentSpanContext toContext(final SpanContext spanContext) { if (spanContext instanceof OtelSpanContext) { return ((OtelSpanContext) spanContext).getDelegate(); } diff --git a/dd-java-agent/instrumentation/opentracing/api-0.31/src/main/java/datadog/trace/instrumentation/opentracing31/OTSpanContext.java b/dd-java-agent/instrumentation/opentracing/api-0.31/src/main/java/datadog/trace/instrumentation/opentracing31/OTSpanContext.java index 23622bfed57..6bbb8c59a48 100644 --- a/dd-java-agent/instrumentation/opentracing/api-0.31/src/main/java/datadog/trace/instrumentation/opentracing31/OTSpanContext.java +++ b/dd-java-agent/instrumentation/opentracing/api-0.31/src/main/java/datadog/trace/instrumentation/opentracing31/OTSpanContext.java @@ -1,13 +1,13 @@ package datadog.trace.instrumentation.opentracing31; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import io.opentracing.SpanContext; import java.util.Map; class OTSpanContext implements SpanContext { - private final AgentSpan.Context delegate; + private final AgentSpanContext delegate; - OTSpanContext(final AgentSpan.Context delegate) { + OTSpanContext(final AgentSpanContext delegate) { this.delegate = delegate; } @@ -16,7 +16,7 @@ public Iterable> baggageItems() { return delegate.baggageItems(); } - AgentSpan.Context getDelegate() { + AgentSpanContext getDelegate() { return delegate; } } diff --git a/dd-java-agent/instrumentation/opentracing/api-0.31/src/main/java/datadog/trace/instrumentation/opentracing31/OTTracer.java b/dd-java-agent/instrumentation/opentracing/api-0.31/src/main/java/datadog/trace/instrumentation/opentracing31/OTTracer.java index d28679dcd27..c49815fadb4 100644 --- a/dd-java-agent/instrumentation/opentracing/api-0.31/src/main/java/datadog/trace/instrumentation/opentracing31/OTTracer.java +++ b/dd-java-agent/instrumentation/opentracing/api-0.31/src/main/java/datadog/trace/instrumentation/opentracing31/OTTracer.java @@ -1,6 +1,7 @@ package datadog.trace.instrumentation.opentracing31; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.bootstrap.instrumentation.api.ContextVisitors; import datadog.trace.bootstrap.instrumentation.api.ScopeSource; @@ -47,7 +48,7 @@ public SpanBuilder buildSpan(final String operationName) { @Override public void inject(final SpanContext spanContext, final Format format, final C carrier) { if (carrier instanceof TextMap) { - final AgentSpan.Context context = converter.toContext(spanContext); + final AgentSpanContext context = converter.toContext(spanContext); tracer.propagate().inject(context, (TextMap) carrier, OTTextMapSetter.INSTANCE); } else { @@ -58,7 +59,7 @@ public void inject(final SpanContext spanContext, final Format format, fi @Override public SpanContext extract(final Format format, final C carrier) { if (carrier instanceof TextMap) { - final AgentSpan.Context tagContext = + final AgentSpanContext tagContext = tracer .propagate() .extract((TextMap) carrier, ContextVisitors.stringValuesEntrySet()); @@ -98,7 +99,7 @@ public Tracer.SpanBuilder addReference( return this; } - final AgentSpan.Context context = converter.toContext(referencedContext); + final AgentSpanContext context = converter.toContext(referencedContext); if (References.CHILD_OF.equals(referenceType) || References.FOLLOWS_FROM.equals(referenceType)) { diff --git a/dd-java-agent/instrumentation/opentracing/api-0.31/src/main/java/datadog/trace/instrumentation/opentracing31/TypeConverter.java b/dd-java-agent/instrumentation/opentracing/api-0.31/src/main/java/datadog/trace/instrumentation/opentracing31/TypeConverter.java index 21c5aac7740..21dbfc21c51 100644 --- a/dd-java-agent/instrumentation/opentracing/api-0.31/src/main/java/datadog/trace/instrumentation/opentracing31/TypeConverter.java +++ b/dd-java-agent/instrumentation/opentracing/api-0.31/src/main/java/datadog/trace/instrumentation/opentracing31/TypeConverter.java @@ -2,6 +2,7 @@ import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.bootstrap.instrumentation.api.AttachableWrapper; import datadog.trace.instrumentation.opentracing.LogHandler; @@ -73,7 +74,7 @@ public Scope toScope(final AgentScope scope, final boolean finishSpanOnClose) { return new OTScopeManager.OTScope(scope, finishSpanOnClose, this); } - public SpanContext toSpanContext(final AgentSpan.Context context) { + public SpanContext toSpanContext(final AgentSpanContext context) { if (context == null) { return null; } @@ -84,7 +85,7 @@ public SpanContext toSpanContext(final AgentSpan.Context context) { return new OTSpanContext(context); } - public AgentSpan.Context toContext(final SpanContext spanContext) { + public AgentSpanContext toContext(final SpanContext spanContext) { if (spanContext instanceof OTSpanContext) { return ((OTSpanContext) spanContext).getDelegate(); } diff --git a/dd-java-agent/instrumentation/opentracing/api-0.32/src/main/java/datadog/trace/instrumentation/opentracing32/OTSpanContext.java b/dd-java-agent/instrumentation/opentracing/api-0.32/src/main/java/datadog/trace/instrumentation/opentracing32/OTSpanContext.java index d33b26b396d..60cc72c6c2b 100644 --- a/dd-java-agent/instrumentation/opentracing/api-0.32/src/main/java/datadog/trace/instrumentation/opentracing32/OTSpanContext.java +++ b/dd-java-agent/instrumentation/opentracing/api-0.32/src/main/java/datadog/trace/instrumentation/opentracing32/OTSpanContext.java @@ -1,14 +1,14 @@ package datadog.trace.instrumentation.opentracing32; import datadog.trace.api.DDSpanId; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import io.opentracing.SpanContext; import java.util.Map; class OTSpanContext implements SpanContext { - private final AgentSpan.Context delegate; + private final AgentSpanContext delegate; - OTSpanContext(final AgentSpan.Context delegate) { + OTSpanContext(final AgentSpanContext delegate) { this.delegate = delegate; } @@ -27,7 +27,7 @@ public Iterable> baggageItems() { return delegate.baggageItems(); } - AgentSpan.Context getDelegate() { + AgentSpanContext getDelegate() { return delegate; } } diff --git a/dd-java-agent/instrumentation/opentracing/api-0.32/src/main/java/datadog/trace/instrumentation/opentracing32/OTTracer.java b/dd-java-agent/instrumentation/opentracing/api-0.32/src/main/java/datadog/trace/instrumentation/opentracing32/OTTracer.java index 79de6676172..5f642be86fd 100644 --- a/dd-java-agent/instrumentation/opentracing/api-0.32/src/main/java/datadog/trace/instrumentation/opentracing32/OTTracer.java +++ b/dd-java-agent/instrumentation/opentracing/api-0.32/src/main/java/datadog/trace/instrumentation/opentracing32/OTTracer.java @@ -1,6 +1,7 @@ package datadog.trace.instrumentation.opentracing32; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.bootstrap.instrumentation.api.ContextVisitors; import datadog.trace.bootstrap.instrumentation.api.ScopeSource; @@ -59,7 +60,7 @@ public SpanBuilder buildSpan(final String operationName) { @Override public void inject(final SpanContext spanContext, final Format format, final C carrier) { if (carrier instanceof TextMapInject) { - final AgentSpan.Context context = converter.toContext(spanContext); + final AgentSpanContext context = converter.toContext(spanContext); tracer.propagate().inject(context, (TextMapInject) carrier, OTTextMapInjectSetter.INSTANCE); } else { @@ -70,7 +71,7 @@ public void inject(final SpanContext spanContext, final Format format, fi @Override public SpanContext extract(final Format format, final C carrier) { if (carrier instanceof TextMapExtract) { - final AgentSpan.Context tagContext = + final AgentSpanContext tagContext = tracer .propagate() .extract((TextMapExtract) carrier, ContextVisitors.stringValuesEntrySet()); @@ -115,7 +116,7 @@ public Tracer.SpanBuilder addReference( return this; } - final AgentSpan.Context context = converter.toContext(referencedContext); + final AgentSpanContext context = converter.toContext(referencedContext); if (References.CHILD_OF.equals(referenceType) || References.FOLLOWS_FROM.equals(referenceType)) { diff --git a/dd-java-agent/instrumentation/opentracing/api-0.32/src/main/java/datadog/trace/instrumentation/opentracing32/TypeConverter.java b/dd-java-agent/instrumentation/opentracing/api-0.32/src/main/java/datadog/trace/instrumentation/opentracing32/TypeConverter.java index 4c3f3c89a7b..a41f9bc793b 100644 --- a/dd-java-agent/instrumentation/opentracing/api-0.32/src/main/java/datadog/trace/instrumentation/opentracing32/TypeConverter.java +++ b/dd-java-agent/instrumentation/opentracing/api-0.32/src/main/java/datadog/trace/instrumentation/opentracing32/TypeConverter.java @@ -2,6 +2,7 @@ import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.bootstrap.instrumentation.api.AttachableWrapper; import datadog.trace.instrumentation.opentracing.LogHandler; @@ -73,7 +74,7 @@ public Scope toScope(final AgentScope scope, final boolean finishSpanOnClose) { return new OTScopeManager.OTScope(scope, finishSpanOnClose, this); } - public SpanContext toSpanContext(final AgentSpan.Context context) { + public SpanContext toSpanContext(final AgentSpanContext context) { if (context == null) { return null; } @@ -84,7 +85,7 @@ public SpanContext toSpanContext(final AgentSpan.Context context) { return new OTSpanContext(context); } - public AgentSpan.Context toContext(final SpanContext spanContext) { + public AgentSpanContext toContext(final SpanContext spanContext) { if (spanContext instanceof OTSpanContext) { return ((OTSpanContext) spanContext).getDelegate(); } diff --git a/dd-java-agent/instrumentation/pekko-http-1.0/src/main/java/datadog/trace/instrumentation/pekkohttp/DatadogWrapperHelper.java b/dd-java-agent/instrumentation/pekko-http-1.0/src/main/java/datadog/trace/instrumentation/pekkohttp/DatadogWrapperHelper.java index 9437ba83f49..e4a159c6e7a 100644 --- a/dd-java-agent/instrumentation/pekko-http-1.0/src/main/java/datadog/trace/instrumentation/pekkohttp/DatadogWrapperHelper.java +++ b/dd-java-agent/instrumentation/pekko-http-1.0/src/main/java/datadog/trace/instrumentation/pekkohttp/DatadogWrapperHelper.java @@ -5,12 +5,13 @@ import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import org.apache.pekko.http.scaladsl.model.HttpRequest; import org.apache.pekko.http.scaladsl.model.HttpResponse; public class DatadogWrapperHelper { public static AgentScope createSpan(final HttpRequest request) { - final AgentSpan.Context.Extracted extractedContext = DECORATE.extract(request); + final AgentSpanContext.Extracted extractedContext = DECORATE.extract(request); final AgentSpan span = DECORATE.startSpan(request, extractedContext); DECORATE.afterStart(span); DECORATE.onRequest(span, request, request, extractedContext); diff --git a/dd-java-agent/instrumentation/play-2.3/src/main/java/datadog/trace/instrumentation/play23/PlayAdvice.java b/dd-java-agent/instrumentation/play-2.3/src/main/java/datadog/trace/instrumentation/play23/PlayAdvice.java index 78c3296b830..7aaebe110b1 100644 --- a/dd-java-agent/instrumentation/play-2.3/src/main/java/datadog/trace/instrumentation/play23/PlayAdvice.java +++ b/dd-java-agent/instrumentation/play-2.3/src/main/java/datadog/trace/instrumentation/play23/PlayAdvice.java @@ -9,7 +9,7 @@ import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan.Context; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import net.bytebuddy.asm.Advice; import play.api.mvc.Action; import play.api.mvc.Headers; @@ -23,7 +23,7 @@ public static AgentScope onEnter(@Advice.Argument(0) final Request req) { final AgentSpan span; if (activeSpan() == null) { Headers headers = req.headers(); - final Context.Extracted extractedContext = DECORATE.extract(headers); + final AgentSpanContext.Extracted extractedContext = DECORATE.extract(headers); span = DECORATE.startSpan(headers, extractedContext); } else { // An upstream framework (e.g. akka-http, netty) has already started the span. diff --git a/dd-java-agent/instrumentation/play-2.3/src/main/java/datadog/trace/instrumentation/play23/PlayHttpServerDecorator.java b/dd-java-agent/instrumentation/play-2.3/src/main/java/datadog/trace/instrumentation/play23/PlayHttpServerDecorator.java index 99f3245cd54..404157597aa 100644 --- a/dd-java-agent/instrumentation/play-2.3/src/main/java/datadog/trace/instrumentation/play23/PlayHttpServerDecorator.java +++ b/dd-java-agent/instrumentation/play-2.3/src/main/java/datadog/trace/instrumentation/play23/PlayHttpServerDecorator.java @@ -5,6 +5,7 @@ import datadog.trace.api.Config; import datadog.trace.bootstrap.instrumentation.api.AgentPropagation; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.URIDataAdapter; import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString; import datadog.trace.bootstrap.instrumentation.decorator.HttpServerDecorator; @@ -78,7 +79,7 @@ public AgentSpan onRequest( final AgentSpan span, final Request connection, final Request request, - AgentSpan.Context.Extracted context) { + AgentSpanContext.Extracted context) { super.onRequest(span, connection, request, context); if (request != null) { // more about routes here: diff --git a/dd-java-agent/instrumentation/play-2.4/src/main/java/datadog/trace/instrumentation/play24/PlayAdvice.java b/dd-java-agent/instrumentation/play-2.4/src/main/java/datadog/trace/instrumentation/play24/PlayAdvice.java index 7bcba240fe2..452a4db65f6 100644 --- a/dd-java-agent/instrumentation/play-2.4/src/main/java/datadog/trace/instrumentation/play24/PlayAdvice.java +++ b/dd-java-agent/instrumentation/play-2.4/src/main/java/datadog/trace/instrumentation/play24/PlayAdvice.java @@ -9,7 +9,7 @@ import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan.Context; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import net.bytebuddy.asm.Advice; import play.api.mvc.Action; import play.api.mvc.Headers; @@ -29,7 +29,7 @@ public static AgentScope onEnter(@Advice.Argument(value = 0, readOnly = false) R if (activeSpan() == null) { final Headers headers = req.headers(); - final Context.Extracted extractedContext = DECORATE.extract(headers); + final AgentSpanContext.Extracted extractedContext = DECORATE.extract(headers); span = DECORATE.startSpan(headers, extractedContext); } else { // An upstream framework (e.g. akka-http, netty) has already started the span. diff --git a/dd-java-agent/instrumentation/play-2.4/src/main/java/datadog/trace/instrumentation/play24/PlayHttpServerDecorator.java b/dd-java-agent/instrumentation/play-2.4/src/main/java/datadog/trace/instrumentation/play24/PlayHttpServerDecorator.java index 8d43271371c..6837a065059 100644 --- a/dd-java-agent/instrumentation/play-2.4/src/main/java/datadog/trace/instrumentation/play24/PlayHttpServerDecorator.java +++ b/dd-java-agent/instrumentation/play-2.4/src/main/java/datadog/trace/instrumentation/play24/PlayHttpServerDecorator.java @@ -5,6 +5,7 @@ import datadog.trace.api.Config; import datadog.trace.bootstrap.instrumentation.api.AgentPropagation; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.URIDataAdapter; import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString; import datadog.trace.bootstrap.instrumentation.decorator.HttpServerDecorator; @@ -78,7 +79,7 @@ public AgentSpan onRequest( final AgentSpan span, final Request connection, final Request request, - AgentSpan.Context.Extracted context) { + AgentSpanContext.Extracted context) { super.onRequest(span, connection, request, context); if (request != null) { // more about routes here: diff --git a/dd-java-agent/instrumentation/play-2.6/src/main/java/datadog/trace/instrumentation/play26/PlayAdvice.java b/dd-java-agent/instrumentation/play-2.6/src/main/java/datadog/trace/instrumentation/play26/PlayAdvice.java index 9c6d7295daf..a8e17088062 100644 --- a/dd-java-agent/instrumentation/play-2.6/src/main/java/datadog/trace/instrumentation/play26/PlayAdvice.java +++ b/dd-java-agent/instrumentation/play-2.6/src/main/java/datadog/trace/instrumentation/play26/PlayAdvice.java @@ -8,7 +8,7 @@ import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan.Context; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.ResourceNamePriorities; import net.bytebuddy.asm.Advice; import play.api.mvc.Action; @@ -21,7 +21,7 @@ public class PlayAdvice { @Advice.OnMethodEnter(suppress = Throwable.class) public static AgentScope onEnter( @Advice.Argument(value = 0, readOnly = false) Request req, - @Advice.Local("extractedContext") Context.Extracted extractedContext) { + @Advice.Local("extractedContext") AgentSpanContext.Extracted extractedContext) { final AgentSpan span; // If we have already added a `play.request` span, then don't do it again @@ -50,7 +50,7 @@ public static AgentScope onEnter( @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) public static void stopTraceOnResponse( @Advice.Enter final AgentScope playControllerScope, - @Advice.Local("extractedContext") Context.Extracted extractedContext, + @Advice.Local("extractedContext") AgentSpanContext.Extracted extractedContext, @Advice.This final Object thisAction, @Advice.Thrown final Throwable throwable, @Advice.Argument(0) final Request req, diff --git a/dd-java-agent/instrumentation/play-2.6/src/main/java/datadog/trace/instrumentation/play26/PlayHttpServerDecorator.java b/dd-java-agent/instrumentation/play-2.6/src/main/java/datadog/trace/instrumentation/play26/PlayHttpServerDecorator.java index b5267fe7540..be36d190358 100644 --- a/dd-java-agent/instrumentation/play-2.6/src/main/java/datadog/trace/instrumentation/play26/PlayHttpServerDecorator.java +++ b/dd-java-agent/instrumentation/play-2.6/src/main/java/datadog/trace/instrumentation/play26/PlayHttpServerDecorator.java @@ -7,6 +7,7 @@ import datadog.trace.api.cache.DDCaches; import datadog.trace.bootstrap.instrumentation.api.AgentPropagation; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.URIDataAdapter; import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString; import datadog.trace.bootstrap.instrumentation.decorator.HttpServerDecorator; @@ -119,7 +120,7 @@ public AgentSpan onRequest( final AgentSpan span, final Request connection, final Request request, - AgentSpan.Context.Extracted context) { + AgentSpanContext.Extracted context) { super.onRequest(span, connection, request, context); if (request != null) { // more about routes here: diff --git a/dd-java-agent/instrumentation/rabbitmq-amqp-2.7/src/main/java/datadog/trace/instrumentation/rabbitmq/amqp/RabbitDecorator.java b/dd-java-agent/instrumentation/rabbitmq-amqp-2.7/src/main/java/datadog/trace/instrumentation/rabbitmq/amqp/RabbitDecorator.java index 051b9348983..da98323640e 100644 --- a/dd-java-agent/instrumentation/rabbitmq-amqp-2.7/src/main/java/datadog/trace/instrumentation/rabbitmq/amqp/RabbitDecorator.java +++ b/dd-java-agent/instrumentation/rabbitmq-amqp-2.7/src/main/java/datadog/trace/instrumentation/rabbitmq/amqp/RabbitDecorator.java @@ -21,6 +21,7 @@ import datadog.trace.api.naming.SpanNaming; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.bootstrap.instrumentation.api.ContextVisitors; import datadog.trace.bootstrap.instrumentation.api.InternalSpanTypes; @@ -203,7 +204,7 @@ public static AgentScope startReceivingSpan( String queue) { final Map headers = propagate && null != properties ? properties.getHeaders() : null; - AgentSpan.Context parentContext = + AgentSpanContext parentContext = null != headers ? propagate().extract(headers, ContextVisitors.objectValuesMap()) : null; // TODO: check dynamically bound queues - // https://github.com/DataDog/dd-trace-java/pull/2955#discussion_r677787875 diff --git a/dd-java-agent/instrumentation/restlet-2.2/src/main/java/datadog/trace/instrumentation/restlet/RestletInstrumentation.java b/dd-java-agent/instrumentation/restlet-2.2/src/main/java/datadog/trace/instrumentation/restlet/RestletInstrumentation.java index 223e9e9b937..68b808ab66f 100644 --- a/dd-java-agent/instrumentation/restlet-2.2/src/main/java/datadog/trace/instrumentation/restlet/RestletInstrumentation.java +++ b/dd-java-agent/instrumentation/restlet-2.2/src/main/java/datadog/trace/instrumentation/restlet/RestletInstrumentation.java @@ -12,6 +12,7 @@ import datadog.trace.agent.tooling.InstrumenterModule; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import net.bytebuddy.asm.Advice; @AutoService(InstrumenterModule.class) @@ -53,7 +54,7 @@ public String[] helperClassNames() { public static class RestletHandleAdvice { @Advice.OnMethodEnter(suppress = Throwable.class) public static AgentScope beginRequest(@Advice.Argument(0) final HttpExchange exchange) { - AgentSpan.Context.Extracted context = DECORATE.extract(exchange); + AgentSpanContext.Extracted context = DECORATE.extract(exchange); AgentSpan span = DECORATE.startSpan(exchange, context); AgentScope scope = activateSpan(span); DECORATE.afterStart(span); diff --git a/dd-java-agent/instrumentation/rmi/src/main/java/datadog/trace/instrumentation/rmi/server/RmiServerInstrumentation.java b/dd-java-agent/instrumentation/rmi/src/main/java/datadog/trace/instrumentation/rmi/server/RmiServerInstrumentation.java index c1678242280..dab340c3833 100644 --- a/dd-java-agent/instrumentation/rmi/src/main/java/datadog/trace/instrumentation/rmi/server/RmiServerInstrumentation.java +++ b/dd-java-agent/instrumentation/rmi/src/main/java/datadog/trace/instrumentation/rmi/server/RmiServerInstrumentation.java @@ -17,6 +17,7 @@ import datadog.trace.agent.tooling.InstrumenterModule; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import java.lang.reflect.Method; import net.bytebuddy.asm.Advice; import net.bytebuddy.description.type.TypeDescription; @@ -52,7 +53,7 @@ public static class ServerAdvice { @Advice.OnMethodEnter(suppress = Throwable.class, inline = true) public static AgentScope onEnter( @Advice.This final Object thiz, @Advice.Origin final Method method) { - final AgentSpan.Context context = THREAD_LOCAL_CONTEXT.getAndResetContext(); + final AgentSpanContext context = THREAD_LOCAL_CONTEXT.getAndResetContext(); final AgentSpan span; if (context == null) { diff --git a/dd-java-agent/instrumentation/servlet/request-2/src/main/java/datadog/trace/instrumentation/servlet2/Servlet2Advice.java b/dd-java-agent/instrumentation/servlet/request-2/src/main/java/datadog/trace/instrumentation/servlet2/Servlet2Advice.java index 5473d5d7a94..30feb834777 100644 --- a/dd-java-agent/instrumentation/servlet/request-2/src/main/java/datadog/trace/instrumentation/servlet2/Servlet2Advice.java +++ b/dd-java-agent/instrumentation/servlet/request-2/src/main/java/datadog/trace/instrumentation/servlet2/Servlet2Advice.java @@ -13,6 +13,7 @@ import datadog.trace.bootstrap.InstrumentationContext; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.instrumentation.servlet.ServletBlockingHelper; import java.security.Principal; import javax.servlet.ServletRequest; @@ -51,7 +52,7 @@ public static boolean onEnter( InstrumentationContext.get(ServletResponse.class, Integer.class).put(response, 200); } - final AgentSpan.Context.Extracted extractedContext = DECORATE.extract(httpServletRequest); + final AgentSpanContext.Extracted extractedContext = DECORATE.extract(httpServletRequest); final AgentSpan span = DECORATE.startSpan(httpServletRequest, extractedContext); scope = activateSpan(span, true); DECORATE.afterStart(span); diff --git a/dd-java-agent/instrumentation/servlet/request-2/src/main/java/datadog/trace/instrumentation/servlet2/Servlet2Decorator.java b/dd-java-agent/instrumentation/servlet/request-2/src/main/java/datadog/trace/instrumentation/servlet2/Servlet2Decorator.java index d217fda2ea4..1f8005f6049 100644 --- a/dd-java-agent/instrumentation/servlet/request-2/src/main/java/datadog/trace/instrumentation/servlet2/Servlet2Decorator.java +++ b/dd-java-agent/instrumentation/servlet/request-2/src/main/java/datadog/trace/instrumentation/servlet2/Servlet2Decorator.java @@ -4,6 +4,7 @@ import datadog.trace.bootstrap.instrumentation.api.AgentPropagation; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.URIDataAdapter; import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString; import datadog.trace.bootstrap.instrumentation.decorator.HttpServerDecorator; @@ -78,7 +79,7 @@ public AgentSpan onRequest( final AgentSpan span, final HttpServletRequest connection, final HttpServletRequest request, - AgentSpan.Context.Extracted context) { + AgentSpanContext.Extracted context) { assert span != null; if (request != null) { span.setTag("servlet.context", request.getContextPath()); diff --git a/dd-java-agent/instrumentation/servlet/request-3/src/main/java/datadog/trace/instrumentation/servlet3/Servlet3Advice.java b/dd-java-agent/instrumentation/servlet/request-3/src/main/java/datadog/trace/instrumentation/servlet3/Servlet3Advice.java index bc8ca7bb645..fa6018ae060 100644 --- a/dd-java-agent/instrumentation/servlet/request-3/src/main/java/datadog/trace/instrumentation/servlet3/Servlet3Advice.java +++ b/dd-java-agent/instrumentation/servlet/request-3/src/main/java/datadog/trace/instrumentation/servlet3/Servlet3Advice.java @@ -15,6 +15,7 @@ import datadog.trace.api.naming.ClassloaderServiceNames; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.instrumentation.servlet.ServletBlockingHelper; import java.security.Principal; import java.util.concurrent.atomic.AtomicBoolean; @@ -68,7 +69,7 @@ public static boolean onEnter( return false; } - final AgentSpan.Context.Extracted extractedContext = DECORATE.extract(httpServletRequest); + final AgentSpanContext.Extracted extractedContext = DECORATE.extract(httpServletRequest); final AgentSpan span = DECORATE.startSpan(httpServletRequest, extractedContext); scope = activateSpan(span, true); diff --git a/dd-java-agent/instrumentation/servlet/request-3/src/main/java/datadog/trace/instrumentation/servlet3/Servlet3Decorator.java b/dd-java-agent/instrumentation/servlet/request-3/src/main/java/datadog/trace/instrumentation/servlet3/Servlet3Decorator.java index 9b1f179200e..41964668659 100644 --- a/dd-java-agent/instrumentation/servlet/request-3/src/main/java/datadog/trace/instrumentation/servlet3/Servlet3Decorator.java +++ b/dd-java-agent/instrumentation/servlet/request-3/src/main/java/datadog/trace/instrumentation/servlet3/Servlet3Decorator.java @@ -3,6 +3,7 @@ import datadog.trace.api.naming.ClassloaderServiceNames; import datadog.trace.bootstrap.instrumentation.api.AgentPropagation; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.URIDataAdapter; import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString; import datadog.trace.bootstrap.instrumentation.decorator.HttpServerDecorator; @@ -81,7 +82,7 @@ public AgentSpan onRequest( final AgentSpan span, final HttpServletRequest connection, final HttpServletRequest request, - AgentSpan.Context.Extracted context) { + AgentSpanContext.Extracted context) { assert span != null; ClassloaderServiceNames.maybeSetToSpan(span); if (request != null) { diff --git a/dd-java-agent/instrumentation/servlet/src/main/java/datadog/trace/instrumentation/servlet/dispatcher/RequestDispatcherInstrumentation.java b/dd-java-agent/instrumentation/servlet/src/main/java/datadog/trace/instrumentation/servlet/dispatcher/RequestDispatcherInstrumentation.java index 10025a3fa3a..82f5f47c374 100644 --- a/dd-java-agent/instrumentation/servlet/src/main/java/datadog/trace/instrumentation/servlet/dispatcher/RequestDispatcherInstrumentation.java +++ b/dd-java-agent/instrumentation/servlet/src/main/java/datadog/trace/instrumentation/servlet/dispatcher/RequestDispatcherInstrumentation.java @@ -27,6 +27,7 @@ import datadog.trace.bootstrap.InstrumentationContext; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.InternalSpanTypes; import datadog.trace.bootstrap.instrumentation.decorator.HttpClientDecorator; import java.util.Map; @@ -98,7 +99,7 @@ public static AgentScope start( // Don't want to generate a new top-level span return null; } - final AgentSpan.Context parent; + final AgentSpanContext parent; if (servletSpan == null || (parentSpan != null && servletSpan.isSameTrace(parentSpan))) { // Use the parentSpan if the servletSpan is null or part of the same trace. parent = parentSpan.context(); diff --git a/dd-java-agent/instrumentation/spark/src/main/java/datadog/trace/instrumentation/spark/AbstractDatadogSparkListener.java b/dd-java-agent/instrumentation/spark/src/main/java/datadog/trace/instrumentation/spark/AbstractDatadogSparkListener.java index 9572f0cef1a..bbd03d5b897 100644 --- a/dd-java-agent/instrumentation/spark/src/main/java/datadog/trace/instrumentation/spark/AbstractDatadogSparkListener.java +++ b/dd-java-agent/instrumentation/spark/src/main/java/datadog/trace/instrumentation/spark/AbstractDatadogSparkListener.java @@ -13,6 +13,7 @@ import datadog.trace.api.sampling.PrioritySampling; import datadog.trace.api.sampling.SamplingMechanism; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.bootstrap.instrumentation.api.SpanLink; import datadog.trace.util.AgentThreadFactory; @@ -321,7 +322,7 @@ private void addDatabricksSpecificTags( builder.withTag("databricks_job_run_id", databricksJobRunId); builder.withTag("databricks_task_run_id", databricksTaskRunId); - AgentSpan.Context parentContext = + AgentSpanContext parentContext = new DatabricksParentContext(databricksJobId, databricksJobRunId, databricksTaskRunId); if (parentContext.getTraceId() != DDTraceId.ZERO) { diff --git a/dd-java-agent/instrumentation/spark/src/main/java/datadog/trace/instrumentation/spark/DatabricksParentContext.java b/dd-java-agent/instrumentation/spark/src/main/java/datadog/trace/instrumentation/spark/DatabricksParentContext.java index 7e102d0d44b..ce072749228 100644 --- a/dd-java-agent/instrumentation/spark/src/main/java/datadog/trace/instrumentation/spark/DatabricksParentContext.java +++ b/dd-java-agent/instrumentation/spark/src/main/java/datadog/trace/instrumentation/spark/DatabricksParentContext.java @@ -3,7 +3,7 @@ import datadog.trace.api.DDSpanId; import datadog.trace.api.DDTraceId; import datadog.trace.api.sampling.PrioritySampling; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTraceCollector; import datadog.trace.bootstrap.instrumentation.api.PathwayContext; import java.nio.ByteBuffer; @@ -21,7 +21,7 @@ * workflow task spans are generated from the databricks API. The traceId/spanId is computed using * the same hash on both sides to link everything in the same trace */ -public class DatabricksParentContext implements AgentSpan.Context { +public class DatabricksParentContext implements AgentSpanContext { private static final Logger log = LoggerFactory.getLogger(DatabricksParentContext.class); private final DDTraceId traceId; diff --git a/dd-java-agent/instrumentation/spark/src/main/java/datadog/trace/instrumentation/spark/OpenlineageParentContext.java b/dd-java-agent/instrumentation/spark/src/main/java/datadog/trace/instrumentation/spark/OpenlineageParentContext.java index d4ac5775425..e4c2688f064 100644 --- a/dd-java-agent/instrumentation/spark/src/main/java/datadog/trace/instrumentation/spark/OpenlineageParentContext.java +++ b/dd-java-agent/instrumentation/spark/src/main/java/datadog/trace/instrumentation/spark/OpenlineageParentContext.java @@ -3,7 +3,7 @@ import datadog.trace.api.DDSpanId; import datadog.trace.api.DDTraceId; import datadog.trace.api.sampling.PrioritySampling; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTraceCollector; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.bootstrap.instrumentation.api.PathwayContext; @@ -19,7 +19,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class OpenlineageParentContext implements AgentSpan.Context { +public class OpenlineageParentContext implements AgentSpanContext { private static final Logger log = LoggerFactory.getLogger(OpenlineageParentContext.class); private static final Pattern UUID = Pattern.compile( diff --git a/dd-java-agent/instrumentation/spray-1.3/src/main/scala/datadog/trace/instrumentation/spray/SprayHelper.scala b/dd-java-agent/instrumentation/spray-1.3/src/main/scala/datadog/trace/instrumentation/spray/SprayHelper.scala index efaa8142951..f93e0c83a82 100644 --- a/dd-java-agent/instrumentation/spray-1.3/src/main/scala/datadog/trace/instrumentation/spray/SprayHelper.scala +++ b/dd-java-agent/instrumentation/spray-1.3/src/main/scala/datadog/trace/instrumentation/spray/SprayHelper.scala @@ -1,6 +1,7 @@ package datadog.trace.instrumentation.spray import datadog.trace.bootstrap.instrumentation.api.AgentSpan +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext import datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan import datadog.trace.instrumentation.spray.SprayHttpServerDecorator.DECORATE import spray.http.HttpResponse @@ -12,7 +13,7 @@ object SprayHelper { def wrapRequestContext( ctx: RequestContext, span: AgentSpan, - extracted: AgentSpan.Context.Extracted + extracted: AgentSpanContext.Extracted ): RequestContext = { ctx.withRouteResponseMapped(message => { DECORATE.onRequest(span, ctx, ctx.request, extracted) diff --git a/dd-java-agent/instrumentation/spray-1.3/src/main/scala/datadog/trace/instrumentation/spray/SprayHttpServerRunSealedRouteAdvice.java b/dd-java-agent/instrumentation/spray-1.3/src/main/scala/datadog/trace/instrumentation/spray/SprayHttpServerRunSealedRouteAdvice.java index 571a683ed22..3352c9cabaa 100644 --- a/dd-java-agent/instrumentation/spray-1.3/src/main/scala/datadog/trace/instrumentation/spray/SprayHttpServerRunSealedRouteAdvice.java +++ b/dd-java-agent/instrumentation/spray-1.3/src/main/scala/datadog/trace/instrumentation/spray/SprayHttpServerRunSealedRouteAdvice.java @@ -7,6 +7,7 @@ import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import net.bytebuddy.asm.Advice; import spray.http.HttpRequest; import spray.routing.RequestContext; @@ -15,7 +16,7 @@ public class SprayHttpServerRunSealedRouteAdvice { @Advice.OnMethodEnter(suppress = Throwable.class) public static AgentScope enter(@Advice.Argument(value = 1, readOnly = false) RequestContext ctx) { final AgentSpan span; - final AgentSpan.Context.Extracted extractedContext; + final AgentSpanContext.Extracted extractedContext; if (activeSpan() == null) { // Propagate context in case income request was going through several routes // TODO: Add test for it diff --git a/dd-java-agent/instrumentation/spring-messaging-4/src/main/java/datadog/trace/instrumentation/springmessaging/SpringMessageHandlerInstrumentation.java b/dd-java-agent/instrumentation/spring-messaging-4/src/main/java/datadog/trace/instrumentation/springmessaging/SpringMessageHandlerInstrumentation.java index d392b453910..4f0c6c2a153 100644 --- a/dd-java-agent/instrumentation/spring-messaging-4/src/main/java/datadog/trace/instrumentation/springmessaging/SpringMessageHandlerInstrumentation.java +++ b/dd-java-agent/instrumentation/spring-messaging-4/src/main/java/datadog/trace/instrumentation/springmessaging/SpringMessageHandlerInstrumentation.java @@ -16,6 +16,7 @@ import datadog.trace.agent.tooling.InstrumenterModule; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import net.bytebuddy.asm.Advice; import org.springframework.messaging.Message; import org.springframework.messaging.handler.invocation.InvocableHandlerMethod; @@ -56,7 +57,7 @@ public static class HandleMessageAdvice { @Advice.OnMethodEnter(suppress = Throwable.class) public static AgentScope onEnter( @Advice.This InvocableHandlerMethod thiz, @Advice.Argument(0) Message message) { - AgentSpan.Context parentContext; + AgentSpanContext parentContext; AgentSpan parent = activeSpan(); if (null != parent) { // prefer existing context, assume it was already extracted from this message diff --git a/dd-java-agent/instrumentation/spring-webmvc-3.1/src/main/java/datadog/trace/instrumentation/springweb/SpringWebHttpServerDecorator.java b/dd-java-agent/instrumentation/spring-webmvc-3.1/src/main/java/datadog/trace/instrumentation/springweb/SpringWebHttpServerDecorator.java index 53d28b87830..da34fd37ce8 100644 --- a/dd-java-agent/instrumentation/spring-webmvc-3.1/src/main/java/datadog/trace/instrumentation/springweb/SpringWebHttpServerDecorator.java +++ b/dd-java-agent/instrumentation/spring-webmvc-3.1/src/main/java/datadog/trace/instrumentation/springweb/SpringWebHttpServerDecorator.java @@ -4,6 +4,7 @@ import datadog.trace.bootstrap.instrumentation.api.AgentPropagation; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.URIDataAdapter; import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString; import datadog.trace.bootstrap.instrumentation.decorator.HttpServerDecorator; @@ -94,7 +95,7 @@ public AgentSpan onRequest( final AgentSpan span, final HttpServletRequest connection, final HttpServletRequest request, - AgentSpan.Context.Extracted context) { + AgentSpanContext.Extracted context) { if (request != null) { final String method = request.getMethod(); final Object bestMatchingPattern = diff --git a/dd-java-agent/instrumentation/spring-webmvc-6.0/src/main/java17/datadog/trace/instrumentation/springweb6/SpringWebHttpServerDecorator.java b/dd-java-agent/instrumentation/spring-webmvc-6.0/src/main/java17/datadog/trace/instrumentation/springweb6/SpringWebHttpServerDecorator.java index 6b3a7aba2b5..91c25b90f1a 100644 --- a/dd-java-agent/instrumentation/spring-webmvc-6.0/src/main/java17/datadog/trace/instrumentation/springweb6/SpringWebHttpServerDecorator.java +++ b/dd-java-agent/instrumentation/spring-webmvc-6.0/src/main/java17/datadog/trace/instrumentation/springweb6/SpringWebHttpServerDecorator.java @@ -4,6 +4,7 @@ import datadog.trace.bootstrap.instrumentation.api.AgentPropagation; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.URIDataAdapter; import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString; import datadog.trace.bootstrap.instrumentation.decorator.HttpServerDecorator; @@ -97,7 +98,7 @@ public AgentSpan onRequest( final AgentSpan span, final HttpServletRequest connection, final HttpServletRequest request, - AgentSpan.Context.Extracted context) { + AgentSpanContext.Extracted context) { // FIXME: adding a filter to avoid resource name to be overridden on redirect and forwards. // Remove myself when jakarta.servlet will be available if (request != null && request.getAttribute(DD_FILTERED_SPRING_ROUTE_ALREADY_APPLIED) == null) { diff --git a/dd-java-agent/instrumentation/synapse-3/src/main/java/datadog/trace/instrumentation/synapse3/SynapseServerInstrumentation.java b/dd-java-agent/instrumentation/synapse-3/src/main/java/datadog/trace/instrumentation/synapse3/SynapseServerInstrumentation.java index 6c8418a3113..d95d4668d1e 100644 --- a/dd-java-agent/instrumentation/synapse-3/src/main/java/datadog/trace/instrumentation/synapse3/SynapseServerInstrumentation.java +++ b/dd-java-agent/instrumentation/synapse-3/src/main/java/datadog/trace/instrumentation/synapse3/SynapseServerInstrumentation.java @@ -14,6 +14,7 @@ import datadog.trace.agent.tooling.InstrumenterModule; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import net.bytebuddy.asm.Advice; import org.apache.http.HttpRequest; import org.apache.http.nio.NHttpServerConnection; @@ -67,7 +68,7 @@ public static AgentScope beginRequest( // check incoming request for distributed trace ids HttpRequest request = connection.getHttpRequest(); - AgentSpan.Context.Extracted extractedContext = DECORATE.extract(request); + AgentSpanContext.Extracted extractedContext = DECORATE.extract(request); AgentSpan span; if (null != extractedContext) { diff --git a/dd-java-agent/instrumentation/tinylog-2/src/main/java/datadog/trace/instrumentation/tinylog2/LogEntryInstrumentation.java b/dd-java-agent/instrumentation/tinylog-2/src/main/java/datadog/trace/instrumentation/tinylog2/LogEntryInstrumentation.java index 4e78a6283f1..780857c2ddc 100644 --- a/dd-java-agent/instrumentation/tinylog-2/src/main/java/datadog/trace/instrumentation/tinylog2/LogEntryInstrumentation.java +++ b/dd-java-agent/instrumentation/tinylog-2/src/main/java/datadog/trace/instrumentation/tinylog2/LogEntryInstrumentation.java @@ -15,7 +15,7 @@ import datadog.trace.api.DDTraceId; import datadog.trace.api.InstrumenterConfig; import datadog.trace.bootstrap.InstrumentationContext; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.bootstrap.instrumentation.api.Tags; import java.util.HashMap; @@ -38,7 +38,7 @@ public String instrumentedType() { @Override public Map contextStore() { - return singletonMap("org.tinylog.core.LogEntry", AgentSpan.Context.class.getName()); + return singletonMap("org.tinylog.core.LogEntry", AgentSpanContext.class.getName()); } @Override @@ -68,8 +68,8 @@ public static void onExit( return; } - AgentSpan.Context context = - InstrumentationContext.get(LogEntry.class, AgentSpan.Context.class).get(event); + AgentSpanContext context = + InstrumentationContext.get(LogEntry.class, AgentSpanContext.class).get(event); // TinyLoggingProviderInstrumentation only populates the context if injection is enabled // Impossible for context to be not null while injection is disabled diff --git a/dd-java-agent/instrumentation/tinylog-2/src/main/java/datadog/trace/instrumentation/tinylog2/TinylogLoggingProviderInstrumentation.java b/dd-java-agent/instrumentation/tinylog-2/src/main/java/datadog/trace/instrumentation/tinylog2/TinylogLoggingProviderInstrumentation.java index 76ae2de6d93..15b66a664d9 100644 --- a/dd-java-agent/instrumentation/tinylog-2/src/main/java/datadog/trace/instrumentation/tinylog2/TinylogLoggingProviderInstrumentation.java +++ b/dd-java-agent/instrumentation/tinylog-2/src/main/java/datadog/trace/instrumentation/tinylog2/TinylogLoggingProviderInstrumentation.java @@ -14,6 +14,7 @@ import datadog.trace.agent.tooling.InstrumenterModule; import datadog.trace.bootstrap.InstrumentationContext; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import java.util.Map; import net.bytebuddy.asm.Advice; import org.tinylog.core.LogEntry; @@ -32,7 +33,7 @@ public String instrumentedType() { @Override public Map contextStore() { - return singletonMap("org.tinylog.core.LogEntry", AgentSpan.Context.class.getName()); + return singletonMap("org.tinylog.core.LogEntry", AgentSpanContext.class.getName()); } @Override @@ -52,7 +53,7 @@ public static void onEnter(@Advice.Argument(0) LogEntry event) { AgentSpan span = activeSpan(); if (span != null && traceConfig(span).isLogsInjectionEnabled()) { - InstrumentationContext.get(LogEntry.class, AgentSpan.Context.class) + InstrumentationContext.get(LogEntry.class, AgentSpanContext.class) .put(event, span.context()); } } diff --git a/dd-java-agent/instrumentation/tomcat-5.5-common/src/main/java/datadog/trace/instrumentation/tomcat/TomcatDecorator.java b/dd-java-agent/instrumentation/tomcat-5.5-common/src/main/java/datadog/trace/instrumentation/tomcat/TomcatDecorator.java index 42aaab686b6..c1e70323507 100644 --- a/dd-java-agent/instrumentation/tomcat-5.5-common/src/main/java/datadog/trace/instrumentation/tomcat/TomcatDecorator.java +++ b/dd-java-agent/instrumentation/tomcat-5.5-common/src/main/java/datadog/trace/instrumentation/tomcat/TomcatDecorator.java @@ -7,6 +7,7 @@ import datadog.trace.api.internal.TraceSegment; import datadog.trace.bootstrap.instrumentation.api.AgentPropagation; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.URIDataAdapter; import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString; import datadog.trace.bootstrap.instrumentation.decorator.HttpServerDecorator; @@ -93,7 +94,7 @@ public AgentSpan onRequest( final AgentSpan span, final Request connection, final Request request, - AgentSpan.Context.Extracted context) { + AgentSpanContext.Extracted context) { if (request != null) { String contextPath = request.getContextPath(); String servletPath = request.getServletPath(); diff --git a/dd-java-agent/instrumentation/tomcat-5.5/src/main/java/datadog/trace/instrumentation/tomcat/TomcatServerInstrumentation.java b/dd-java-agent/instrumentation/tomcat-5.5/src/main/java/datadog/trace/instrumentation/tomcat/TomcatServerInstrumentation.java index 28acc4ec6de..c6c69245dde 100644 --- a/dd-java-agent/instrumentation/tomcat-5.5/src/main/java/datadog/trace/instrumentation/tomcat/TomcatServerInstrumentation.java +++ b/dd-java-agent/instrumentation/tomcat-5.5/src/main/java/datadog/trace/instrumentation/tomcat/TomcatServerInstrumentation.java @@ -21,6 +21,7 @@ import datadog.trace.api.gateway.Flow; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.bootstrap.instrumentation.java.concurrent.ExcludeFilter; import java.util.Arrays; @@ -121,7 +122,7 @@ public static AgentScope onService(@Advice.Argument(0) org.apache.coyote.Request return activateSpan((AgentSpan) existingSpan); } - final AgentSpan.Context.Extracted extractedContext = DECORATE.extract(req); + final AgentSpanContext.Extracted extractedContext = DECORATE.extract(req); req.setAttribute(DD_EXTRACTED_CONTEXT_ATTRIBUTE, extractedContext); final AgentSpan span = DECORATE.startSpan(req, extractedContext); @@ -165,9 +166,9 @@ public static void afterParse( req.setAttribute(CorrelationIdentifier.getTraceIdKey(), AgentTracer.get().getTraceId(span)); req.setAttribute(CorrelationIdentifier.getSpanIdKey(), AgentTracer.get().getSpanId(span)); Object ctxObj = req.getAttribute(DD_EXTRACTED_CONTEXT_ATTRIBUTE); - AgentSpan.Context.Extracted ctx = - ctxObj instanceof AgentSpan.Context.Extracted - ? (AgentSpan.Context.Extracted) ctxObj + AgentSpanContext.Extracted ctx = + ctxObj instanceof AgentSpanContext.Extracted + ? (AgentSpanContext.Extracted) ctxObj : null; DECORATE.onRequest(span, req, req, ctx); Flow.Action.RequestBlockingAction rba = span.getRequestBlockingAction(); diff --git a/dd-java-agent/instrumentation/undertow/undertow-2.0/src/main/java/datadog/trace/instrumentation/undertow/HandlerInstrumentation.java b/dd-java-agent/instrumentation/undertow/undertow-2.0/src/main/java/datadog/trace/instrumentation/undertow/HandlerInstrumentation.java index fe8b96034a4..a6087e7d912 100644 --- a/dd-java-agent/instrumentation/undertow/undertow-2.0/src/main/java/datadog/trace/instrumentation/undertow/HandlerInstrumentation.java +++ b/dd-java-agent/instrumentation/undertow/undertow-2.0/src/main/java/datadog/trace/instrumentation/undertow/HandlerInstrumentation.java @@ -18,6 +18,7 @@ import datadog.trace.api.gateway.Flow.Action.RequestBlockingAction; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; @@ -91,7 +92,7 @@ public static void onEnter( return; } - final AgentSpan.Context.Extracted extractedContext = DECORATE.extract(exchange); + final AgentSpanContext.Extracted extractedContext = DECORATE.extract(exchange); final AgentSpan span = DECORATE.startSpan(exchange, extractedContext).setMeasured(true); scope = activateSpan(span, true); DECORATE.afterStart(span); diff --git a/dd-java-agent/instrumentation/undertow/undertow-2.0/src/main/java/datadog/trace/instrumentation/undertow/HttpRequestParserInstrumentation.java b/dd-java-agent/instrumentation/undertow/undertow-2.0/src/main/java/datadog/trace/instrumentation/undertow/HttpRequestParserInstrumentation.java index b13730331ff..7e9e0d50423 100644 --- a/dd-java-agent/instrumentation/undertow/undertow-2.0/src/main/java/datadog/trace/instrumentation/undertow/HttpRequestParserInstrumentation.java +++ b/dd-java-agent/instrumentation/undertow/undertow-2.0/src/main/java/datadog/trace/instrumentation/undertow/HttpRequestParserInstrumentation.java @@ -13,6 +13,7 @@ import datadog.trace.agent.tooling.InstrumenterModule; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import io.undertow.server.HttpServerExchange; import net.bytebuddy.asm.Advice; import net.bytebuddy.description.type.TypeDescription; @@ -76,7 +77,7 @@ public static void afterRequestParse( if (scope != null) { span = scope.span(); } else { - final AgentSpan.Context.Extracted extractedContext = DECORATE.extract(exchange); + final AgentSpanContext.Extracted extractedContext = DECORATE.extract(exchange); span = DECORATE.startSpan(exchange, extractedContext).setMeasured(true); scope = activateSpan(span); DECORATE.afterStart(span); diff --git a/dd-java-agent/instrumentation/vertx-web-3.4/src/main/java/datadog/trace/instrumentation/vertx_3_4/server/VertxDecorator.java b/dd-java-agent/instrumentation/vertx-web-3.4/src/main/java/datadog/trace/instrumentation/vertx_3_4/server/VertxDecorator.java index 4459285ffb2..65659862ba0 100644 --- a/dd-java-agent/instrumentation/vertx-web-3.4/src/main/java/datadog/trace/instrumentation/vertx_3_4/server/VertxDecorator.java +++ b/dd-java-agent/instrumentation/vertx-web-3.4/src/main/java/datadog/trace/instrumentation/vertx_3_4/server/VertxDecorator.java @@ -2,6 +2,7 @@ import datadog.trace.bootstrap.instrumentation.api.AgentPropagation; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.URIDataAdapter; import datadog.trace.bootstrap.instrumentation.api.URIDataAdapterBase; import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString; @@ -57,7 +58,7 @@ public AgentSpan onRequest( final AgentSpan span, final RoutingContext connection, final RoutingContext routingContext, - AgentSpan.Context.Extracted context) { + AgentSpanContext.Extracted context) { return span; } diff --git a/dd-java-agent/instrumentation/vertx-web-4.0/src/main/java/datadog/trace/instrumentation/vertx_4_0/server/VertxDecorator.java b/dd-java-agent/instrumentation/vertx-web-4.0/src/main/java/datadog/trace/instrumentation/vertx_4_0/server/VertxDecorator.java index 3458d589d53..ec3877450c8 100644 --- a/dd-java-agent/instrumentation/vertx-web-4.0/src/main/java/datadog/trace/instrumentation/vertx_4_0/server/VertxDecorator.java +++ b/dd-java-agent/instrumentation/vertx-web-4.0/src/main/java/datadog/trace/instrumentation/vertx_4_0/server/VertxDecorator.java @@ -2,6 +2,7 @@ import datadog.trace.bootstrap.instrumentation.api.AgentPropagation; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.URIDataAdapter; import datadog.trace.bootstrap.instrumentation.api.URIDataAdapterBase; import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString; @@ -57,7 +58,7 @@ public AgentSpan onRequest( final AgentSpan span, final RoutingContext connection, final RoutingContext routingContext, - AgentSpan.Context.Extracted context) { + AgentSpanContext.Extracted context) { return span; } diff --git a/dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/server/http/TestHttpServer.groovy b/dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/server/http/TestHttpServer.groovy index 8ebd8c600e2..e74ded29fe4 100644 --- a/dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/server/http/TestHttpServer.groovy +++ b/dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/server/http/TestHttpServer.groovy @@ -2,7 +2,7 @@ package datadog.trace.agent.test.server.http import datadog.trace.agent.test.asserts.ListWriterAssert import datadog.trace.agent.test.base.HttpServer -import datadog.trace.bootstrap.instrumentation.api.AgentSpan +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext import datadog.trace.bootstrap.instrumentation.api.Tags import datadog.trace.core.DDSpan import edu.umd.cs.findbugs.annotations.SuppressFBWarnings @@ -379,7 +379,7 @@ class TestHttpServer implements AutoCloseable { isDDServer = Boolean.parseBoolean(request.getHeader("is-dd-server")) } if (isDDServer) { - final AgentSpan.Context extractedContext = propagate().extract(req.orig, GETTER) + final AgentSpanContext extractedContext = propagate().extract(req.orig, GETTER) if (extractedContext != null) { startSpan("test-http-server", extractedContext) .setTag("path", request.path) diff --git a/dd-trace-core/src/main/java/datadog/trace/core/CoreTracer.java b/dd-trace-core/src/main/java/datadog/trace/core/CoreTracer.java index 2c36ae972bb..437c397883b 100644 --- a/dd-trace-core/src/main/java/datadog/trace/core/CoreTracer.java +++ b/dd-trace-core/src/main/java/datadog/trace/core/CoreTracer.java @@ -52,6 +52,7 @@ import datadog.trace.bootstrap.instrumentation.api.AgentPropagation; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentSpanLink; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.bootstrap.instrumentation.api.PathwayContext; @@ -873,7 +874,7 @@ public AgentSpan startSpan( @Override public AgentSpan startSpan( - String instrumentationName, final CharSequence spanName, final AgentSpan.Context parent) { + String instrumentationName, final CharSequence spanName, final AgentSpanContext parent) { return buildSpan(instrumentationName, spanName).ignoreActiveSpan().asChildOf(parent).start(); } @@ -881,7 +882,7 @@ public AgentSpan startSpan( public AgentSpan startSpan( final String instrumentationName, final CharSequence spanName, - final AgentSpan.Context parent, + final AgentSpanContext parent, final long startTimeMicros) { return buildSpan(instrumentationName, spanName) .ignoreActiveSpan() @@ -955,7 +956,7 @@ public AgentSpan blackholeSpan() { } @Override - public AgentSpan.Context notifyExtensionStart(Object event) { + public AgentSpanContext notifyExtensionStart(Object event) { return LambdaHandler.notifyStartInvocation(this, event); } @@ -1179,7 +1180,7 @@ public TraceSegment getTraceSegment() { if (activeSpan == null) { return null; } - AgentSpan.Context ctx = activeSpan.context(); + AgentSpanContext ctx = activeSpan.context(); if (ctx instanceof DDSpanContext) { return ((DDSpanContext) ctx).getTraceSegment(); } @@ -1264,7 +1265,7 @@ public class CoreSpanBuilder implements AgentTracer.SpanBuilder { // Builder attributes private Map tags; private long timestampMicro; - private AgentSpan.Context parent; + private AgentSpanContext parent; private String serviceName; private String resourceName; private boolean errorFlag; @@ -1316,7 +1317,7 @@ private void addTerminatedContextAsLinks() { @Override public AgentSpan start() { - AgentSpan.Context pc = parent; + AgentSpanContext pc = parent; if (pc == null && !ignoreScope) { final AgentSpan span = activeSpan(); if (span != null) { @@ -1376,7 +1377,7 @@ public CoreSpanBuilder withSpanType(final CharSequence spanType) { } @Override - public CoreSpanBuilder asChildOf(final AgentSpan.Context spanContext) { + public CoreSpanBuilder asChildOf(final AgentSpanContext spanContext) { // TODO we will start propagating stack trace hash and it will need to // be extracted here if available parent = spanContext; @@ -1467,9 +1468,8 @@ private DDSpanContext buildSpanContext() { } else { spanId = this.spanId; } - // FIXME [API] parentContext should be an interface implemented by ExtractedContext, - // TagContext, DDSpanContext, AgentSpan.Context - AgentSpan.Context parentContext = parent; + + AgentSpanContext parentContext = parent; if (parentContext == null && !ignoreScope) { // use the Scope as parent unless overridden or ignored. final AgentSpan activeSpan = scopeManager.activeSpan(); diff --git a/dd-trace-core/src/main/java/datadog/trace/core/DDSpan.java b/dd-trace-core/src/main/java/datadog/trace/core/DDSpan.java index e56f9a5206c..dcf49e974c9 100644 --- a/dd-trace-core/src/main/java/datadog/trace/core/DDSpan.java +++ b/dd-trace-core/src/main/java/datadog/trace/core/DDSpan.java @@ -330,12 +330,7 @@ public boolean isLocalRootSpan() { @Override public boolean isSameTrace(final AgentSpan otherSpan) { - // FIXME [API] AgentSpan or AgentSpan.Context should have a "getTraceId()" type method - if (otherSpan instanceof DDSpan) { - return getTraceId().equals(otherSpan.getTraceId()); - } - - return false; + return null != otherSpan && getTraceId().equals(otherSpan.getTraceId()); } @Override diff --git a/dd-trace-core/src/main/java/datadog/trace/core/DDSpanContext.java b/dd-trace-core/src/main/java/datadog/trace/core/DDSpanContext.java index 3634dab847e..d8092874bb9 100644 --- a/dd-trace-core/src/main/java/datadog/trace/core/DDSpanContext.java +++ b/dd-trace-core/src/main/java/datadog/trace/core/DDSpanContext.java @@ -16,7 +16,7 @@ import datadog.trace.api.internal.TraceSegment; import datadog.trace.api.sampling.PrioritySampling; import datadog.trace.api.sampling.SamplingMechanism; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentSpanLink; import datadog.trace.bootstrap.instrumentation.api.PathwayContext; import datadog.trace.bootstrap.instrumentation.api.ProfilerContext; @@ -51,7 +51,7 @@ * the associated Span instance */ public class DDSpanContext - implements AgentSpan.Context, RequestContext, TraceSegment, ProfilerContext { + implements AgentSpanContext, RequestContext, TraceSegment, ProfilerContext { private static final Logger log = LoggerFactory.getLogger(DDSpanContext.class); public static final String PRIORITY_SAMPLING_KEY = "_sampling_priority_v1"; diff --git a/dd-trace-core/src/main/java/datadog/trace/core/datastreams/DataStreamsMonitoring.java b/dd-trace-core/src/main/java/datadog/trace/core/datastreams/DataStreamsMonitoring.java index d6df69cc8ed..c7039bac92e 100644 --- a/dd-trace-core/src/main/java/datadog/trace/core/datastreams/DataStreamsMonitoring.java +++ b/dd-trace-core/src/main/java/datadog/trace/core/datastreams/DataStreamsMonitoring.java @@ -3,7 +3,7 @@ import datadog.trace.api.experimental.DataStreamsContextCarrier; import datadog.trace.bootstrap.instrumentation.api.AgentDataStreamsMonitoring; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan.Context; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.PathwayContext; import datadog.trace.core.propagation.HttpCodec; @@ -26,7 +26,7 @@ public interface DataStreamsMonitoring extends AgentDataStreamsMonitoring, AutoC DataStreamContextInjector injector(); /** - * Injects DSM {@link PathwayContext} into a span {@link Context}. + * Injects DSM {@link PathwayContext} into a span {@link AgentSpanContext}. * * @param span The span to update. * @param carrier The carrier of the {@link PathwayContext} to extract and inject. diff --git a/dd-trace-core/src/main/java/datadog/trace/core/propagation/CorePropagation.java b/dd-trace-core/src/main/java/datadog/trace/core/propagation/CorePropagation.java index dc7cca518d9..75c3abb949c 100644 --- a/dd-trace-core/src/main/java/datadog/trace/core/propagation/CorePropagation.java +++ b/dd-trace-core/src/main/java/datadog/trace/core/propagation/CorePropagation.java @@ -4,6 +4,7 @@ import datadog.trace.api.TracePropagationStyle; import datadog.trace.bootstrap.instrumentation.api.AgentPropagation; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.core.DDSpanContext; import datadog.trace.core.datastreams.DataStreamContextInjector; import java.util.LinkedHashMap; @@ -41,7 +42,7 @@ public void inject(final AgentSpan span, final C carrier, final Setter se } @Override - public void inject(AgentSpan.Context context, C carrier, Setter setter) { + public void inject(AgentSpanContext context, C carrier, Setter setter) { inject(context, carrier, setter, null); } @@ -51,7 +52,7 @@ public void inject(AgentSpan span, C carrier, Setter setter, TracePropaga } private void inject( - AgentSpan.Context context, C carrier, Setter setter, TracePropagationStyle style) { + AgentSpanContext context, C carrier, Setter setter, TracePropagationStyle style) { if (!(context instanceof DDSpanContext)) { return; } @@ -101,7 +102,7 @@ public void injectPathwayContextWithoutSendingStats( } @Override - public AgentSpan.Context.Extracted extract(final C carrier, final ContextVisitor getter) { + public AgentSpanContext.Extracted extract(final C carrier, final ContextVisitor getter) { return extractor.extract(carrier, getter); } } diff --git a/dd-trace-core/src/main/java/datadog/trace/lambda/LambdaHandler.java b/dd-trace-core/src/main/java/datadog/trace/lambda/LambdaHandler.java index 7d50726090b..2f6b9be444b 100644 --- a/dd-trace-core/src/main/java/datadog/trace/lambda/LambdaHandler.java +++ b/dd-trace-core/src/main/java/datadog/trace/lambda/LambdaHandler.java @@ -7,6 +7,7 @@ import datadog.trace.api.DDSpanId; import datadog.trace.api.DDTags; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.core.CoreTracer; import java.io.ByteArrayInputStream; import java.nio.charset.StandardCharsets; @@ -68,7 +69,7 @@ public class LambdaHandler { private static String EXTENSION_BASE_URL = "http://127.0.0.1:8124"; - public static AgentSpan.Context notifyStartInvocation(CoreTracer tracer, Object event) { + public static AgentSpanContext notifyStartInvocation(CoreTracer tracer, Object event) { RequestBody body = RequestBody.create(jsonMediaType, writeValueAsString(event)); try (Response response = HTTP_CLIENT diff --git a/dd-trace-core/src/test/groovy/datadog/trace/core/DDSpanContextPropagationTagsTest.groovy b/dd-trace-core/src/test/groovy/datadog/trace/core/DDSpanContextPropagationTagsTest.groovy index 50ef4ff544f..0ee9f05c5aa 100644 --- a/dd-trace-core/src/test/groovy/datadog/trace/core/DDSpanContextPropagationTagsTest.groovy +++ b/dd-trace-core/src/test/groovy/datadog/trace/core/DDSpanContextPropagationTagsTest.groovy @@ -1,7 +1,7 @@ package datadog.trace.core import datadog.trace.api.DDTraceId -import datadog.trace.bootstrap.instrumentation.api.AgentSpan +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext import datadog.trace.common.writer.ListWriter import datadog.trace.core.propagation.ExtractedContext import datadog.trace.core.propagation.PropagationTags @@ -27,7 +27,7 @@ class DDSpanContextPropagationTagsTest extends DDCoreSpecification { def extracted = new ExtractedContext(DDTraceId.from(123), 456, priority, "789", propagationTags, DATADOG) .withRequestContextDataAppSec("dummy") def span = (DDSpan) tracer.buildSpan("top") - .asChildOf((AgentSpan.Context) extracted) + .asChildOf((AgentSpanContext) extracted) .start() def dd = span.context().getPropagationTags() @@ -56,7 +56,7 @@ class DDSpanContextPropagationTagsTest extends DDCoreSpecification { def extracted = new ExtractedContext(DDTraceId.from(123), 456, priority, "789", propagationTags, DATADOG) .withRequestContextDataAppSec("dummy") def rootSpan = (DDSpan) tracer.buildSpan("top") - .asChildOf((AgentSpan.Context) extracted) + .asChildOf((AgentSpanContext) extracted) .start() def ddRoot = rootSpan.context().getPropagationTags() def span = (DDSpan) tracer.buildSpan("current").asChildOf(rootSpan).start() @@ -86,7 +86,7 @@ class DDSpanContextPropagationTagsTest extends DDCoreSpecification { def extracted = new ExtractedContext(DDTraceId.from(123), 456, priority, "789", propagationTags, DATADOG) .withRequestContextDataAppSec("dummy") def span = (DDSpan) tracer.buildSpan("top") - .asChildOf((AgentSpan.Context) extracted) + .asChildOf((AgentSpanContext) extracted) .start() def dd = span.context().getPropagationTags() @@ -113,7 +113,7 @@ class DDSpanContextPropagationTagsTest extends DDCoreSpecification { def extracted = new ExtractedContext(DDTraceId.from(123), 456, priority, "789", propagationTags, DATADOG) .withRequestContextDataAppSec("dummy") def rootSpan = (DDSpan) tracer.buildSpan("top") - .asChildOf((AgentSpan.Context) extracted) + .asChildOf((AgentSpanContext) extracted) .start() def ddRoot = rootSpan.context().getPropagationTags() def span = (DDSpan) tracer.buildSpan("current").asChildOf(rootSpan).start() diff --git a/dd-trace-core/src/test/groovy/datadog/trace/core/DDSpanContextTest.groovy b/dd-trace-core/src/test/groovy/datadog/trace/core/DDSpanContextTest.groovy index 25cbf7ca537..c880c17d94c 100644 --- a/dd-trace-core/src/test/groovy/datadog/trace/core/DDSpanContextTest.groovy +++ b/dd-trace-core/src/test/groovy/datadog/trace/core/DDSpanContextTest.groovy @@ -2,7 +2,7 @@ package datadog.trace.core import datadog.trace.api.DDTags import datadog.trace.api.DDTraceId -import datadog.trace.bootstrap.instrumentation.api.AgentSpan +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext import datadog.trace.bootstrap.instrumentation.api.ErrorPriorities import datadog.trace.bootstrap.instrumentation.api.ProfilingContextIntegration import datadog.trace.common.writer.ListWriter @@ -185,7 +185,7 @@ class DDSpanContextTest extends DDCoreSpecification { def extracted = new ExtractedContext(DDTraceId.from(123), 456, SAMPLER_KEEP, "789", tracer.getPropagationTagsFactory().empty(), DATADOG) .withRequestContextDataAppSec("dummy") - def top = tracer.buildSpan("top").asChildOf((AgentSpan.Context) extracted).start() + def top = tracer.buildSpan("top").asChildOf((AgentSpanContext) extracted).start() def topC = (DDSpanContext) top.context() def topTS = top.getRequestContext().getTraceSegment() def current = tracer.buildSpan("current").asChildOf(top).start() diff --git a/dd-trace-core/src/test/groovy/datadog/trace/core/DDSpanTest.groovy b/dd-trace-core/src/test/groovy/datadog/trace/core/DDSpanTest.groovy index a8aa2c1f30c..8385a42d543 100644 --- a/dd-trace-core/src/test/groovy/datadog/trace/core/DDSpanTest.groovy +++ b/dd-trace-core/src/test/groovy/datadog/trace/core/DDSpanTest.groovy @@ -5,7 +5,7 @@ import datadog.trace.api.DDTags import datadog.trace.api.DDTraceId import datadog.trace.api.gateway.RequestContextSlot import datadog.trace.api.sampling.PrioritySampling -import datadog.trace.bootstrap.instrumentation.api.AgentSpan +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext import datadog.trace.bootstrap.instrumentation.api.AgentTracer.NoopPathwayContext import datadog.trace.bootstrap.instrumentation.api.ErrorPriorities import datadog.trace.bootstrap.instrumentation.api.TagContext @@ -280,7 +280,7 @@ class DDSpanTest extends DDCoreSpecification { def "isRootSpan() in and not in the context of distributed tracing"() { setup: - def root = tracer.buildSpan("root").asChildOf((AgentSpan.Context) extractedContext).start() + def root = tracer.buildSpan("root").asChildOf((AgentSpanContext) extractedContext).start() def child = tracer.buildSpan("child").asChildOf(root).start() expect: @@ -299,7 +299,7 @@ class DDSpanTest extends DDCoreSpecification { def "getApplicationRootSpan() in and not in the context of distributed tracing"() { setup: - def root = tracer.buildSpan("root").asChildOf((AgentSpan.Context) extractedContext).start() + def root = tracer.buildSpan("root").asChildOf((AgentSpanContext) extractedContext).start() def child = tracer.buildSpan("child").asChildOf(root).start() expect: diff --git a/dd-trace-ot/src/main/java/datadog/opentracing/DDTracer.java b/dd-trace-ot/src/main/java/datadog/opentracing/DDTracer.java index 71183333b8d..4e52736dfdc 100644 --- a/dd-trace-ot/src/main/java/datadog/opentracing/DDTracer.java +++ b/dd-trace-ot/src/main/java/datadog/opentracing/DDTracer.java @@ -11,6 +11,7 @@ import datadog.trace.api.profiling.Profiling; import datadog.trace.bootstrap.instrumentation.api.AgentPropagation; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.common.sampling.Sampler; import datadog.trace.common.writer.Writer; @@ -463,7 +464,7 @@ public DDSpanBuilder buildSpan(final String operationName) { @Override public void inject(final SpanContext spanContext, final Format format, final C carrier) { if (carrier instanceof TextMap) { - final AgentSpan.Context context = converter.toContext(spanContext); + final AgentSpanContext context = converter.toContext(spanContext); tracer.propagate().inject(context, (TextMap) carrier, TextMapSetter.INSTANCE); } else { @@ -474,7 +475,7 @@ public void inject(final SpanContext spanContext, final Format format, fi @Override public SpanContext extract(final Format format, final C carrier) { if (carrier instanceof TextMap) { - final AgentSpan.Context tagContext = + final AgentSpanContext tagContext = tracer.propagate().extract((TextMap) carrier, new TextMapGetter((TextMap) carrier)); return converter.toSpanContext(tagContext); @@ -507,7 +508,7 @@ public Profiling getProfilingContext() { @Override public TraceSegment getTraceSegment() { - AgentSpan.Context ctx = tracer.activeSpan().context(); + AgentSpanContext ctx = tracer.activeSpan().context(); if (ctx instanceof DDSpanContext) { return ((DDSpanContext) ctx).getTraceSegment(); } @@ -573,7 +574,7 @@ public DDSpanBuilder addReference( return this; } - final AgentSpan.Context context = converter.toContext(referencedContext); + final AgentSpanContext context = converter.toContext(referencedContext); if (!(context instanceof ExtractedContext) && !(context instanceof DDSpanContext)) { log.debug( "Expected to have a DDSpanContext or ExtractedContext but got " diff --git a/dd-trace-ot/src/main/java/datadog/opentracing/OTSpanContext.java b/dd-trace-ot/src/main/java/datadog/opentracing/OTSpanContext.java index 70b7291079d..9f84c075cb2 100644 --- a/dd-trace-ot/src/main/java/datadog/opentracing/OTSpanContext.java +++ b/dd-trace-ot/src/main/java/datadog/opentracing/OTSpanContext.java @@ -1,14 +1,14 @@ package datadog.opentracing; import datadog.trace.api.DDSpanId; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import io.opentracing.SpanContext; import java.util.Map; class OTSpanContext implements SpanContext { - private final AgentSpan.Context delegate; + private final AgentSpanContext delegate; - OTSpanContext(final AgentSpan.Context delegate) { + OTSpanContext(final AgentSpanContext delegate) { this.delegate = delegate; } @@ -27,7 +27,7 @@ public Iterable> baggageItems() { return delegate.baggageItems(); } - AgentSpan.Context getDelegate() { + AgentSpanContext getDelegate() { return delegate; } diff --git a/dd-trace-ot/src/main/java/datadog/opentracing/TypeConverter.java b/dd-trace-ot/src/main/java/datadog/opentracing/TypeConverter.java index 968d748b53e..7d50eb632f8 100644 --- a/dd-trace-ot/src/main/java/datadog/opentracing/TypeConverter.java +++ b/dd-trace-ot/src/main/java/datadog/opentracing/TypeConverter.java @@ -2,6 +2,7 @@ import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentSpanContext; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.bootstrap.instrumentation.api.AttachableWrapper; import io.opentracing.Scope; @@ -76,7 +77,7 @@ public Scope toScope(final AgentScope scope, final boolean finishSpanOnClose) { return new OTScopeManager.OTScope(scope, finishSpanOnClose, this); } - public SpanContext toSpanContext(final AgentSpan.Context context) { + public SpanContext toSpanContext(final AgentSpanContext context) { if (context == null) { return null; } @@ -87,7 +88,7 @@ public SpanContext toSpanContext(final AgentSpan.Context context) { return new OTSpanContext(context); } - public AgentSpan.Context toContext(final SpanContext spanContext) { + public AgentSpanContext toContext(final SpanContext spanContext) { if (spanContext == null) { return null; } else if (spanContext instanceof OTSpanContext) { diff --git a/internal-api/build.gradle b/internal-api/build.gradle index fb4d388fc97..dea10d40519 100644 --- a/internal-api/build.gradle +++ b/internal-api/build.gradle @@ -57,7 +57,7 @@ excludedClassesCoverage += [ "datadog.trace.bootstrap.instrumentation.api.CommonTagValues", // Caused by empty 'default' interface method "datadog.trace.bootstrap.instrumentation.api.AgentSpan", - "datadog.trace.bootstrap.instrumentation.api.AgentSpan.Context", + "datadog.trace.bootstrap.instrumentation.api.AgentSpanContext", "datadog.trace.bootstrap.instrumentation.api.AgentTracer.NoopAgentPropagation", "datadog.trace.bootstrap.instrumentation.api.AgentTracer", "datadog.trace.bootstrap.instrumentation.api.AgentTracer.NoopContext", diff --git a/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentPropagation.java b/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentPropagation.java index 5edcf448690..1a69ea9aabe 100644 --- a/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentPropagation.java +++ b/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentPropagation.java @@ -6,7 +6,7 @@ public interface AgentPropagation { void inject(AgentSpan span, C carrier, Setter setter); - void inject(AgentSpan.Context context, C carrier, Setter setter); + void inject(AgentSpanContext context, C carrier, Setter setter); void inject(AgentSpan span, C carrier, Setter setter, TracePropagationStyle style); @@ -33,7 +33,7 @@ interface BinarySetter extends Setter { void set(C carrier, String key, byte[] value); } - AgentSpan.Context.Extracted extract(C carrier, ContextVisitor getter); + AgentSpanContext.Extracted extract(C carrier, ContextVisitor getter); interface KeyClassifier { diff --git a/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentSpan.java b/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentSpan.java index c2d5b783a8e..31eda67568f 100644 --- a/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentSpan.java +++ b/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentSpan.java @@ -5,8 +5,6 @@ import datadog.trace.api.gateway.IGSpanInfo; import datadog.trace.api.gateway.RequestContext; import datadog.trace.api.interceptor.MutableSpan; -import datadog.trace.api.sampling.PrioritySampling; -import java.util.List; import java.util.Map; public interface AgentSpan extends MutableSpan, IGSpanInfo, WithAgentSpan { @@ -66,7 +64,7 @@ public interface AgentSpan extends MutableSpan, IGSpanInfo, WithAgentSpan { boolean isSameTrace(AgentSpan otherSpan); - Context context(); + AgentSpanContext context(); String getBaggageItem(String key); @@ -149,85 +147,6 @@ default AgentSpan asAgentSpan() { return this; } - interface Context { - /** - * Gets the TraceId of the span's trace. - * - * @return The TraceId of the span's trace, or {@link DDTraceId#ZERO} if not set. - */ - DDTraceId getTraceId(); - - /** - * Gets the SpanId. - * - * @return The span identifier, or {@link datadog.trace.api.DDSpanId#ZERO} if not set. - */ - long getSpanId(); - - /** - * Get the span's trace collector. - * - * @return The span's trace, or a noop {@link AgentTracer.NoopAgentTraceCollector#INSTANCE} if - * the trace is not valid. - */ - AgentTraceCollector getTraceCollector(); - - /** - * Gets the trace sampling priority of the span's trace. - * - *

Check {@link PrioritySampling} for possible values. - * - * @return The trace sampling priority of the span's trace, or {@link PrioritySampling#UNSET} if - * no priority has been set. - */ - int getSamplingPriority(); - - Iterable> baggageItems(); - - PathwayContext getPathwayContext(); - - default void mergePathwayContext(PathwayContext pathwayContext) {} - - interface Extracted extends Context { - /** - * Gets the span links related to the other terminated context. - * - * @return The span links to other extracted contexts found but terminated. - */ - List getTerminatedContextLinks(); - - String getForwarded(); - - String getFastlyClientIp(); - - String getCfConnectingIp(); - - String getCfConnectingIpv6(); - - String getXForwardedProto(); - - String getXForwardedHost(); - - String getXForwardedPort(); - - String getForwardedFor(); - - String getXForwardedFor(); - - String getXClusterClientIp(); - - String getXRealIp(); - - String getXClientIp(); - - String getUserAgent(); - - String getTrueClientIp(); - - String getCustomIpHeader(); - } - } - interface Attributes { /** * Gets the attributes as an immutable map. diff --git a/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentSpanContext.java b/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentSpanContext.java new file mode 100644 index 00000000000..1f10c1ed24b --- /dev/null +++ b/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentSpanContext.java @@ -0,0 +1,92 @@ +package datadog.trace.bootstrap.instrumentation.api; + +import datadog.trace.api.DDTraceId; +import datadog.trace.api.sampling.PrioritySampling; +import java.util.List; +import java.util.Map; + +/** + * Represents Span state that must propagate to descendant Spans and across process boundaries. + * + *

Span context is logically divided into two pieces: (1) the user-level "Baggage" that + * propagates across Span boundaries and (2) internal fields that are needed to identify or + * contextualize the associated Span instance. + */ +public interface AgentSpanContext { + /** + * Gets the TraceId of the span's trace. + * + * @return The TraceId of the span's trace, or {@link DDTraceId#ZERO} if not set. + */ + DDTraceId getTraceId(); + + /** + * Gets the SpanId. + * + * @return The span identifier, or {@link datadog.trace.api.DDSpanId#ZERO} if not set. + */ + long getSpanId(); + + /** + * Get the span's trace collector. + * + * @return The span's trace, or a noop {@link AgentTracer.NoopAgentTraceCollector#INSTANCE} if the + * trace is not valid. + */ + AgentTraceCollector getTraceCollector(); + + /** + * Gets the trace sampling priority of the span's trace. + * + *

Check {@link PrioritySampling} for possible values. + * + * @return The trace sampling priority of the span's trace, or {@link PrioritySampling#UNSET} if + * no priority has been set. + */ + int getSamplingPriority(); + + Iterable> baggageItems(); + + PathwayContext getPathwayContext(); + + default void mergePathwayContext(PathwayContext pathwayContext) {} + + interface Extracted extends AgentSpanContext { + /** + * Gets the span links related to the other terminated context. + * + * @return The span links to other extracted contexts found but terminated. + */ + List getTerminatedContextLinks(); + + String getForwarded(); + + String getFastlyClientIp(); + + String getCfConnectingIp(); + + String getCfConnectingIpv6(); + + String getXForwardedProto(); + + String getXForwardedHost(); + + String getXForwardedPort(); + + String getForwardedFor(); + + String getXForwardedFor(); + + String getXClusterClientIp(); + + String getXRealIp(); + + String getXClientIp(); + + String getUserAgent(); + + String getTrueClientIp(); + + String getCustomIpHeader(); + } +} diff --git a/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentTracer.java b/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentTracer.java index 630d91ad7cf..cd2aab1ec10 100644 --- a/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentTracer.java +++ b/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentTracer.java @@ -22,7 +22,6 @@ import datadog.trace.api.sampling.PrioritySampling; import datadog.trace.api.sampling.SamplingRule; import datadog.trace.api.scopemanager.ScopeListener; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan.Context; import datadog.trace.context.TraceScope; import java.nio.ByteBuffer; import java.util.Collections; @@ -60,33 +59,33 @@ public static AgentSpan startSpan( } // Explicit parent - /** Deprecated. Use {@link #startSpan(String, CharSequence, AgentSpan.Context)} instead. */ + /** Deprecated. Use {@link #startSpan(String, CharSequence, AgentSpanContext)} instead. */ @Deprecated - public static AgentSpan startSpan(final CharSequence spanName, final AgentSpan.Context parent) { + public static AgentSpan startSpan(final CharSequence spanName, final AgentSpanContext parent) { return startSpan(DEFAULT_INSTRUMENTATION_NAME, spanName, parent); } - /** @see TracerAPI#startSpan(String, CharSequence, AgentSpan.Context) */ + /** @see TracerAPI#startSpan(String, CharSequence, AgentSpanContext) */ public static AgentSpan startSpan( final String instrumentationName, final CharSequence spanName, - final AgentSpan.Context parent) { + final AgentSpanContext parent) { return get().startSpan(instrumentationName, spanName, parent); } // Explicit parent - /** Deprecated. Use {@link #startSpan(String, CharSequence, AgentSpan.Context, long)} instead. */ + /** Deprecated. Use {@link #startSpan(String, CharSequence, AgentSpanContext, long)} instead. */ @Deprecated public static AgentSpan startSpan( - final CharSequence spanName, final AgentSpan.Context parent, final long startTimeMicros) { + final CharSequence spanName, final AgentSpanContext parent, final long startTimeMicros) { return startSpan(DEFAULT_INSTRUMENTATION_NAME, spanName, parent, startTimeMicros); } - /** @see TracerAPI#startSpan(String, CharSequence, AgentSpan.Context, long) */ + /** @see TracerAPI#startSpan(String, CharSequence, AgentSpanContext, long) */ public static AgentSpan startSpan( final String instrumentationName, final CharSequence spanName, - final AgentSpan.Context parent, + final AgentSpanContext parent, final long startTimeMicros) { return get().startSpan(instrumentationName, spanName, parent, startTimeMicros); } @@ -208,8 +207,7 @@ public interface TracerAPI * @param parent The parent span context. * @return The new started span. */ - AgentSpan startSpan( - String instrumentationName, CharSequence spanName, AgentSpan.Context parent); + AgentSpan startSpan(String instrumentationName, CharSequence spanName, AgentSpanContext parent); /** * Create and start a new span with an explicit parent and a given start time. @@ -223,7 +221,7 @@ AgentSpan startSpan( AgentSpan startSpan( String instrumentationName, CharSequence spanName, - AgentSpan.Context parent, + AgentSpanContext parent, long startTimeMicros); AgentScope activateSpan(AgentSpan span, ScopeSource source); @@ -269,7 +267,7 @@ default SpanBuilder buildSpan(CharSequence spanName) { CallbackProvider getUniversalCallbackProvider(); - AgentSpan.Context notifyExtensionStart(Object event); + AgentSpanContext notifyExtensionStart(Object event); void notifyExtensionEnd(AgentSpan span, Object result, boolean isError); @@ -296,7 +294,7 @@ default SpanBuilder buildSpan(CharSequence spanName) { public interface SpanBuilder { AgentSpan start(); - SpanBuilder asChildOf(Context toContext); + SpanBuilder asChildOf(AgentSpanContext toContext); SpanBuilder ignoreActiveSpan(); @@ -342,7 +340,9 @@ public AgentSpan startSpan( @Override public AgentSpan startSpan( - final String instrumentationName, final CharSequence spanName, final Context parent) { + final String instrumentationName, + final CharSequence spanName, + final AgentSpanContext parent) { return NoopAgentSpan.INSTANCE; } @@ -350,7 +350,7 @@ public AgentSpan startSpan( public AgentSpan startSpan( final String instrumentationName, final CharSequence spanName, - final Context parent, + final AgentSpanContext parent, final long startTimeMicros) { return NoopAgentSpan.INSTANCE; } @@ -494,7 +494,7 @@ public EndpointTracker onRootSpanStarted(AgentSpan root) { } @Override - public AgentSpan.Context notifyExtensionStart(Object event) { + public AgentSpanContext notifyExtensionStart(Object event) { return null; } @@ -547,7 +547,7 @@ public DDTraceId getTraceId() { } @Override - public Context context() { + public AgentSpanContext context() { return BlackholeContext.INSTANCE; } } @@ -782,13 +782,11 @@ public AgentSpan getLocalRootSpan() { @Override public boolean isSameTrace(final AgentSpan otherSpan) { - // FIXME [API] AgentSpan or AgentSpan.Context should have a "getTraceId()" type method - // Not sure if this is the best idea... return otherSpan == INSTANCE; } @Override - public Context context() { + public AgentSpanContext context() { return NoopContext.INSTANCE; } @@ -914,7 +912,8 @@ static class NoopAgentPropagation implements AgentPropagation { public void inject(final AgentSpan span, final C carrier, final Setter setter) {} @Override - public void inject(final Context context, final C carrier, final Setter setter) {} + public void inject( + final AgentSpanContext context, final C carrier, final Setter setter) {} @Override public void inject( @@ -938,7 +937,7 @@ public void injectPathwayContextWithoutSendingStats( AgentSpan span, C carrier, Setter setter, LinkedHashMap sortedTags) {} @Override - public Context.Extracted extract(final C carrier, final ContextVisitor getter) { + public AgentSpanContext.Extracted extract(final C carrier, final ContextVisitor getter) { return NoopContext.INSTANCE; } } @@ -966,7 +965,7 @@ public static final class BlackholeContext extends NoopContext { private BlackholeContext() {} } - public static class NoopContext implements Context.Extracted { + public static class NoopContext implements AgentSpanContext.Extracted { public static final NoopContext INSTANCE = new NoopContext(); private NoopContext() {} diff --git a/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/SpanLink.java b/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/SpanLink.java index 0a0ded3a61c..39e361d87ae 100644 --- a/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/SpanLink.java +++ b/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/SpanLink.java @@ -32,7 +32,7 @@ protected SpanLink( * @param context The context of the span to get the link to. * @return A span link to the given context. */ - public static SpanLink from(AgentSpan.Context context) { + public static SpanLink from(AgentSpanContext context) { return from(context, DEFAULT_FLAGS, "", EMPTY); } @@ -47,7 +47,7 @@ public static SpanLink from(AgentSpan.Context context) { * @return A span link to the given context. */ public static SpanLink from( - AgentSpan.Context context, + AgentSpanContext context, byte traceFlags, String traceState, AgentSpan.Attributes attributes) { diff --git a/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/TagContext.java b/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/TagContext.java index 324e4d99a8d..fdf9580cbb9 100644 --- a/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/TagContext.java +++ b/internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/TagContext.java @@ -18,7 +18,7 @@ * When calling extract, we allow for grabbing other configured headers as tags. Those tags are * returned here even if the rest of the request would have returned null. */ -public class TagContext implements AgentSpan.Context.Extracted { +public class TagContext implements AgentSpanContext.Extracted { private static final HttpHeaders EMPTY_HTTP_HEADERS = new HttpHeaders(); diff --git a/internal-api/src/test/groovy/datadog/trace/bootstrap/instrumentation/api/SpanLinkTest.groovy b/internal-api/src/test/groovy/datadog/trace/bootstrap/instrumentation/api/SpanLinkTest.groovy index a58e38f1094..56057d8b16a 100644 --- a/internal-api/src/test/groovy/datadog/trace/bootstrap/instrumentation/api/SpanLinkTest.groovy +++ b/internal-api/src/test/groovy/datadog/trace/bootstrap/instrumentation/api/SpanLinkTest.groovy @@ -13,7 +13,7 @@ class SpanLinkTest extends DDSpecification { setup: def traceId = DDTraceId.fromHex("11223344556677889900aabbccddeeff") def spanId = DDSpanId.fromHex("123456789abcdef0") - AgentSpan.Context context = Stub { + AgentSpanContext context = Stub { getTraceId() >> traceId getSpanId() >> spanId getSamplingPriority() >> (sampled ? 1 : 0)