-
Hi, I was originally trying to come up with a PR for injecting into SQS message attributes, but noticed that it is quite cumbersome to reflect your way through all the classes/methods needed and that this project is usually using this cool muzzle thingy to get around that. There is this comment, copied a few times for other classes: https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/v1.25.1/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsMessageAccess.java#L16-L24 Basically, the AWS SDK v2 consists of a set of separate libraries per SQS-service and a core library. The aws-sdk-2 instrumentation has these dependencies: IIUC, if I would add e.g. a dependency to SQS, I could code like I want and e.g. cast to SQS-specific classes and use their methods, but then somewhere (only in the agent or also for the library instrumentation?) the whole aws-sdk instrumentation would be suppressed if any of the depended-upon libraries are not available at runtime. So this would be easily solvable if it there would be a separate dependency type like If this would not be feasible, another way would be to have one plugin-instrumentation per aws-sdk plugin library, e.g. instead of having only an all-in-one io.opentelemetry.instrumentation/opentelemetry-aws-sdk-2.2, one would additionally have io.opentelemetry.instrumentation/opentelemetry-aws-sdk-sqs-2.2, and those would then need to interoperate somehow (in this case, I'm thinking of a SPI so that the core library chain-loads specific hook classes, and the API remains unified). In the end, this might be more awkward than the current reflection solution though. Does any of these solutions sound reasonable to you? Where would I start to look if I wanted to try my hand at implementing the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
Hmm, reading through https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/docs/contributing/writing-instrumentation.md#instrumenting-code-that-is-not-available-as-a-maven-dependency, maybe the |
Beta Was this translation helpful? Give feedback.
-
So I read up on it a bit, and it seems what we are working here against are not any compile time checks, but the runtime checks: https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/docs/safety-mechanisms.md#muzzle-runtime-checks It seems that with some refactoring to move all code depending on a plugin library we should be able to use only a few The only problem I have with that is testing. It seems I would need to add a whole new test source set that does not depend on the plugin library and then check that the (non plugin-related) tests still succeed. EDIT: Seems like EDIT2: No this seems to do something different |
Beta Was this translation helpful? Give feedback.
Javaagent modules remove stuff that is supposed to be in the agent from classpath. Try moving this test to separate module that does not apply javaagent conventions like in https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/external-annotations/javaagent-unit-tests