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

fix(tracing): only apply rate limits when trace sample rules are set [except for ASM Standalone] [backport 2.14] #10941

Merged
merged 1 commit into from
Oct 4, 2024

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Oct 3, 2024

Backport afb6f2f from #10764 to 2.14.

Aligns the implementation of DD_TRACE_RATE_LIMIT with the java, dotnet and nodejs tracers: https://docs.datadoghq.com/tracing/trace_collection/library_config/java/#configuration-options.

Linked to: https://github.com/DataDog/dd-trace-py/pull/10830/files.

Changes

  • When tracing is enabled only apply DD_TRACE_RATE_LIMIT if a trace sampling rules or a trace sample rate is set. Otherwise trace rate limiting should be handled by the Datadog Agent.
  • [backwards compatibility] When ASM is enabled in standalone mode, rate limiting of 1 trace per second should be applied to ALL spans. All rate limited spans should have priority category of USER.
  • When spans are rate limited set _dd.limit_psr to the effective rate limit. Previously this tag was only set is DD_TRACE_RATE_LIMIT != 100. This restriction is not found in the spec.

Checklist

  • PR author has checked that all the criteria below are met
  • The PR description includes an overview of the change
  • The PR description articulates the motivation for the change
  • The change includes tests OR the PR description describes a testing strategy
  • The PR description notes risks associated with the change, if any
  • Newly-added code is easy to change
  • The change follows the library release note guidelines
  • The change includes or references documentation updates if necessary
  • Backport labels are set (if applicable)

Reviewer Checklist

  • Reviewer has checked that all the criteria below are met
  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Newly-added code is easy to change
  • Release note makes sense to a user of the library
  • If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment
  • Backport labels are set in a manner that is consistent with the release branch maintenance policy

…[except for ASM Standalone] (#10764)

Aligns the implementation of DD_TRACE_RATE_LIMIT with the java, dotnet
and nodejs tracers:
https://docs.datadoghq.com/tracing/trace_collection/library_config/java/#configuration-options.

Linked to: https://github.com/DataDog/dd-trace-py/pull/10830/files.

## Changes
- When tracing is enabled only apply DD_TRACE_RATE_LIMIT if a trace
sampling rules or a trace sample rate is set. Otherwise trace rate
limiting should be handled by the Datadog Agent.
- [backwards compatibility] When ASM is enabled in standalone mode, rate
limiting of 1 trace per second should be applied to ALL spans. All rate
limited spans should have priority category of USER.
- When spans are rate limited set `_dd.limit_psr` to the effective rate
limit. Previously this tag was only set is DD_TRACE_RATE_LIMIT != 100.
This restriction is not found in the spec.

## Checklist
- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

---------

Co-authored-by: Zachary Groves <32471391+ZStriker19@users.noreply.github.com>
Co-authored-by: erikayasuda <153395705+erikayasuda@users.noreply.github.com>
(cherry picked from commit afb6f2f)
@datadog-dd-trace-py-rkomorn
Copy link

Datadog Report

Branch report: backport-10764-to-2.14
Commit report: f976379
Test service: dd-trace-py

✅ 0 Failed, 1286 Passed, 0 Skipped, 35m 35.72s Total duration (43.93s time saved)

@pr-commenter
Copy link

pr-commenter bot commented Oct 4, 2024

Benchmarks

Benchmark execution time: 2024-10-04 00:06:37

Comparing candidate commit f976379 in PR branch backport-10764-to-2.14 with baseline commit 7fcc3a0 in branch 2.14.

Found 3 performance improvements and 0 performance regressions! Performance is the same for 353 metrics, 48 unstable metrics.

scenario:span-start-finish

  • 🟩 execution_time [-5.857ms; -5.365ms] or [-10.620%; -9.727%]

scenario:span-start-finish-telemetry

  • 🟩 execution_time [-6.123ms; -5.610ms] or [-10.816%; -9.909%]

scenario:span-start-finish-traceid128

  • 🟩 execution_time [-6.143ms; -5.482ms] or [-10.459%; -9.333%]

@mabdinur mabdinur closed this Oct 4, 2024
@mabdinur mabdinur reopened this Oct 4, 2024
Copy link
Contributor Author

github-actions bot commented Oct 4, 2024

CODEOWNERS have been resolved as:

releasenotes/notes/only-rate-limit-on-sampling-rules-6f807defa7d0f5f1.yaml  @DataDog/apm-python
ddtrace/_trace/tracer.py                                                @DataDog/apm-sdk-api-python
ddtrace/internal/rate_limiter.py                                        @DataDog/apm-core-python
ddtrace/sampler.py                                                      @DataDog/apm-sdk-api-python
ddtrace/settings/config.py                                              @DataDog/python-guild @DataDog/apm-sdk-api-python
docs/configuration.rst                                                  @DataDog/python-guild
tests/integration/test_sampling.py                                      @DataDog/apm-core-python
tests/snapshots/test_extended_sampling_glob_multi_rule.json             @DataDog/apm-python
tests/snapshots/test_sampling_with_default_sample_rate_1.json           @DataDog/apm-python
tests/snapshots/test_sampling_with_default_sample_rate_1_and_rule_1.json  @DataDog/apm-python
tests/snapshots/test_sampling_with_rate_limit_3.json                    @DataDog/apm-python
tests/snapshots/test_sampling_with_sample_rate_1_and_rate_limit_3_and_rule_0.json  @DataDog/apm-python
tests/snapshots/tests.integration.test_trace_stats.test_single_span_sampling[sampling_rule1].json  @DataDog/apm-python
tests/tracer/test_sampler.py                                            @DataDog/apm-sdk-api-python

@mabdinur mabdinur enabled auto-merge (squash) October 4, 2024 16:04
@mabdinur mabdinur merged commit 70a2ee1 into 2.14 Oct 4, 2024
639 of 641 checks passed
@mabdinur mabdinur deleted the backport-10764-to-2.14 branch October 4, 2024 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants