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(sampling): add rc for trace sampling rules #8900

Merged
merged 44 commits into from
Apr 30, 2024

Conversation

ZStriker19
Copy link
Contributor

@ZStriker19 ZStriker19 commented Apr 8, 2024

This PR implements remote config for DD_TRACE_SAMPLING_RULES:

  1. Add the rc
  2. Add provenance which we parse from rc and use to give a new decision maker _dd.p.dm to either -11 for customer configuration or -12 for dynamic configuration.
  3. The most confusing part of this implementation takes place in tracer._on_global_config_update. Essentially implementing the logic for choosing the correct sample_rate and sampling_rules depending on rc input.

In addition to the sample_rate we already had I added one for sampling_rules and for the interaction between them. This PR also passes the newly added system-tests for this behavior.

Since this feature is in internal beta, there's no release note.

Checklist

  • Change(s) are motivated and described in the PR description
  • Testing strategy is described if automated tests are not included in the PR
  • Risks are described (performance impact, potential for breakage, maintainability)
  • Change is maintainable (easy to change, telemetry, documentation)
  • Library release note guidelines are followed or label changelog/no-changelog is set
  • Documentation is included (in-code, generated user docs, public corp docs)
  • Backport labels are set (if applicable)
  • If this PR changes the public interface, I've notified @DataDog/apm-tees.

Reviewer Checklist

  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Description motivates each change
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Change is maintainable (easy to change, telemetry, documentation)
  • Release note makes sense to a user of the library
  • 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

@ZStriker19 ZStriker19 added the changelog/no-changelog A changelog entry is not required for this PR. label Apr 16, 2024
@datadog-dd-trace-py-rkomorn
Copy link

datadog-dd-trace-py-rkomorn bot commented Apr 16, 2024

Datadog Report

Branch report: zachg/add_rcm_for_trace_sampling_rules
Commit report: 8d2f553
Test service: dd-trace-py

✅ 0 Failed, 131616 Passed, 42229 Skipped, 6h 2m 38.51s Total duration (4h 20m 5.62s time saved)
⌛ 1 Performance Regression

⌛ Performance Regressions vs Default Branch (1)

  • test_data_streams_default_context_propagation - test_kafka.py 1m 30s (+1m 26.03s, +2169%) - Details

@pr-commenter
Copy link

pr-commenter bot commented Apr 16, 2024

Benchmarks

Benchmark execution time: 2024-04-30 18:42:23

Comparing candidate commit 3fc5773 in PR branch zachg/add_rcm_for_trace_sampling_rules with baseline commit 815da75 in branch main.

Found 9 performance improvements and 10 performance regressions! Performance is the same for 182 metrics, 9 unstable metrics.

scenario:flasksimple-appsec-get

  • 🟥 execution_time [+198.033µs; +252.738µs] or [+3.151%; +4.021%]

scenario:httppropagationextract-full_t_id_datadog_headers

  • 🟩 max_rss_usage [-691.475KB; -435.334KB] or [-3.242%; -2.041%]

scenario:httppropagationextract-invalid_trace_id_header

  • 🟩 max_rss_usage [-900.591KB; -550.622KB] or [-4.262%; -2.606%]

scenario:httppropagationextract-valid_headers_all

  • 🟥 max_rss_usage [+595.031KB; +746.818KB] or [+2.883%; +3.618%]

scenario:httppropagationextract-wsgi_large_header_no_matches

  • 🟥 max_rss_usage [+572.634KB; +665.586KB] or [+2.767%; +3.216%]

scenario:httppropagationextract-wsgi_medium_header_no_matches

  • 🟥 max_rss_usage [+555.333KB; +643.567KB] or [+2.685%; +3.112%]

scenario:httppropagationextract-wsgi_valid_headers_basic

  • 🟩 max_rss_usage [-708.177KB; -635.720KB] or [-3.329%; -2.988%]

scenario:sethttpmeta-all-disabled

  • 🟩 max_rss_usage [-711.392KB; -622.675KB] or [-3.293%; -2.882%]

scenario:sethttpmeta-all-enabled

  • 🟩 max_rss_usage [-731.033KB; -655.872KB] or [-3.382%; -3.035%]

scenario:sethttpmeta-obfuscation-disabled

  • 🟥 max_rss_usage [+938.437KB; +1025.186KB] or [+4.528%; +4.946%]

scenario:sethttpmeta-obfuscation-regular-case-explicit-query

  • 🟥 max_rss_usage [+578.359KB; +653.308KB] or [+2.724%; +3.077%]

