Skip to content

Commit 78e0d68

Browse files
committed
Migrating PathMatcherInstrumentation
1 parent 10bfb20 commit 78e0d68

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

instrumentation/pekko/pekko-http-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/server/PekkoHttpServerSingletons.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@
66
package io.opentelemetry.javaagent.instrumentation.pekkohttp.v1_0.server;
77

88
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
9+
import io.opentelemetry.instrumentation.api.util.VirtualField;
910
import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenters;
1011
import io.opentelemetry.javaagent.instrumentation.pekkohttp.v1_0.PekkoHttpUtil;
1112
import org.apache.pekko.http.scaladsl.model.HttpRequest;
1213
import org.apache.pekko.http.scaladsl.model.HttpResponse;
14+
import org.apache.pekko.http.scaladsl.server.PathMatcher;
1315

1416
public final class PekkoHttpServerSingletons {
1517

1618
private static final Instrumenter<HttpRequest, HttpResponse> INSTRUMENTER;
19+
public static final VirtualField<PathMatcher<?>, String> PATH_MATCHER_FIELD =
20+
VirtualField.find(PathMatcher.class, String.class);
1721

1822
static {
1923
INSTRUMENTER =

instrumentation/pekko/pekko-http-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/server/route/PathMatcherInstrumentation.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
package io.opentelemetry.javaagent.instrumentation.pekkohttp.v1_0.server.route;
77

8+
import static io.opentelemetry.javaagent.instrumentation.pekkohttp.v1_0.server.PekkoHttpServerSingletons.PATH_MATCHER_FIELD;
89
import static net.bytebuddy.matcher.ElementMatchers.named;
910
import static net.bytebuddy.matcher.ElementMatchers.returns;
1011
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
1112

12-
import io.opentelemetry.instrumentation.api.util.VirtualField;
1313
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
1414
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
1515
import net.bytebuddy.asm.Advice;
@@ -41,7 +41,7 @@ public static void onEnter(
4141
@Advice.Argument(0) Uri.Path prefix, @Advice.Return PathMatcher<?> result) {
4242
// store the path being matched inside a VirtualField on the given matcher, so it can be used
4343
// for constructing the route
44-
VirtualField.find(PathMatcher.class, String.class).set(result, prefix.toString());
44+
PATH_MATCHER_FIELD.set(result, prefix.toString());
4545
}
4646
}
4747
}

0 commit comments

Comments
 (0)