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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package datadog.trace.instrumentation.akkahttp;

import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeScope;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan;

import akka.http.scaladsl.model.HttpRequest;
import akka.http.scaladsl.model.HttpResponse;
Expand Down Expand Up @@ -142,11 +142,11 @@ public void onPush() throws Exception {
response = newResponse;
}
DatadogWrapperHelper.finishSpan(span, response);
// Check if the active scope is still the scope from when the request came in,
// Check if the active span matches the scope from when the request came in,
// and close it. If it's not, then it will be cleaned up actor message
// processing instrumentation that drives this state machine
AgentScope activeScope = activeScope();
if (activeScope == scope) {
AgentSpan activeSpan = activeSpan();
if (activeSpan == scope.span()) {
scope.close();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package datadog.trace.instrumentation.pekkohttp;

import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeScope;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan;

import datadog.trace.bootstrap.instrumentation.api.AgentScope;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import java.util.Queue;
import java.util.concurrent.ArrayBlockingQueue;
import org.apache.pekko.http.scaladsl.model.HttpRequest;
Expand Down Expand Up @@ -113,11 +114,11 @@ public void onPush() throws Exception {
final AgentScope scope = scopes.poll();
if (scope != null) {
DatadogWrapperHelper.finishSpan(scope.span(), response);
// Check if the active scope is still the scope from when the request came in,
// Check if the active span matches the scope from when the request came in,
// and close it. If it's not, then it will be cleaned up actor message
// processing instrumentation that drives this state machine
AgentScope activeScope = activeScope();
if (activeScope == scope) {
AgentSpan activeSpan = activeSpan();
if (activeSpan == scope.span()) {
scope.close();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import datadog.trace.agent.tooling.InstrumenterModule;
import datadog.trace.api.InstrumenterConfig;
import datadog.trace.bootstrap.config.provider.ConfigProvider;
import datadog.trace.bootstrap.instrumentation.api.AgentScope;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import datadog.trace.bootstrap.instrumentation.api.AgentTracer;
import net.bytebuddy.asm.Advice;

Expand Down Expand Up @@ -53,8 +53,8 @@ public static final class DisableWallclockSampling {

@Advice.OnMethodEnter(suppress = Throwable.class)
public static boolean before() {
AgentScope active = AgentTracer.activeScope();
if (active != null) {
AgentSpan activeSpan = AgentTracer.activeSpan();
if (activeSpan != null) {
AgentTracer.get().getProfilingContext().onDetach();
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ public static void onEnter(
@Advice.Argument(value = 0, readOnly = false) HttpHandler handler,
@Advice.Argument(1) final HttpServerExchange exchange,
@Advice.Local("agentScope") AgentScope scope) {
AgentScope currentScope = AgentTracer.activeScope();
if (currentScope != null) {
AgentSpan localRootSpan = currentScope.span().getLocalRootSpan();
AgentSpan activeSpan = AgentTracer.activeSpan();
if (activeSpan != null) {
AgentSpan localRootSpan = activeSpan.getLocalRootSpan();
if (DECORATE.spanName().equals(localRootSpan.getSpanName())) {
// if we can here through the dispatch of an HttpHandler, rather than that of a
// plain Runnable, then Connects.executeRootHandler() will still have been called,
Expand Down
Loading