Skip to content

Commit

Permalink
Merge branch 'master' into andrea.marziali/reactor-optimizable
Browse files Browse the repository at this point in the history
  • Loading branch information
amarziali authored Jan 8, 2025
2 parents 9ad2b7d + d3d6f9c commit 1323af9
Show file tree
Hide file tree
Showing 127 changed files with 491 additions and 366 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -121,22 +122,22 @@ protected AgentTracer.TracerAPI tracer() {
return AgentTracer.get();
}

public AgentSpan.Context.Extracted extract(REQUEST_CARRIER carrier) {
public AgentSpanContext.Extracted extract(REQUEST_CARRIER carrier) {
AgentPropagation.ContextVisitor<REQUEST_CARRIER> getter = getter();
if (null == carrier || null == getter) {
return null;
}
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))
Expand All @@ -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()
Expand Down Expand Up @@ -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<Flow<Object>> startedCbAppSec =
tracer.getCallbackProvider(RequestContextSlot.APPSEC).getCallback(EVENTS.requestStarted());
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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) {
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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<AgentSpan.Context> local;
private final ThreadLocal<AgentSpanContext> 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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
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 {

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:
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -30,7 +31,7 @@ public abstract class AbstractTestModule {
private final Consumer<AgentSpan> onSpanFinish;

public AbstractTestModule(
AgentSpan.Context sessionSpanContext,
AgentSpanContext sessionSpanContext,
String moduleName,
@Nullable Long startTime,
InstrumentationType instrumentationType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -52,7 +53,7 @@ public class TestSuiteImpl implements DDTestSuite {
private final Consumer<AgentSpan> onSpanFinish;

public TestSuiteImpl(
AgentSpan.Context moduleSpanContext,
AgentSpanContext moduleSpanContext,
String moduleName,
String testSuiteName,
String itrCorrelationId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -49,7 +50,7 @@ public class BuildSystemModuleImpl extends AbstractTestModule implements BuildSy
private volatile boolean testSkippingEnabled;

public <T extends CoverageCalculator> BuildSystemModuleImpl(
AgentSpan.Context sessionSpanContext,
AgentSpanContext sessionSpanContext,
String moduleName,
String startCommand,
@Nullable Long startTime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -56,7 +57,7 @@ public class ProxyTestModule implements TestFrameworkModule {
private final Collection<TestFramework> testFrameworks = ConcurrentHashMap.newKeySet();

public ProxyTestModule(
AgentSpan.Context parentProcessModuleContext,
AgentSpanContext parentProcessModuleContext,
String moduleName,
ExecutionStrategy executionStrategy,
Config config,
Expand Down
Loading

0 comments on commit 1323af9

Please sign in to comment.