Skip to content
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

chore(configurations): remove deprecated tracing env vars #12176

Open
wants to merge 8 commits into
base: 3.x-staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
63 changes: 11 additions & 52 deletions ddtrace/settings/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,8 @@ def __init__(self):

sample_rate = os.getenv("DD_TRACE_SAMPLE_RATE")
if sample_rate is not None:
deprecate(
"DD_TRACE_SAMPLE_RATE is deprecated",
message="Please use DD_TRACE_SAMPLING_RULES instead.",
removal_version="3.0.0",
log.error(
"DD_TRACE_SAMPLE_RATE configuration is not supported. Use DD_TRACE_SAMPLING_RULES instead.",
)

# Use a dict as underlying storing mechanism for integration configs
Expand Down Expand Up @@ -424,13 +422,9 @@ def __init__(self):
)
self._trace_api = _get_config("DD_TRACE_API_VERSION")
if self._trace_api == "v0.3":
deprecate(
"DD_TRACE_API_VERSION=v0.3 is deprecated",
message="Traces will be submitted to the v0.4/traces agent endpoint instead.",
removal_version="3.0.0",
category=DDTraceDeprecationWarning,
log.error(
"Setting DD_TRACE_API_VERSION to ``v0.3`` is not supported. The default ``v0.5`` format will be used.",
)
self._trace_api = "v0.4"
self._trace_writer_buffer_size = _get_config("DD_TRACE_WRITER_BUFFER_SIZE_BYTES", DEFAULT_BUFFER_SIZE, int)
self._trace_writer_payload_size = _get_config(
"DD_TRACE_WRITER_MAX_PAYLOAD_SIZE_BYTES", DEFAULT_MAX_PAYLOAD_SIZE, int
Expand All @@ -454,18 +448,8 @@ def __init__(self):

self._span_traceback_max_size = _get_config("DD_TRACE_SPAN_TRACEBACK_MAX_SIZE", 30, int)

# Master switch for turning on and off trace search by default
# this weird invocation of getenv is meant to read the DD_ANALYTICS_ENABLED
# legacy environment variable. It should be removed in the future
self._analytics_enabled = _get_config(["DD_TRACE_ANALYTICS_ENABLED", "DD_ANALYTICS_ENABLED"], False, asbool)
if self._analytics_enabled:
deprecate(
"Datadog App Analytics is deprecated and will be removed in a future version. "
"App Analytics can be enabled via DD_TRACE_ANALYTICS_ENABLED and DD_ANALYTICS_ENABLED "
"environment variables and ddtrace.config.analytics_enabled configuration. "
"These configurations will also be removed.",
category=DDTraceDeprecationWarning,
)
# DD_ANALYTICS_ENABLED is not longer supported, remove this functionatiy from all integrations in the future
self._analytics_enabled = False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the changes above, should we log that analytics_enabled is not supported?

self._client_ip_header = _get_config("DD_TRACE_CLIENT_IP_HEADER")
self._retrieve_client_ip = _get_config("DD_TRACE_CLIENT_IP_ENABLED", False, asbool)

Expand Down Expand Up @@ -512,15 +496,8 @@ def __init__(self):

self._128_bit_trace_id_enabled = _get_config("DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED", True, asbool)

self._128_bit_trace_id_logging_enabled = _get_config("DD_TRACE_128_BIT_TRACEID_LOGGING_ENABLED", False, asbool)
if self._128_bit_trace_id_logging_enabled:
deprecate(
"Using DD_TRACE_128_BIT_TRACEID_LOGGING_ENABLED is deprecated.",
message="Log injection format is now configured automatically.",
removal_version="3.0.0",
category=DDTraceDeprecationWarning,
)

# Disabling DD_TRACE_128_BIT_TRACEID_LOGGING_ENABLED is not supported. Remove this configuration in the future.
self._128_bit_trace_id_logging_enabled = True
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc: @mtoffl01

Not sure if we should pull this out into it's own PR. DD_TRACE_128_BIT_TRACEID_LOGGING_ENABLED configuration is being removed so we need to enable this functionality by default.

Maybe this could use it's own release note.

self._sampling_rules = _get_config("DD_SPAN_SAMPLING_RULES")
self._sampling_rules_file = _get_config("DD_SPAN_SAMPLING_RULES_FILE")

Expand Down Expand Up @@ -572,18 +549,7 @@ def __init__(self):
["DD_TRACE_COMPUTE_STATS", "DD_TRACE_STATS_COMPUTATION_ENABLED"], trace_compute_stats_default, asbool
)
self._data_streams_enabled = _get_config("DD_DATA_STREAMS_ENABLED", False, asbool)

legacy_client_tag_enabled = _get_config("DD_HTTP_CLIENT_TAG_QUERY_STRING")
if legacy_client_tag_enabled is None:
self._http_client_tag_query_string = _get_config("DD_TRACE_HTTP_CLIENT_TAG_QUERY_STRING", "true")
else:
deprecate(
"DD_HTTP_CLIENT_TAG_QUERY_STRING is deprecated",
message="Please use DD_TRACE_HTTP_CLIENT_TAG_QUERY_STRING instead.",
removal_version="3.0.0",
category=DDTraceDeprecationWarning,
)
self._http_client_tag_query_string = legacy_client_tag_enabled.lower()
self._http_client_tag_query_string = _get_config("DD_TRACE_HTTP_CLIENT_TAG_QUERY_STRING", "true")

dd_trace_obfuscation_query_string_regexp = _get_config(
"DD_TRACE_OBFUSCATION_QUERY_STRING_REGEXP", DD_TRACE_OBFUSCATION_QUERY_STRING_REGEXP_DEFAULT
Expand Down Expand Up @@ -613,15 +579,8 @@ def __init__(self):
# https://github.com/open-telemetry/opentelemetry-python/blob/v1.16.0/opentelemetry-api/src/opentelemetry/context/__init__.py#L53
os.environ["OTEL_PYTHON_CONTEXT"] = "ddcontextvars_context"
self._subscriptions = [] # type: List[Tuple[List[str], Callable[[Config, List[str]], None]]]
self._span_aggregator_rlock = _get_config("DD_TRACE_SPAN_AGGREGATOR_RLOCK", True, asbool)
if self._span_aggregator_rlock is False:
deprecate(
"DD_TRACE_SPAN_AGGREGATOR_RLOCK is deprecated",
message="Soon the ddtrace library will only support using threading.Rlock to "
"aggregate and encode span data. If you need to disable the re-entrant lock and "
"revert to using threading.Lock, please contact Datadog support.",
removal_version="3.0.0",
)
# Disabled Span Aggregator Rlock is not supported. Remove this configuration in the future
self._span_aggregator_rlock = True

self._trace_methods = _get_config("DD_TRACE_METHODS")

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
upgrade:
- |
configurations: Drops support for deprecated tracing configurations. The following configurations are no longer supported:
- DD_TRACE_SAMPLE_RATE, use DD_TRACE_SAMPLING_RULES instead.
- DD_TRACE_API_VERSION=v0.3, the default ``v0.5`` version is used instead.
- DD_ANALYTICS_ENABLED, Datadog Analytics is no longer supported.
- DD_TRACE_ANALYTICS_ENABLED, Datadog Analytics is no longer supported.
- DD_TRACE_128_BIT_TRACEID_LOGGING_ENABLED, this configuration can not be disabled.
- DD_HTTP_CLIENT_TAG_QUERY_STRING, DD_TRACE_HTTP_CLIENT_TAG_QUERY_STRING should be used instead.
- DD_TRACE_SPAN_AGGREGATOR_RLOCK, disabling the span aggregator rlock is no longer supported.
2 changes: 1 addition & 1 deletion tests/suitespec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ components:
- ddtrace/__init__.py
- ddtrace/py.typed
- ddtrace/version.py
- ddtrace/settings/config.py
- ddtrace/settings/_config.py
- src/native/*
datastreams:
- ddtrace/internal/datastreams/*
Expand Down
6 changes: 0 additions & 6 deletions tests/telemetry/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ def test_app_started_event(telemetry_writer, test_agent_session, mock_time):
{"name": "DD_SPAN_SAMPLING_RULES_FILE", "origin": "unknown", "value": None},
{"name": "DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED", "origin": "unknown", "value": True},
{"name": "DD_TRACE_AGENT_TIMEOUT_SECONDS", "origin": "unknown", "value": 2.0},
{"name": "DD_TRACE_ANALYTICS_ENABLED", "origin": "unknown", "value": False},
{"name": "DD_TRACE_API_VERSION", "origin": "unknown", "value": None},
{"name": "DD_TRACE_CLIENT_IP_ENABLED", "origin": "unknown", "value": None},
{"name": "DD_TRACE_COMPUTE_STATS", "origin": "unknown", "value": False},
Expand Down Expand Up @@ -225,7 +224,6 @@ def test_app_started_event_configuration_override(test_agent_session, run_python
env["DD_RUNTIME_METRICS_ENABLED"] = "True"
env["DD_SERVICE_MAPPING"] = "default_dd_service:remapped_dd_service"
env["DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED"] = "True"
env["DD_TRACE_ANALYTICS_ENABLED"] = "True"
env["DD_TRACE_CLIENT_IP_ENABLED"] = "True"
env["DD_TRACE_COMPUTE_STATS"] = "True"
env["DD_TRACE_DEBUG"] = "True"
Expand Down Expand Up @@ -356,7 +354,6 @@ def test_app_started_event_configuration_override(test_agent_session, run_python
{"name": "DD_EXCEPTION_REPLAY_CAPTURE_MAX_FRAMES", "origin": "default", "value": 8},
{"name": "DD_EXCEPTION_REPLAY_ENABLED", "origin": "env_var", "value": True},
{"name": "DD_EXPERIMENTAL_APPSEC_STANDALONE_ENABLED", "origin": "default", "value": False},
{"name": "DD_HTTP_CLIENT_TAG_QUERY_STRING", "origin": "default", "value": None},
{"name": "DD_IAST_DEDUPLICATION_ENABLED", "origin": "default", "value": True},
{"name": "DD_IAST_ENABLED", "origin": "default", "value": False},
{"name": "DD_IAST_MAX_CONCURRENT_REQUESTS", "origin": "default", "value": 2},
Expand Down Expand Up @@ -431,9 +428,7 @@ def test_app_started_event_configuration_override(test_agent_session, run_python
{"name": "DD_TESTING_RAISE", "origin": "env_var", "value": True},
{"name": "DD_TEST_SESSION_NAME", "origin": "default", "value": None},
{"name": "DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED", "origin": "env_var", "value": True},
{"name": "DD_TRACE_128_BIT_TRACEID_LOGGING_ENABLED", "origin": "default", "value": False},
{"name": "DD_TRACE_AGENT_TIMEOUT_SECONDS", "origin": "default", "value": 2.0},
{"name": "DD_TRACE_ANALYTICS_ENABLED", "origin": "env_var", "value": True},
{"name": "DD_TRACE_API_VERSION", "origin": "env_var", "value": "v0.5"},
{"name": "DD_TRACE_CLIENT_IP_ENABLED", "origin": "env_var", "value": True},
{"name": "DD_TRACE_CLIENT_IP_HEADER", "origin": "default", "value": None},
Expand Down Expand Up @@ -462,7 +457,6 @@ def test_app_started_event_configuration_override(test_agent_session, run_python
"origin": "env_var",
"value": '[{"sample_rate":1.0,"service":"xyz","name":"abc"}]',
},
{"name": "DD_TRACE_SPAN_AGGREGATOR_RLOCK", "origin": "default", "value": True},
{"name": "DD_TRACE_SPAN_TRACEBACK_MAX_SIZE", "origin": "default", "value": 30},
{"name": "DD_TRACE_STARTUP_LOGS", "origin": "env_var", "value": True},
{"name": "DD_TRACE_WRITER_BUFFER_SIZE_BYTES", "origin": "env_var", "value": 1000},
Expand Down
18 changes: 0 additions & 18 deletions tests/tracer/test_encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import json
import random
import string
import sys
import threading
from unittest import TestCase

Expand Down Expand Up @@ -870,20 +869,3 @@ def test_json_encoder_traces_bytes():
assert "\\x80span.a" == span_a["name"]
assert "\x80span.b" == span_b["name"]
assert "\x80span.b" == span_c["name"]


@pytest.mark.skipif(sys.version_info < (3, 8), reason="Python 3.7 deprecation warning")
@pytest.mark.subprocess(env={"DD_TRACE_API_VERSION": "v0.3"})
def test_v03_trace_api_deprecation():
import warnings

with warnings.catch_warnings(record=True) as warns:
warnings.simplefilter("always")
from ddtrace.trace import tracer

assert tracer._writer._api_version == "v0.4"
assert len(warns) == 1, warns
assert (
warns[0].message.args[0] == "DD_TRACE_API_VERSION=v0.3 is deprecated and will be "
"removed in version '3.0.0': Traces will be submitted to the v0.4/traces agent endpoint instead."
), warns[0].message
Loading