scenario:sethttpmeta-obfuscation-regular-case-implicit-query

  • 🟥 max_rss_usage [+942.299KB; +1018.866KB] or [+4.510%; +4.877%]

scenario:sethttpmeta-useragentvariant_exists_1

  • 🟩 max_rss_usage [-652.133KB; -580.353KB] or [-3.020%; -2.688%]

scenario:sethttpmeta-useragentvariant_exists_2

  • 🟩 max_rss_usage [-709.397KB; -628.766KB] or [-3.284%; -2.911%]

scenario:sethttpmeta-useragentvariant_exists_3

  • 🟩 max_rss_usage [-715.716KB; -637.193KB] or [-3.314%; -2.951%]

scenario:sethttpmeta-useragentvariant_not_exists_1

  • 🟥 max_rss_usage [+729.781KB; +807.857KB] or [+3.498%; +3.872%]

scenario:span-start-finish

  • 🟩 max_rss_usage [-718.886KB; -639.757KB] or [-3.370%; -2.999%]

scenario:tracer-large

  • 🟥 max_rss_usage [+703.732KB; +791.308KB] or [+3.238%; +3.641%]

scenario:tracer-small

  • 🟥 max_rss_usage [+744.536KB; +828.328KB] or [+3.613%; +4.020%]

@ZStriker19 ZStriker19 force-pushed the zachg/add_rcm_for_trace_sampling_rules branch from 1024978 to 51ab94d Compare April 17, 2024 17:46
@ZStriker19 ZStriker19 requested a review from marcotc April 18, 2024 16:31
@ZStriker19 ZStriker19 marked this pull request as ready for review April 22, 2024 15:29
@ZStriker19 ZStriker19 requested review from a team as code owners April 22, 2024 15:29
@ZStriker19 ZStriker19 force-pushed the zachg/add_rcm_for_trace_sampling_rules branch from de08f30 to 9e5fbf7 Compare April 23, 2024 11:22
@codecov-commenter
Copy link

codecov-commenter commented Apr 29, 2024

Codecov Report

Attention: Patch coverage is 9.70874% with 93 lines in your changes are missing coverage. Please review.

Project coverage is 6.58%. Comparing base (815da75) to head (fa806ca).
Report is 1 commits behind head on main.

Files Patch % Lines
ddtrace/settings/config.py 0.00% 26 Missing ⚠️
ddtrace/_trace/tracer.py 8.69% 21 Missing ⚠️
ddtrace/sampler.py 6.66% 14 Missing ⚠️
tests/internal/test_settings.py 0.00% 11 Missing ⚠️
tests/internal/remoteconfig/test_remoteconfig.py 0.00% 10 Missing ⚠️
ddtrace/internal/sampling.py 33.33% 6 Missing ⚠️
ddtrace/internal/constants.py 0.00% 3 Missing ⚠️
ddtrace/sampling_rule.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #8900       +/-   ##
===========================================
- Coverage   68.03%    6.58%   -61.45%     
===========================================
  Files        1266     1236       -30     
  Lines      119540   117846     -1694     
===========================================
- Hits        81328     7762    -73566     
- Misses      38212   110084    +71872     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ZStriker19 ZStriker19 marked this pull request as ready for review April 30, 2024 14:02
@ZStriker19 ZStriker19 enabled auto-merge (squash) April 30, 2024 14:07
tests/internal/remoteconfig/test_remoteconfig.py Outdated Show resolved Hide resolved
ddtrace/internal/sampling.py Outdated Show resolved Hide resolved
ddtrace/settings/config.py Outdated Show resolved Hide resolved
ddtrace/internal/sampling.py Outdated Show resolved Hide resolved
ddtrace/settings/config.py Outdated Show resolved Hide resolved
ddtrace/settings/config.py Show resolved Hide resolved
ddtrace/settings/config.py Outdated Show resolved Hide resolved
ddtrace/sampler.py Outdated Show resolved Hide resolved
ddtrace/_trace/tracer.py Show resolved Hide resolved
ddtrace/_trace/tracer.py Show resolved Hide resolved
@ZStriker19 ZStriker19 merged commit 97af079 into main Apr 30, 2024
149 of 156 checks passed
@ZStriker19 ZStriker19 deleted the zachg/add_rcm_for_trace_sampling_rules branch April 30, 2024 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/no-changelog A changelog entry is not required for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants