Change8

v4.0.0rc3

Breaking Changes
📦 datadog-sdkView on GitHub →
37 breaking4 features3 deprecations🔧 37 symbols

Summary

This major release introduces significant backwards-incompatible API changes, drops support for Python 3.8 and 32-bit Linux, and adds an OpenFeature provider implementation. Users should review breaking changes carefully, especially regarding removed APIs and updated Django tracing defaults.

⚠️ Breaking Changes

  • Support for ddtrace with Python 3.8 is removed. Use ddtrace 4.x with Python 3.9 or newer.
  • 32-bit linux is no longer supported. Please contact us if this blocks upgrading dd-trace-py.
  • Drops support for the `ddtrace.Pin` object with mongoengine. Mongoengine will now be supported only through the `pymongo` integration.
  • Removed deprecated entry points for the `pytest_benchmark` and `pytest_bdd` CI Visibility integrations. These plugins are now supported by the regular `pytest` integration.
  • Removed the deprecated `DD_DYNAMIC_INSTRUMENTATION_UPLOAD_FLUSH_INTERVAL` environment variable.
  • Removed the deprecated `DD_EXCEPTION_DEBUGGING_ENABLED` environment variable for exception replay.
  • `Span.set_tag_str` has been removed, use `Span.set_tag` instead.
  • `Span.set_struct_tag` has been removed.
  • `Span.get_struct_tag` has been removed.
  • `Span._pprint` has been removed.
  • `Span.finished` setter was removed, please use `Span.finish()` method instead.
  • `Tracer.on_start_span` method has been removed.
  • `Tracer.deregister_on_start_span` method has been removed.
  • `ddtrace.trace.Pin` has been removed.
  • `Span.finish_with_ancestors` was removed with no replacement.
  • The typing for `Span.set_tag` changed to `set_tag(key: str, value: Optional[str] = None) -> None`.
  • The typing for `Span.get_tag` changed to `get_tag(key: str) -> Optional[str]`.
  • The typing for `Span.set_tags` changed to `set_tags(tags: dict[str, str]) -> None`.
  • The typing for `Span.get_tags` changed to `get_tags() -> dict[str, str]`.
  • The typing for `Span.set_metric` changed to `set_metric(key: str, value: int | float) -> None`.
  • The typing for `Span.get_metric` changed to `get_metric(key: str) -> Optional[int | float]`.
  • The typing for `Span.set_metrics` changed to `set_metrics(metrics: Dict[str, int | float]) -> None`.
  • The typing for `Span.get_metrics` changed to `get_metrics() -> dict[str, int | float]`.
  • `Span.record_exception`'s `timestamp` and `escaped` parameters are removed.
  • Manual LLM Observability instrumentation methods (`LLMObs.annotate()`, `LLMObs.export_span()`, `LLMObs.submit_evaluation()`, `LLMObs.inject_distributed_headers()`, and `LLMObs.activate_distributed_headers()`) now raise exceptions instead of logging.
  • `LLMObs.submit_evaluation_for()` has been removed. Use `LLMObs.submit_evaluation()` instead. For migration, rename the function call and change the `span_context` argument to `span`.
  • The V1 stack profiler is removed. `DD_PROFILING_STACK_V2_ENABLED` is removed.
  • The deprecated `freezegun` integration is now removed.
  • The deprecated `opentracer` package is removed.
  • The `aioredis` integration has been removed.
  • The `google_generativeai` integration has been removed. Use the `google_genai` integration instead.
  • Streamed chat/completions will no longer compute token counts using `tiktoken`. Set `stream_options={\"include_usage\": True}` in the OpenAI request to guarantee accurate streamed token metrics.
  • Default tracing behavior for Django is upgraded to enable minimal tracing mode (`DD_DJANGO_TRACING_MINIMAL` defaults to `true`), disabling Django ORM, cache, and template instrumentation by default. To restore full instrumentation, set `DD_DJANGO_TRACING_MINIMAL=false` or enable specific features.
  • When `DD_DJANGO_INSTRUMENT_DATABASES=true`, database instrumentation now merges Django tags into driver spans instead of creating duplicate spans.
  • The `ddtrace.settings` package is removed. Use environment variables to adjust settings.
  • The deprecated `non_active_span` parameter to `HttpPropagator.inject` is removed.
  • The deprecated environment variable `DEFAULT_RUNTIME_METRICS_INTERVAL` is removed.

Migration Steps

  1. If using Python 3.8, upgrade to Python 3.9 or newer.
  2. If using mongoengine, be aware that direct `ddtrace.Pin` support is dropped; tracing relies on the `pymongo` integration.
  3. If using deprecated methods like `Span.set_tag_str`, switch to `Span.set_tag`.
  4. If using `LLMObs.submit_evaluation_for(...)`, rename the call to `LLMObs.submit_evaluation(...)` and rename the `span_context` argument to `span`.
  5. If relying on Django ORM/cache/template instrumentation, set `DD_DJANGO_TRACING_MINIMAL=false` or enable specific features via environment variables (`DD_DJANGO_INSTRUMENT_DATABASES=true`, etc.) if you require the old behavior.
  6. Stop using the `ddtrace.settings` package and configure settings via environment variables.
  7. If using streamed OpenAI requests and requiring accurate token counts, set `stream_options={\"include_usage\": True}` in the request.

✨ New Features

  • dd-trace-py now includes an OpenFeature provider implementation, enabling feature flag evaluation through the OpenFeature API.
  • API Security schema collection is now supported in AWS Lambda behind an Application Load Balancer or the Lambda Function URL service where the endpoint cannot be reliably known.
  • AppSec instrumentation for downstream request is now enabled by default for `urllib3` and `requests`.
  • Add support for `threading.RLock` (reentrant lock) profiling.

🔧 Affected Symbols

ddtrace.Pinpytest_benchmarkpytest_bddDD_DYNAMIC_INSTRUMENTATION_UPLOAD_FLUSH_INTERVALDD_EXCEPTION_DEBUGGING_ENABLEDSpan.set_tag_strSpan.set_tagSpan.set_struct_tagSpan.get_struct_tagSpan._pprintSpan.finishedSpan.finish()Tracer.on_start_spanTracer.deregister_on_start_spanSpan.record_exceptionLLMObs.annotate()LLMObs.export_span()LLMObs.submit_evaluation()LLMObs.inject_distributed_headers()LLMObs.activate_distributed_headers()LLMObs.submit_evaluation_for()DD_PROFILING_STACK_V2_ENABLEDfreezegun integrationopentracer packageaioredis integrationgoogle_generativeai integrationgoogle_genai integrationtiktokenDD_DJANGO_TRACING_MINIMALDD_DJANGO_INSTRUMENT_DATABASESDD_DJANGO_INSTRUMENT_CACHESDD_DJANGO_INSTRUMENT_TEMPLATESddtrace.settingsHttpPropagator.injectDEFAULT_RUNTIME_METRICS_INTERVALthreading.Lockthreading.RLock

⚡ Deprecations

  • Support for ddtrace with Python 3.9 is deprecated as Python 3.9 reached end-of-life.
  • Deprecates support for Tornado versions older than v6.1. Use Tornado v6.1 or later.
  • Deprecates programmatic tracing configuration via the ``ddtrace.contrib.tornado`` module. Configure tracing using environment variables and ``import ddtrace.auto`` instead.