opentelemetry-python-contrib icon indicating copy to clipboard operation
opentelemetry-python-contrib copied to clipboard

botocore: Add enhanced support for SQS

Open mariojonke opened this issue 2 years ago • 4 comments
trafficstars

Description

Adds enhanced support for SQS by setting relevant span attributes, and injecting/extracting the trace context into/from the MessageAttributes of SQS messages.

This PR adds the same functionality to the botocore instrumentation that already exists in the Node.Js AWS-SDK instrumentation and in the separate boto3sqs instrumentation package.

The way how SQS processing spans are handled is different though between the boto3sqs instrumentation and the approach in this PR. The boto3sqs instrumentation tries to automatically create the processing spans while the Messages list (the return value of the sqs.receive_message call) is iterated. This is rather error prone since e.g. the list might be iterated multiple times, and the processing spans are tracked by the instrumentation in a more or less global dictionary which might lead to memory leaks. Since for an instrumentation it is not reasonably possible to determine when to start/end a processing span, the automatic detection "feature" was not considered in this PR. Instead the instrumentation provides a context manager and a decorator that need to be added manually, which in turn create the processing span for a corresponding SQS message.

Type of change

  • [x] New feature (non-breaking change which adds functionality)
  • [x] This change requires a documentation update

How Has This Been Tested?

Added multiple unit tests to verify span attributes and trace context propagation for SQS and also SNS to SQS scenarios.

Does This PR Require a Core Repo Change?

  • [x] No.

Checklist:

  • [x] Followed the style guidelines of this project
  • [x] Changelogs have been updated
  • [x] Unit tests have been added
  • [x] Documentation has been updated

mariojonke avatar Jan 25 '23 16:01 mariojonke