Skip to content

Commit 4501dbe

Browse files
authored
Merge pull request #899 from dpratt/fix-akka-http
Fix akka-http instrumentation.
2 parents aa33030 + 681420a commit 4501dbe

File tree

7 files changed

+8
-133
lines changed

7 files changed

+8
-133
lines changed

dd-java-agent/instrumentation/akka-http-10.0/akka-http-10.0.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ muzzle {
5959
// later versions of akka-http expect streams to be provided
6060
extraDependency 'com.typesafe.akka:akka-stream_2.12:2.5.11'
6161
}
62+
//There is no akka-http 10.0.x series for scala 2.13
63+
pass {
64+
group = 'com.typesafe.akka'
65+
module = 'akka-http_2.13'
66+
versions = "[10.1.8,)"
67+
// later versions of akka-http expect streams to be provided
68+
extraDependency 'com.typesafe.akka:akka-stream_2.13:2.5.23'
69+
}
6270
}
6371

6472
dependencies {
Lines changed: 0 additions & 45 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,10 +45,6 @@ public String[] helperClassNames() {
4945
return new String[] {
5046
AkkaHttpClientInstrumentation.class.getName() + "$OnCompleteHandler",
5147
AkkaHttpClientInstrumentation.class.getName() + "$AkkaHttpHeaders",
52-
packageName + ".AkkaHttpClientTransformFlow",
53-
packageName + ".AkkaHttpClientTransformFlow$",
54-
packageName + ".AkkaHttpClientTransformFlow$$anonfun$transform$1",
55-
packageName + ".AkkaHttpClientTransformFlow$$anonfun$transform$2",
5648
"datadog.trace.agent.decorator.BaseDecorator",
5749
"datadog.trace.agent.decorator.ClientDecorator",
5850
"datadog.trace.agent.decorator.HttpClientDecorator",
@@ -72,14 +64,6 @@ public Map<? extends ElementMatcher<? super MethodDescription>, String> transfor
7264
named("singleRequestImpl")
7365
.and(takesArgument(0, named("akka.http.scaladsl.model.HttpRequest"))),
7466
SingleRequestAdvice.class.getName());
75-
// This is mainly for compatibility with 10.0
76-
transformers.put(
77-
named("superPool").and(returns(named("akka.stream.scaladsl.Flow"))),
78-
SuperPoolAdvice.class.getName());
79-
// This is for 10.1+
80-
transformers.put(
81-
named("superPoolImpl").and(returns(named("akka.stream.scaladsl.Flow"))),
82-
SuperPoolAdvice.class.getName());
8367
return transformers;
8468
}
8569

@@ -108,7 +92,6 @@ public static Scope methodEnter(
10892
// Request is immutable, so we have to assign new value once we update headers
10993
request = headers.getRequest();
11094
}
111-
11295
return scope;
11396
}
11497

@@ -137,34 +120,6 @@ public static void methodExit(
137120
}
138121
}
139122

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

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

Lines changed: 0 additions & 35 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)