|
20 | 20 | reraise, |
21 | 21 | ) |
22 | 22 | from sentry_sdk.integrations import Integration |
23 | | -from sentry_sdk.integrations._wsgi_common import _filter_headers |
| 23 | +from sentry_sdk.integrations._wsgi_common import ( |
| 24 | + _filter_headers, |
| 25 | + _request_headers_to_span_attributes, |
| 26 | +) |
24 | 27 |
|
25 | 28 | from typing import TYPE_CHECKING |
26 | 29 |
|
@@ -162,7 +165,7 @@ def sentry_handler(aws_event, aws_context, *args, **kwargs): |
162 | 165 | name=aws_context.function_name, |
163 | 166 | source=TRANSACTION_SOURCE_COMPONENT, |
164 | 167 | origin=AwsLambdaIntegration.origin, |
165 | | - attributes=_prepopulate_attributes(aws_event, aws_context), |
| 168 | + attributes=_prepopulate_attributes(aws_event, aws_context, headers), |
166 | 169 | ): |
167 | 170 | try: |
168 | 171 | return handler(aws_event, aws_context, *args, **kwargs) |
@@ -487,10 +490,15 @@ def _prepopulate_attributes(aws_event, aws_context): |
487 | 490 | url += f"?{aws_event['queryStringParameters']}" |
488 | 491 | attributes["url.full"] = url |
489 | 492 |
|
490 | | - headers = aws_event.get("headers") or {} |
| 493 | + headers = {} |
| 494 | + if aws_event.get("headers") and isinstance(aws_event["headers"], dict): |
| 495 | + headers = aws_event["headers"] |
| 496 | + |
491 | 497 | if headers.get("X-Forwarded-Proto"): |
492 | 498 | attributes["network.protocol.name"] = headers["X-Forwarded-Proto"] |
493 | 499 | if headers.get("Host"): |
494 | 500 | attributes["server.address"] = headers["Host"] |
495 | 501 |
|
| 502 | + attributes.update(_request_headers_to_span_attributes(headers)) |
| 503 | + |
496 | 504 | return attributes |
0 commit comments