Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changelog/4831.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`opentelemetry-instrumentation-aws-lambda`: use the correct camel case when accessing the SQS message attributes
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ class _SqsMessageAttributesGetter(Getter[CarrierT]):
"""Extracts W3C trace context from SQS message attribute dicts.

SQS message attributes have the structure:
``{"traceparent": {"DataType": "String", "StringValue": "00-..."}}``.
``{"traceparent": {"dataType": "String", "stringValue": "00-..."}}``.
"""

def get(self, carrier: CarrierT, key: str) -> list[str] | None:
msg_attr = carrier.get(key)
if not isinstance(msg_attr, Mapping):
return None
value = msg_attr.get("StringValue")
value = msg_attr.get("stringValue")
return [value] if isinstance(value, str) else None

def keys(self, carrier: CarrierT) -> list[str]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
},
"messageAttributes": {
"traceparent": {
"DataType": "String",
"StringValue": "00-5ce0e9a56015fec5aadfa328ae398115-ab54a98ceb1f0ad2-01",
"dataType": "String",
"stringValue": "00-5ce0e9a56015fec5aadfa328ae398115-ab54a98ceb1f0ad2-01",
}
},
"md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
Expand All @@ -68,8 +68,8 @@
},
"messageAttributes": {
"TRACEPARENT": {
"DataType": "String",
"StringValue": "00-5ce0e9a56015fec5aadfa328ae398115-ab54a98ceb1f0ad2-01",
"dataType": "String",
"stringValue": "00-5ce0e9a56015fec5aadfa328ae398115-ab54a98ceb1f0ad2-01",
}
},
"md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
Expand Down Expand Up @@ -155,8 +155,8 @@
},
"messageAttributes": {
"Traceparent": {
"DataType": "String",
"StringValue": "00-aabbccddeeff00112233445566778899-aabbccddeeff0011-01",
"dataType": "String",
"stringValue": "00-aabbccddeeff00112233445566778899-aabbccddeeff0011-01",
}
},
"md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b4",
Expand All @@ -176,8 +176,8 @@
},
"messageAttributes": {
"traceparent": {
"DataType": "String",
"StringValue": "00-cafebabe12345678cafebabe12345678-cafebabe12345678-01",
"dataType": "String",
"stringValue": "00-cafebabe12345678cafebabe12345678-cafebabe12345678-01",
}
},
"md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b5",
Expand Down Expand Up @@ -214,7 +214,7 @@
# Malformed: no Records key at all, _is_sqs_event should return False.
MOCK_MALFORMED_SQS_EVENT_NO_RECORDS_KEY = {"body": "oops, no Records key"}

# SQS event with a traceparent whose StringValue is not a valid W3C traceparent.
# SQS event with a traceparent whose stringValue is not a valid W3C traceparent.
# The propagator will parse it as an invalid context, no span link should be extracted.
MOCK_LAMBDA_SQS_EVENT_INVALID_TRACEPARENT = {
"Records": [
Expand All @@ -230,8 +230,8 @@
},
"messageAttributes": {
"traceparent": {
"DataType": "String",
"StringValue": "not-a-valid-traceparent",
"dataType": "String",
"stringValue": "not-a-valid-traceparent",
}
},
"md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
Expand Down Expand Up @@ -267,8 +267,8 @@
]
}

# SQS event where the attribute dict has DataType but no StringValue key.
# The getter returns None for missing StringValue, no link is extracted.
# SQS event where the attribute dict has dataType but no stringValue key.
# The getter returns None for missing stringValue, no link is extracted.
MOCK_LAMBDA_SQS_EVENT_MISSING_STRING_VALUE = {
"Records": [
{
Expand Down Expand Up @@ -352,8 +352,8 @@
},
"messageAttributes": {
"traceparent": {
"DataType": "String",
"StringValue": "00-5ce0e9a56015fec5aadfa328ae398115-ab54a98ceb1f0ad2-01",
"dataType": "String",
"stringValue": "00-5ce0e9a56015fec5aadfa328ae398115-ab54a98ceb1f0ad2-01",
}
},
"md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
Expand All @@ -373,8 +373,8 @@
},
"messageAttributes": {
"traceparent": {
"DataType": "String",
"StringValue": "00-8a3c60f7d188f8fa79d48a391a778fa6-53995c3f42cd8ad8-01",
"dataType": "String",
"stringValue": "00-8a3c60f7d188f8fa79d48a391a778fa6-53995c3f42cd8ad8-01",
}
},
"md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b4",
Expand Down