OpenTelemetry Boto3 SQS Instrumentation¶
This library allows tracing requests made by the Boto3 library to the SQS service.
Installation¶
pip install opentelemetry-instrumentation-boto3sqs
References¶
Instrument boto3sqs to trace SQS applications.
Usage¶
import boto3
from opentelemetry.instrumentation.boto3sqs import Boto3SQSInstrumentor
Boto3SQSInstrumentor().instrument()
—
- class opentelemetry.instrumentation.boto3sqs.Boto3SQSGetter(*args, **kwds)[source]¶
Bases:
opentelemetry.propagators.textmap.Getter
[opentelemetry.propagators.textmap.CarrierT
]
- class opentelemetry.instrumentation.boto3sqs.Boto3SQSSetter(*args, **kwds)[source]¶
Bases:
opentelemetry.propagators.textmap.Setter
[opentelemetry.propagators.textmap.CarrierT
]
- class opentelemetry.instrumentation.boto3sqs.Boto3SQSInstrumentor(*args, **kwargs)[source]¶
Bases:
opentelemetry.instrumentation.instrumentor.BaseInstrumentor
- received_messages_spans: Dict[str, opentelemetry.trace.span.Span] = {}¶
- current_context_token = None¶
- class ContextableList(iterable=(), /)[source]¶
Bases:
list
Since the classic way to process SQS messages is using a
The for statement
loop, without a well defined scope like a callback - we are doing something similar to the instrumentation of Kafka-python and instrumenting the__iter__
functions and the__getitem__
functions to set the span context of the addressed message. Since the return value from anSQS.ReceiveMessage
returns a builtin list, we cannot wrap it and change all of the calls forlist.__iter__
andlist.__getitem__
- therefore we use ContextableList. It is bound to the received_messages_spans dict
- instrumentation_dependencies()[source]¶
Return a list of python packages with versions that the will be instrumented.
The format should be the same as used in requirements.txt or pyproject.toml.
For example, if an instrumentation instruments requests 1.x, this method should look like:
- def instrumentation_dependencies(self) -> Collection[str]:
return [‘requests ~= 1.0’]
This will ensure that the instrumentation will only be used when the specified library is present in the environment.
- Return type