Skip to content

catch xray subsegment creation exceptions #142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 26, 2021
Merged
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
19 changes: 13 additions & 6 deletions datadog_lambda/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,19 @@ def create_dd_dummy_metadata_subsegment(
tags into its metadata field, so the X-Ray trace can be converted to a Datadog
trace in the Datadog backend with the correct context.
"""
xray_recorder.begin_subsegment(XraySubsegment.NAME)
subsegment = xray_recorder.current_subsegment()
subsegment.put_metadata(
subsegment_metadata_key, subsegment_metadata_value, XraySubsegment.NAMESPACE
)
xray_recorder.end_subsegment()
try:
xray_recorder.begin_subsegment(XraySubsegment.NAME)
subsegment = xray_recorder.current_subsegment()
subsegment.put_metadata(
subsegment_metadata_key, subsegment_metadata_value, XraySubsegment.NAMESPACE
)
xray_recorder.end_subsegment()
except Exception as e:
logger.debug(
"failed to create dd dummy metadata subsegment with error %s",
e,
exc_info=True,
)


def extract_context_from_lambda_context(lambda_context):
Expand Down