-
Notifications
You must be signed in to change notification settings - Fork 906
Closed
Description
The boto3sqs instrumentation prepends "otel." to all attributes it adds to SQS messages (relevant code:
Lines 56 to 82 in 7c75b38
| # We use this prefix so we can request all instrumentation MessageAttributeNames with a wildcard, without harming | |
| # existing filters | |
| _OPENTELEMETRY_ATTRIBUTE_IDENTIFIER: str = "otel." | |
| _OTEL_IDENTIFIER_LENGTH = len(_OPENTELEMETRY_ATTRIBUTE_IDENTIFIER) | |
| class Boto3SQSGetter(Getter[CarrierT]): | |
| def get(self, carrier: CarrierT, key: str) -> Optional[List[str]]: | |
| value = carrier.get(f"{_OPENTELEMETRY_ATTRIBUTE_IDENTIFIER}{key}", {}) | |
| if not value: | |
| return None | |
| return [value.get("StringValue")] | |
| def keys(self, carrier: CarrierT) -> List[str]: | |
| return [ | |
| key[_OTEL_IDENTIFIER_LENGTH:] | |
| if key.startswith(_OPENTELEMETRY_ATTRIBUTE_IDENTIFIER) | |
| else key | |
| for key in carrier.keys() | |
| ] | |
| class Boto3SQSSetter(Setter[CarrierT]): | |
| def set(self, carrier: CarrierT, key: str, value: str) -> None: | |
| # This is a limitation defined by AWS for SQS MessageAttributes size | |
| if len(carrier.items()) < 10: | |
| carrier[f"{_OPENTELEMETRY_ATTRIBUTE_IDENTIFIER}{key}"] = { |
The reasons cited at https://www.oxeye.io/blog/diving-into-opentelemetrys-specs:
- Prevents propagators setting keys that start with AWS. or Amazon., which would be rejected -- a rather weak reason IMHO as this is very unlikely to happen and there are other, perhaps more likely, rules that keys must adhere to that are not addressed.
- Keys needed for extraction, or prefix thereof, must be known before calling the receive API which requires a list of attributes to receive -- this can be solved by using
TextMapPropagator.fields, although it is meant for listing injected fields, these will usually be the same as extracted ones. This is also what Node.Js does: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/1db1fecc16ecb3dbad530de530418260e54c087a/plugins/node/opentelemetry-instrumentation-aws-sdk/src/services/sqs.ts#L71-L75
So I suggest to remove the otel. prefix and instead use TextMapPropagator.fields to ensure the required attributes are fetched.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels