Skip to content

Look in another location for grpc service methods #8468

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 28, 2025
Merged
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 @@ -43,7 +43,7 @@ public boolean isEnabled() {
public void methodAdvice(MethodTransformer transformer) {
transformer.applyAdvice(
isConstructor().and(takesArguments(2)),
MethodHandlersInstrumentation.class.getName() + "$BuildAdvice");
"datadog.trace.instrumentation.grpc.server.MethodHandlersInstrumentation$BuildAdvice");
}

public static class BuildAdvice {
Expand All @@ -52,9 +52,21 @@ public static class BuildAdvice {
public static void onEnter(@Advice.Argument(0) Object serviceImpl) {
try {
Class<?> serviceClass = serviceImpl.getClass();
Class<?> superclass = serviceClass.getSuperclass();
if (superclass != null) {
for (Method method : superclass.getDeclaredMethods()) {
Class<?> superClass = serviceClass.getSuperclass();
while (superClass != null && !superClass.getSimpleName().endsWith("ImplBase")) {
superClass = superClass.getSuperclass();
}
if (superClass != null) {
// bindService() would be the only method in this case and it's irrelevant
if (superClass.getDeclaredMethods().length == 1) {
for (Class<?> i : serviceClass.getInterfaces()) {
if (i.getSimpleName().equals("AsyncService")) {
superClass = i;
break;
}
}
}
for (Method method : superClass.getDeclaredMethods()) {
try {
entry(serviceClass.getDeclaredMethod(method.getName(), method.getParameterTypes()));
} catch (Throwable e) {
Expand Down
Loading