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
Expand Up @@ -2,7 +2,6 @@

import static datadog.trace.bootstrap.instrumentation.api.AgentSpan.fromContext;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
import static datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge.currentContext;
import static datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge.rootContext;
import static datadog.trace.instrumentation.axway.AxwayHTTPPluginDecorator.DECORATE;
import static datadog.trace.instrumentation.axway.AxwayHTTPPluginDecorator.SERVER_TRANSACTION_CLASS;
Expand All @@ -21,7 +20,7 @@ public static ContextScope onEnter(@Advice.Argument(value = 2) final Object serv
DECORATE.afterStart(span);
// serverTransaction is like request + connection in one object:
DECORATE.onRequest(span, serverTransaction, serverTransaction, rootContext());
return currentContext().with(span).attach();
return span.attachWithContext();
}

@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
import static datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge.currentContext;
import static datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge.spanFromContext;
import static datadog.trace.bootstrap.instrumentation.decorator.http.HttpResourceDecorator.HTTP_RESOURCE_DECORATOR;
import static datadog.trace.instrumentation.finatra.FinatraDecorator.DECORATE;
Expand Down Expand Up @@ -79,7 +78,7 @@ public static ContextScope nameSpan(
DECORATE.afterStart(span);
span.setResourceName(DECORATE.className(clazz));

return currentContext().with(span).attach();
return span.attachWithContext();
}

@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package datadog.trace.instrumentation.micronaut;

import static datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge.currentContext;
import static datadog.trace.instrumentation.micronaut.MicronautDecorator.DECORATE;
import static datadog.trace.instrumentation.micronaut.MicronautDecorator.SPAN_ATTRIBUTE;

Expand All @@ -20,7 +19,7 @@ public static void beginRequest(
return;
}

