Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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 @@ -42,4 +42,9 @@ public List<TypeInstrumentation> typeInstrumentations() {
new GraphInterpreterInstrumentation(),
new PekkoHttpServerSourceInstrumentation());
}

@Override
public boolean isIndyReady() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
package io.opentelemetry.javaagent.instrumentation.pekkohttp.v1_0.server;

import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.instrumentation.api.util.VirtualField;
import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenters;
import io.opentelemetry.javaagent.instrumentation.pekkohttp.v1_0.PekkoHttpUtil;
import org.apache.pekko.http.scaladsl.model.HttpRequest;
import org.apache.pekko.http.scaladsl.model.HttpResponse;
import org.apache.pekko.http.scaladsl.server.PathMatcher;

public final class PekkoHttpServerSingletons {

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

static {
INSTRUMENTER =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

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

import static io.opentelemetry.javaagent.instrumentation.pekkohttp.v1_0.server.PekkoHttpServerSingletons.PATH_MATCHER_FIELD;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.returns;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;

import io.opentelemetry.instrumentation.api.util.VirtualField;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
import net.bytebuddy.asm.Advice;
Expand Down Expand Up @@ -41,7 +41,7 @@ public static void onEnter(
@Advice.Argument(0) Uri.Path prefix, @Advice.Return PathMatcher<?> result) {
// store the path being matched inside a VirtualField on the given matcher, so it can be used
// for constructing the route
VirtualField.find(PathMatcher.class, String.class).set(result, prefix.toString());
PATH_MATCHER_FIELD.set(result, prefix.toString());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
package io.opentelemetry.javaagent.instrumentation.pekkohttp.v1_0.server.route;

import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.extendsClass;
import static io.opentelemetry.javaagent.instrumentation.pekkohttp.v1_0.server.PekkoHttpServerSingletons.PATH_MATCHER_FIELD;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;

import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.util.VirtualField;
import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
Expand Down Expand Up @@ -53,7 +53,7 @@ public static void onExit(
PathMatcher.Matched<?> match = (PathMatcher.Matched<?>) result;
// if present use the matched path that was remembered in PathMatcherInstrumentation,
// otherwise just use a *
String prefix = VirtualField.find(PathMatcher.class, String.class).get(pathMatcher);
String prefix = PATH_MATCHER_FIELD.get(pathMatcher);
if (prefix == null) {
if (PathMatchers.Slash$.class == pathMatcher.getClass()) {
prefix = "/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@ public List<TypeInstrumentation> typeInstrumentations() {
new PathMatcherStaticInstrumentation(),
new RouteConcatenationInstrumentation());
}

@Override
public boolean isIndyReady() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ public void transform(TypeTransformer transformer) {
@SuppressWarnings("unused")
public static class ApplyAdvice {

@Advice.AssignReturned.ToArguments(@Advice.AssignReturned.ToArguments.ToArgument(0))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SylvainJuge usually writes this as @AssignReturned.ToArguments(@ToArgument(0))

@Advice.OnMethodEnter(suppress = Throwable.class)
public static void onEnter(
@Advice.Argument(value = 0, readOnly = false)
Function1<RequestContext, Future<RouteResult>> route) {
route = new PekkoRouteWrapper(route);
public static Object onEnter(
@Advice.Argument(0) Function1<RequestContext, Future<RouteResult>> route) {
return new PekkoRouteWrapper(route);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ public void transform(TypeTransformer transformer) {

@SuppressWarnings("unused")
public static class ApplyAdvice {
@Advice.AssignReturned.ToReturned
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void onExit(
public static Object onExit(
@Advice.Argument(0) ServerEndpoint<?, ?> endpoint,
@Advice.Return(readOnly = false) Function1<RequestContext, Future<RouteResult>> route) {
route = new RouteWrapper(endpoint, route);
@Advice.Return Function1<RequestContext, Future<RouteResult>> route) {
return new RouteWrapper(endpoint, route);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,9 @@ public String getModuleGroup() {
public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new TapirPathInstrumentation());
}

@Override
public boolean isIndyReady() {
return true;
}
}
Loading