opentelemetry-java-instrumentation
opentelemetry-java-instrumentation copied to clipboard
Message handler
Problem Adding Message Handler for messaging systems. These new handlers will create a span for the user and add span links and set the messaging attributes.
Testing Unit tests
@atshaw43 we already have aws lambda instrumentation in https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/aws-lambda/aws-lambda-events-2.2/library
@atshaw43 we already have aws lambda instrumentation in https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/aws-lambda/aws-lambda-events-2.2/library
Those are Lambda specific because of the Context variable. This is for non-Lambda cases such as EC2.
This is for batching messages, while those classes are for for-loop cases. One message at a time.
@laurit Bump
@atshaw43 Firstly the module name message-handler doesn't seem appropriate as the code seems to deal only with aws messages. Perhaps it should be named aws-something-something or even be moved to aws-sdk module. Secondly instrumentations in this repository must use instrumenter api. The provided documentation does not do a good job illustrating why this code should be used. Also I believe aws-sdk instrumentation already creates spans for sqs, can this code be used together with aws-sdk instrumentation?
Firstly the module name message-handler doesn't seem appropriate as the code seems to deal only with aws messages.
I think this is only sort of true. The code is in many places generic, and I think with a few small adjustments, the interface could be fit for any messages. But at the moment, I agree that it is too AWS-specific.
Note that there is also very similar functionality in the AWS Lambda instrumentation, that could be used as inspiration and generalized: https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/aws-lambda/aws-lambda-events-2.2/library/src/main/java/io/opentelemetry/instrumentation/awslambdaevents/v2_2/TracingSqsMessageHandler.java (maybe even in a way that the AWS Lambda instrumentation could re-use code from this new proposed message handler module)
@atshaw43 Firstly the module name
message-handlerdoesn't seem appropriate as the code seems to deal only with aws messages. Perhaps it should be namedaws-something-somethingor even be moved toaws-sdkmodule. Secondly instrumentations in this repository must use instrumenter api. The provided documentation does not do a good job illustrating why this code should be used. Also I believeaws-sdkinstrumentation already creates spans for sqs, can this code be used together withaws-sdkinstrumentation?
@laurit Thanks for the feedback. I have moved the x-ray specific code to the SqsMessageHandler.
I updated the PR so the MessageHandler focuses on process spans. I had originally tried to have it handle receive and process spans, but that is not feasible. I will open a separate PR for auto-instrumentation for SQS receive message nodes.
This PR has been labeled as stale due to lack of activity. It will be automatically closed if there is no further activity over the next 14 days.