Prevent instrumentation from applying too broadly (#337)

This commit is contained in:
Trask Stalnaker 2020-04-24 15:09:30 -07:00 committed by GitHub
parent 1e29610897
commit ccff07abb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -24,6 +24,7 @@ import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
import com.google.auto.service.AutoService;
import io.opentelemetry.auto.bootstrap.ContextStore;
import io.opentelemetry.auto.bootstrap.InstrumentationContext;
import io.opentelemetry.auto.instrumentation.opentelemetryapi.context.ContextUtils;
import io.opentelemetry.auto.tooling.Instrumenter;
import java.util.HashMap;
import java.util.Map;
@ -58,5 +59,11 @@ public class GrpcContextInstrumentation extends AbstractInstrumentation {
InstrumentationContext.get(Context.class, io.grpc.Context.class);
contextStore.put(context, io.grpc.Context.current());
}
// this is to make muzzle think we need ContextUtils to make sure we do not apply this
// instrumentation when ContextUtils would not work
public static Object muzzleCheck() {
return ContextUtils.class;
}
}
}