Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
sentrivana committed Nov 22, 2024
1 parent a9b4d47 commit 42aed98
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions sentry_sdk/integrations/aws_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def sentry_handler(aws_event, aws_context, *args, **kwargs):
"aws_event": aws_event,
"aws_context": aws_context,
},
attributes=_prepopulate_attributes(aws_event, aws_context),
):
try:
return handler(aws_event, aws_context, *args, **kwargs)
Expand Down Expand Up @@ -457,3 +458,29 @@ def _event_from_error_json(error_json):
} # type: Event

return event


EVENT_TO_ATTRIBUTES = {
"httpMethod": "http.request.method",
"queryStringParameters": "url.query",
# url
# headers
}

CONTEXT_TO_ATTRIBUTES = {
"function_name": "faas.name",
}


def _prepopulate_attributes(aws_event, aws_context):
attributes = {}

for prop, attr in EVENT_TO_ATTRIBUTES.items():
if getattr(aws_event, prop, None) is not None:
attributes[attr] = getattr(aws_event, prop)

for prop, attr in CONTEXT_TO_ATTRIBUTES.items():
if getattr(aws_context, prop, None) is not None:
attributes[attr] = getattr(aws_context, prop)

return attributes

0 comments on commit 42aed98

Please sign in to comment.