Skip to content

Commit

Permalink
chore(core): Remove custom scope manager support
Browse files Browse the repository at this point in the history
  • Loading branch information
PerfectSlayer committed Jan 8, 2025
1 parent d6d6049 commit a2125e2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 41 deletions.
14 changes: 3 additions & 11 deletions dd-trace-core/src/main/java/datadog/trace/core/CoreTracer.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import datadog.trace.bootstrap.instrumentation.api.AgentHistogram;
import datadog.trace.bootstrap.instrumentation.api.AgentPropagation;
import datadog.trace.bootstrap.instrumentation.api.AgentScope;
import datadog.trace.bootstrap.instrumentation.api.AgentScopeManager;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import datadog.trace.bootstrap.instrumentation.api.AgentSpanLink;
import datadog.trace.bootstrap.instrumentation.api.AgentTracer;
Expand Down Expand Up @@ -165,7 +164,7 @@ public static CoreTracerBuilder builder() {
/** Sampler defines the sampling policy in order to reduce the number of traces for instance */
final Sampler initialSampler;
/** Scope manager is in charge of managing the scopes from which spans are created */
final AgentScopeManager scopeManager;
final ContinuableScopeManager scopeManager;

final MetricsAggregator metricsAggregator;

Expand Down Expand Up @@ -295,7 +294,7 @@ public static class CoreTracerBuilder {
private SingleSpanSampler singleSpanSampler;
private HttpCodec.Injector injector;
private HttpCodec.Extractor extractor;
private AgentScopeManager scopeManager;
private ContinuableScopeManager scopeManager;
private Map<String, ?> localRootSpanTags;
private Map<String, ?> defaultSpanTags;
private Map<String, String> serviceNameMappings;
Expand Down Expand Up @@ -356,11 +355,6 @@ public CoreTracerBuilder extractor(HttpCodec.Extractor extractor) {
return this;
}

public CoreTracerBuilder scopeManager(AgentScopeManager scopeManager) {
this.scopeManager = scopeManager;
return this;
}

public CoreTracerBuilder localRootSpanTags(Map<String, ?> localRootSpanTags) {
this.localRootSpanTags = tryMakeImmutableMap(localRootSpanTags);
return this;
Expand Down Expand Up @@ -1103,9 +1097,7 @@ public DataStreamsCheckpointer getDataStreamsCheckpointer() {

@Override
public void addScopeListener(final ScopeListener listener) {
if (scopeManager instanceof ContinuableScopeManager) {
((ContinuableScopeManager) scopeManager).addScopeListener(listener);
}
this.scopeManager.addScopeListener(listener);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
import datadog.trace.api.scopemanager.ExtendedScopeListener;
import datadog.trace.api.scopemanager.ScopeListener;
import datadog.trace.bootstrap.instrumentation.api.AgentScope;
import datadog.trace.bootstrap.instrumentation.api.AgentScopeManager;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import datadog.trace.bootstrap.instrumentation.api.AgentTracer;
import datadog.trace.bootstrap.instrumentation.api.ProfilerContext;
import datadog.trace.bootstrap.instrumentation.api.ProfilingContextIntegration;
import datadog.trace.bootstrap.instrumentation.api.ScopeSource;
import datadog.trace.bootstrap.instrumentation.api.ScopeState;
import datadog.trace.bootstrap.instrumentation.api.ScopeStateAware;
import datadog.trace.core.monitor.HealthMetrics;
import datadog.trace.relocate.api.RatelimitedLogger;
import datadog.trace.util.AgentTaskScheduler;
Expand All @@ -37,7 +37,7 @@
* from being reported even if all related spans are finished. It also delegates to other
* ScopeInterceptors to provide additional functionality.
*/
public final class ContinuableScopeManager implements AgentScopeManager {
public final class ContinuableScopeManager implements ScopeStateAware {
static final Logger log = LoggerFactory.getLogger(ContinuableScopeManager.class);
static final RatelimitedLogger ratelimitedLog = new RatelimitedLogger(log, 1, MINUTES);
static final long iterationKeepAlive =
Expand Down Expand Up @@ -81,18 +81,15 @@ public ContinuableScopeManager(
this.profilingContextIntegration = profilingContextIntegration;
}

@Override
public AgentScope activate(final AgentSpan span, final ScopeSource source) {
return activate(span, source.id(), false, /* ignored */ false);
}

@Override
public AgentScope activate(
final AgentSpan span, final ScopeSource source, boolean isAsyncPropagating) {
return activate(span, source.id(), true, isAsyncPropagating);
}

@Override
public AgentScope.Continuation captureSpan(final AgentSpan span) {
AbstractContinuation continuation =
new SingleContinuation(this, span, ScopeSource.INSTRUMENTATION.id());
Expand Down Expand Up @@ -170,7 +167,6 @@ ContinuableScope continueSpan(
return scope;
}

@Override
public void closePrevious(final boolean finishSpan) {
ScopeStack scopeStack = scopeStack();

Expand All @@ -189,7 +185,6 @@ public void closePrevious(final boolean finishSpan) {
}
}

@Override
public AgentScope activateNext(final AgentSpan span) {
ScopeStack scopeStack = scopeStack();

Expand Down Expand Up @@ -220,12 +215,10 @@ public AgentScope activateNext(final AgentSpan span) {
return scope;
}

@Override
public AgentScope active() {
return scopeStack().active();
}

@Override
public AgentSpan activeSpan() {
final ContinuableScope active = scopeStack().active();
return active == null ? null : active.span;
Expand Down

This file was deleted.

0 comments on commit a2125e2

Please sign in to comment.