Skip to content
Closed
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
14 changes: 14 additions & 0 deletions datadog_lambda/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,20 @@ def mark_trace_as_error_for_5xx_responses(context, status_code, span):
span.error = 1


def disable_instrumentation_telemetry_by_default():
"""
As of ddtrace v1.5 instrumentation telemetry collection is enabled by default.
This feature can add 5-10% overhead to the tracer and increase cold start.
Setting ``DD_INSTRUMENTATION_TELEMETRY_ENABLED=False`` will disable this feature.

Instrumentation Telemetry Collection is enabled when the first trace is sent to the
Agent. This feature must be disabled before tracing is configured.
"""

if "DD_INSTRUMENTATION_TELEMETRY_ENABLED" not in os.environ:
os.environ["DD_INSTRUMENTATION_TELEMETRY_ENABLED"] = "false"


class InferredSpanInfo(object):
BASE_NAME = "_inferred_span"
SYNCHRONICITY = f"{BASE_NAME}.synchronicity"
Expand Down
2 changes: 2 additions & 0 deletions datadog_lambda/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from datadog_lambda.patch import patch_all
from datadog_lambda.tracing import (
extract_dd_trace_context,
disable_instrumentation_telemetry_by_default,
create_dd_dummy_metadata_subsegment,
inject_correlation_ids,
dd_tracing_enabled,
Expand Down Expand Up @@ -136,6 +137,7 @@ def __init__(self, func):
os.environ["DD_REQUESTS_SERVICE_NAME"] = os.environ.get(
"DD_SERVICE", "aws.lambda"
)
disable_instrumentation_telemetry_by_default()
# Patch third-party libraries for tracing
patch_all()

Expand Down