Skip to content

KeyError x-datadog-trace-id when DD_ENABLE_TRACE is false #332

@salehshehata-RL

Description

@salehshehata-RL

Expected Behavior

The datadog datalayer doesn't try to get the correlation ids if tracing is off.

Actual Behavior

The datadog datalayer tries to get the correlation ids if tracing is off, and throws a KeyError.

Steps to Reproduce the Problem

  1. Create an aws lambda
  2. Set the DD_LAMBDA_HANDLER to the _lambda_function
  3. Set the lambda handler to datadog_lambda.handler.handler
  4. Set DD_ENABLE_TRACE to "false".

Specifications

  • Datadog Lambda Layer version: 4.66 & 4.72.0
  • Python version: 3.7, 3.9

Stacktrace

023-05-16 08:56:14 Traceback (most recent call last):
2023-05-16 08:56:14   File "/opt/python/lib/python3.9/site-packages/datadog_lambda/wrapper.py", line 234, in _before
2023-05-16 08:56:14     set_correlation_ids()
2023-05-16 08:56:14   File "/opt/python/lib/python3.9/site-packages/datadog_lambda/tracing.py", line 513, in set_correlation_ids
2023-05-16 08:56:14     span.trace_id = int(context[TraceHeader.TRACE_ID])
2023-05-16 08:56:14 KeyError: 'x-datadog-trace-id'

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions