Skip to content

Commit 681420a

Browse files
committed
Remove SuperPool instrumentation.
By definition, a Flow generated by a SuperPool does not respect ordering of requests and responses, and in fact will typically only rarely actually behave in the fashion that the instrumentation expects. The previous implementation would start a span for a given request before submitting it as input to the flow, and close the span with whatever response is next emitted by the flow. This request will rarely (if ever) be the actual response for the request that started the span. For more info, see the official docs at https://doc.akka.io/docs/akka-http/current/client-side/host-level.html#configuring-a-host-connection-pool Additionally, compiling this instumentation against scala 2.11, and only scala 2.11 can (and does) cause significant problems at runtime due to the fact that Scala is explicitly not binary compatible across major versions.
1 parent bf7bbf3 commit 681420a

File tree

6 files changed

+0
-156
lines changed

6 files changed

+0
-156
lines changed
Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22

33
import static datadog.trace.instrumentation.akkahttp.AkkaHttpClientDecorator.DECORATE;
44
import static net.bytebuddy.matcher.ElementMatchers.named;
5-
import static net.bytebuddy.matcher.ElementMatchers.returns;
65
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
76

8-
import akka.NotUsed;
97
import akka.http.javadsl.model.headers.RawHeader;
108
import akka.http.scaladsl.HttpExt;
119
import akka.http.scaladsl.model.HttpRequest;
1210
import akka.http.scaladsl.model.HttpResponse;
13-
import akka.stream.scaladsl.Flow;
1411
import com.google.auto.service.AutoService;
1512
import datadog.trace.agent.tooling.Instrumenter;
1613
import datadog.trace.bootstrap.CallDepthThreadLocalMap;
@@ -27,7 +24,6 @@
2724
import net.bytebuddy.description.method.MethodDescription;
2825
import net.bytebuddy.description.type.TypeDescription;
2926
import net.bytebuddy.matcher.ElementMatcher;
30-
import scala.Tuple2;
3127
import scala.concurrent.Future;
3228
import scala.runtime.AbstractFunction1;
3329
import scala.util.Try;
@@ -49,7 +45,6 @@ public String[] helperClassNames() {
4945
return new String[] {
5046
AkkaHttpClientInstrumentation.class.getName() + "$OnCompleteHandler",
5147
AkkaHttpClientInstrumentation.class.getName() + "$AkkaHttpHeaders",
52-
packageName + ".AkkaHttpClientTransformFlow",
5348
"datadog.trace.agent.decorator.BaseDecorator",
5449
"datadog.trace.agent.decorator.ClientDecorator",
5550
"datadog.trace.agent.decorator.HttpClientDecorator",
@@ -69,14 +64,6 @@ public Map<? extends ElementMatcher<? super MethodDescription>, String> transfor
6964
named("singleRequestImpl")
7065
.and(takesArgument(0, named("akka.http.scaladsl.model.HttpRequest"))),
7166
SingleRequestAdvice.class.getName());
72-
// This is mainly for compatibility with 10.0
73-
transformers.put(
74-
named("superPool").and(returns(named("akka.stream.scaladsl.Flow"))),
75-
SuperPoolAdvice.class.getName());
76-
// This is for 10.1+
77-
transformers.put(
78-
named("superPoolImpl").and(returns(named("akka.stream.scaladsl.Flow"))),
79-
SuperPoolAdvice.class.getName());
8067
return transformers;
8168
}
8269

@@ -105,7 +92,6 @@ public static Scope methodEnter(
10592
// Request is immutable, so we have to assign new value once we update headers
10693
request = headers.getRequest();
10794
}
108-
10995
return scope;
11096
}
11197

@@ -134,34 +120,6 @@ public static void methodExit(
134120
}
135121
}
136122

137-
public static class SuperPoolAdvice {
138-
139-
@Advice.OnMethodEnter(suppress = Throwable.class)
140-
public static boolean methodEnter() {
141-
/*
142-
Versions 10.0 and 10.1 have slightly different structure that is hard to distinguish so here
143-
we cast 'wider net' and avoid instrumenting twice.
144-
In the future we may want to separate these, but since lots of code is reused we would need to come up
145-
with way of continuing to reusing it.
146-
*/
147-
final int callDepth = CallDepthThreadLocalMap.incrementCallDepth(HttpExt.class);
148-
return callDepth <= 0;
149-
}
150-
151-
@Advice.OnMethodExit(suppress = Throwable.class)
152-
public static <T> void methodExit(
153-
@Advice.Return(readOnly = false)
154-
Flow<Tuple2<HttpRequest, T>, Tuple2<Try<HttpResponse>, T>, NotUsed> flow,
155-
@Advice.Enter final boolean isApplied) {
156-
if (!isApplied) {
157-
return;
158-
}
159-
CallDepthThreadLocalMap.reset(HttpExt.class);
160-
161-
flow = AkkaHttpClientTransformFlow.transform(flow);
162-
}
163-
}
164-
165123
public static class OnCompleteHandler extends AbstractFunction1<Try<HttpResponse>, Void> {
166124
private final Span span;
167125

dd-java-agent/instrumentation/akka-http-10.0/src/main/scala/datadog/trace/instrumentation/akkahttp/AkkaHttpClientTransformFlow.java

Lines changed: 0 additions & 61 deletions
This file was deleted.

dd-java-agent/instrumentation/akka-http-10.0/src/test/groovy/AkkaHttpClientPoolInstrumentationTest.groovy

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)