try (final ContextScope scope = currentContext().with(span).attach()) {
try (final ContextScope scope = span.attachWithContext()) {
DECORATE.onResponse(span, message);
DECORATE.beforeFinish(scope.context());
span.finish();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static datadog.trace.agent.tooling.bytebuddy.matcher.HierarchyMatchers.implementsInterface;
import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
import static datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge.currentContext;
import static datadog.trace.instrumentation.netty38.server.NettyHttpServerDecorator.DECORATE;
import static datadog.trace.instrumentation.netty38.server.NettyHttpServerDecorator.NETTY;
import static datadog.trace.instrumentation.netty38.server.NettyHttpServerDecorator.NETTY_CONNECT;
Expand Down Expand Up @@ -110,7 +109,7 @@ public static AgentScope activateScope(@Advice.Argument(0) final ChannelFuture f

final AgentSpan errorSpan = startSpan("netty", NETTY_CONNECT).setTag(Tags.COMPONENT, "netty");
errorSpan.spanContext().setIntegrationName(NETTY);
try (final ContextScope scope = currentContext().with(errorSpan).attach()) {
try (final ContextScope scope = errorSpan.attachWithContext()) {
DECORATE.onError(errorSpan, cause);
DECORATE.beforeFinish(scope.context());
errorSpan.finish();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static datadog.trace.instrumentation.netty38.server.NettyHttpServerDecorator.DECORATE;

import datadog.context.Context;
import datadog.context.ContextScope;
import datadog.trace.bootstrap.ContextStore;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
Expand Down Expand Up @@ -36,7 +35,7 @@ public void writeRequested(final ChannelHandlerContext ctx, final MessageEvent m
return;
}

try (final ContextScope scope = Context.current().with(span).attach()) {
try (final ContextScope scope = span.attachWithContext()) {
final HttpResponse response = (HttpResponse) msg.getMessage();

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static datadog.trace.agent.tooling.bytebuddy.matcher.HierarchyMatchers.implementsInterface;
import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
import static datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge.currentContext;
import static datadog.trace.instrumentation.netty40.AttributeKeys.CONNECT_PARENT_CONTINUATION_ATTRIBUTE_KEY;
import static datadog.trace.instrumentation.netty40.server.NettyHttpServerDecorator.NETTY;
import static datadog.trace.instrumentation.netty40.server.NettyHttpServerDecorator.NETTY_CONNECT;
Expand Down Expand Up @@ -95,7 +94,7 @@ public static AgentScope activateScope(@Advice.Argument(0) final ChannelFuture f

final AgentSpan errorSpan = startSpan("netty", NETTY_CONNECT).setTag(Tags.COMPONENT, "netty");
errorSpan.spanContext().setIntegrationName(NETTY);
try (final ContextScope scope = currentContext().with(errorSpan).attach()) {
try (final ContextScope scope = errorSpan.attachWithContext()) {
NettyHttpServerDecorator.DECORATE.onError(errorSpan, cause);
NettyHttpServerDecorator.DECORATE.beforeFinish(scope.context());
errorSpan.finish();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static datadog.trace.agent.tooling.bytebuddy.matcher.HierarchyMatchers.implementsInterface;
import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
import static datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge.currentContext;
import static datadog.trace.instrumentation.netty41.AttributeKeys.CONNECT_PARENT_CONTINUATION_ATTRIBUTE_KEY;
import static datadog.trace.instrumentation.netty41.server.NettyHttpServerDecorator.NETTY;
import static datadog.trace.instrumentation.netty41.server.NettyHttpServerDecorator.NETTY_CONNECT;
Expand Down Expand Up @@ -95,7 +94,7 @@ public static AgentScope activateScope(@Advice.Argument(0) final ChannelFuture f

final AgentSpan errorSpan = startSpan("netty", NETTY_CONNECT).setTag(Tags.COMPONENT, "netty");
errorSpan.spanContext().setIntegrationName(NETTY);
try (final ContextScope scope = currentContext().with(errorSpan).attach()) {
try (final ContextScope scope = errorSpan.attachWithContext()) {
NettyHttpServerDecorator.DECORATE.onError(errorSpan, cause);
NettyHttpServerDecorator.DECORATE.beforeFinish(scope.context());
errorSpan.finish();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package datadog.trace.instrumentation.playws1;

import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
import static datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge.currentContext;
import static datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge.spanFromContext;
import static datadog.trace.instrumentation.playws.PlayWSClientDecorator.DECORATE;
import static datadog.trace.instrumentation.playws.PlayWSClientDecorator.PLAY_WS_REQUEST;
Expand Down Expand Up @@ -37,7 +36,7 @@ public static ContextScope methodEnter(
asyncHandler = new AsyncHandlerWrapper(asyncHandler, span);
}

return currentContext().with(span).attach();
return span.attachWithContext();
}

@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package datadog.trace.instrumentation.playws2;

import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
import static datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge.currentContext;
import static datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge.spanFromContext;
import static datadog.trace.instrumentation.playws.PlayWSClientDecorator.DECORATE;
import static datadog.trace.instrumentation.playws.PlayWSClientDecorator.PLAY_WS_REQUEST;
Expand Down Expand Up @@ -37,7 +36,7 @@ public static ContextScope methodEnter(
asyncHandler = new AsyncHandlerWrapper(asyncHandler, span);
}

return currentContext().with(span).attach();
return span.attachWithContext();
}

@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package datadog.trace.instrumentation.playws21;

import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
import static datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge.currentContext;
import static datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge.spanFromContext;
import static datadog.trace.instrumentation.playws.PlayWSClientDecorator.DECORATE;
import static datadog.trace.instrumentation.playws.PlayWSClientDecorator.PLAY_WS_REQUEST;
Expand Down Expand Up @@ -37,7 +36,7 @@ public static ContextScope methodEnter(
asyncHandler = new AsyncHandlerWrapper(asyncHandler, span);
}

return currentContext().with(span).attach();
return span.attachWithContext();
}

@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static ContextScope onEnter(@Advice.Argument(0) final Request<?> req) {
// Do not extract the context.
span = startSpan(PLAY_ACTION.toString(), PLAY_REQUEST);
span.setMeasured(true);
scope = span.attachWithCurrent();
scope = span.attachWithContext();
}

DECORATE.afterStart(span);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static ContextScope onEnter(@Advice.Argument(value = 0, readOnly = false)
// Do not extract the context.
span = startSpan(PLAY_ACTION.toString(), PLAY_REQUEST);
span.setMeasured(true);
scope = span.attachWithCurrent();
scope = span.attachWithContext();
}

DECORATE.afterStart(span);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static ContextScope onEnter(@Advice.Argument(value = 0, readOnly = false)
// Do not extract the context.
parentContext = rootContext();
span = startSpan(PLAY_ACTION.toString(), PLAY_REQUEST);
scope = span.attachWithCurrent();
scope = span.attachWithContext();
}

span.setMeasured(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
import static datadog.trace.bootstrap.instrumentation.api.InstrumentationTags.SERVLET_CONTEXT;
import static datadog.trace.bootstrap.instrumentation.api.InstrumentationTags.SERVLET_PATH;
import static datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge.currentContext;
import static datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge.spanFromContext;
import static datadog.trace.bootstrap.instrumentation.decorator.HttpServerDecorator.DD_CONTEXT_ATTRIBUTE;
import static datadog.trace.instrumentation.servlet.ServletRequestSetter.SETTER;
Expand Down Expand Up @@ -136,7 +135,7 @@ public static ContextScope start(
// temporarily replace from request to avoid spring resource name bubbling up:
requestContext = request.getAttribute(DD_CONTEXT_ATTRIBUTE);

final ContextScope scope = currentContext().with(span).attach();
final ContextScope scope = span.attachWithContext();
// Set the context after activation so we have the proper Context object
request.setAttribute(DD_CONTEXT_ATTRIBUTE, scope.context());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
import static datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge.currentContext;
import static datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge.spanFromContext;
import static datadog.trace.instrumentation.springweb.SpringWebHttpServerDecorator.DECORATE;
import static datadog.trace.instrumentation.springweb.SpringWebHttpServerDecorator.DECORATE_RENDER;
Expand Down Expand Up @@ -100,7 +99,7 @@ public static ContextScope onEnter(@Advice.Argument(0) final ModelAndView mv) {
final AgentSpan span = startSpan("spring-webmvc", RESPONSE_RENDER);
DECORATE_RENDER.afterStart(span);
DECORATE_RENDER.onRender(span, mv);
return currentContext().with(span).attach();
return span.attachWithContext();
}

@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
import static datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge.currentContext;
import static datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge.rootContext;
import static datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge.spanFromContext;
import static datadog.trace.bootstrap.instrumentation.decorator.HttpServerDecorator.DD_CONTEXT_ATTRIBUTE;
Expand Down Expand Up @@ -110,7 +109,7 @@ public static ContextScope nameResourceAndStartSpan(
DECORATE.onHandle(span, handler);

request.setAttribute(handlerSpanKey, span);
return currentContext().with(span).attach();
return span.attachWithContext();
}

@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static datadog.context.Context.root;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
import static datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge.currentContext;
import static datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge.spanFromContext;
import static datadog.trace.bootstrap.instrumentation.decorator.HttpServerDecorator.DD_CONTEXT_ATTRIBUTE;
import static datadog.trace.instrumentation.springweb6.SpringWebHttpServerDecorator.DD_HANDLER_SPAN_CONTINUE_SUFFIX;
Expand Down Expand Up @@ -65,7 +64,7 @@ By the time HandlerAdapter.handle runs, every handler mapping kind (annotated an
DECORATE.onHandle(span, handler);

request.setAttribute(handlerSpanKey, span);
return currentContext().with(span).attach();
return span.attachWithContext();
}

@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package datadog.trace.instrumentation.springweb6;

import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
import static datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge.currentContext;
import static datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge.spanFromContext;

import datadog.context.ContextScope;
Expand All @@ -16,7 +15,7 @@ public static ContextScope onEnter(@Advice.Argument(0) final ModelAndView mv) {
final AgentSpan span = startSpan("spring-webmvc", SpringWebHttpServerDecorator.RESPONSE_RENDER);
SpringWebHttpServerDecorator.DECORATE_RENDER.afterStart(span);
SpringWebHttpServerDecorator.DECORATE_RENDER.onRender(span, mv);
return currentContext().with(span).attach();
return span.attachWithContext();
}

@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.captureActiveSpan;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.noopContinuation;
import static datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge.currentContext;
import static datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge.spanFromContext;
import static datadog.trace.instrumentation.synapse3.SynapseClientDecorator.DECORATE;
import static datadog.trace.instrumentation.synapse3.SynapseClientDecorator.SYNAPSE_CONTINUATION_KEY;
Expand Down Expand Up @@ -73,7 +72,7 @@ public static ContextScope beginResponse(
if (null != continuation) {
AgentScope agentScope = continuation.activate();
try {
return currentContext().with(agentScope.span()).attach();
return agentScope.span().attachWithContext();
} finally {
agentScope.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.captureActiveSpan;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.noopContinuation;
import static datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge.currentContext;
import static datadog.trace.bootstrap.instrumentation.api.Java8BytecodeBridge.spanFromContext;
import static datadog.trace.instrumentation.synapse3.SynapseServerDecorator.DECORATE;
import static datadog.trace.instrumentation.synapse3.SynapseServerDecorator.SYNAPSE_CONTEXT_KEY;
Expand Down Expand Up @@ -77,7 +76,7 @@ public static ContextScope beginResponse(
if (null != continuation) {
AgentScope agentScope = continuation.activate();
try {
return currentContext().with(agentScope.span()).attach();
return agentScope.span().attachWithContext();
} finally {
agentScope.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ default ContextScope attach() {
*
* @return a scope to be closed when the combined context is invalid.
*/
default ContextScope attachWithCurrent() {
default ContextScope attachWithContext() {
Comment thread
mcculls marked this conversation as resolved.
return storeInto(Context.current()).attach();
}

Expand Down
Loading