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: make span.sampled reference span.context.sampling_priority and deprecate it #8461

Merged
merged 29 commits into from
Feb 27, 2024

Conversation

ZStriker19
Copy link
Contributor

@ZStriker19 ZStriker19 commented Feb 20, 2024

With span.sampled being outdated, and no longer reliable as a way to tell if a span is actually being sampled, we make this change to make its value reference span.context.sampling_priority which is what actually matters when it comes to sampling. This deprecates span.sampled and removes its use internally, replacing it with checks for span.context.sampling_priority to mimic behavior.

If the value of span.context.sampling_priority, is None we know that sampling hasn't yet run, and then maintain the original behavior of span.sampled being True until sampling is run, if it's >0 we know that the span has been sampled, if <=0 we know the span has not been sampled.

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.
  • If change touches code that signs or publishes builds or packages, or handles credentials of any kind, I've requested a review from @DataDog/security-design-and-guidance.

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
Copy link
Contributor Author

Or do I make everything reference _sampling_priority_v1? and then deprecate span.sampled?

ddtrace/_trace/span.py Outdated Show resolved Hide resolved
ddtrace/_trace/span.py Outdated Show resolved Hide resolved
ZStriker19 and others added 3 commits February 20, 2024 13:03
Co-authored-by: Munir Abdinur <munir.abdinur@datadoghq.com>
Co-authored-by: Munir Abdinur <munir.abdinur@datadoghq.com>
@ZStriker19 ZStriker19 added the changelog/no-changelog A changelog entry is not required for this PR. label Feb 20, 2024
@ZStriker19 ZStriker19 marked this pull request as ready for review February 20, 2024 21:26
@ZStriker19 ZStriker19 requested a review from a team as a code owner February 20, 2024 21:26
@ZStriker19 ZStriker19 enabled auto-merge (squash) February 20, 2024 21:32
@datadog-dd-trace-py-rkomorn
Copy link

datadog-dd-trace-py-rkomorn bot commented Feb 20, 2024

Datadog Report

Branch report: zachg/have_sampled_reference_sampling_priority_v1
Commit report: 719ef33
Test service: dd-trace-py

✅ 0 Failed, 26960 Passed, 140954 Skipped, 2h 55m 23.33s Total duration (6h 12m 38.2s time saved)

Copy link
Collaborator

@emmettbutler emmettbutler left a comment

Choose a reason for hiding this comment

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

Want a review before fixing the test failures?

…mple) just set sampling_priority_v1 everywhere we set sampled
@ZStriker19
Copy link
Contributor Author

nope sorry, thought it was there, but realized a critical flaw.

@ZStriker19 ZStriker19 marked this pull request as draft February 21, 2024 20:22
auto-merge was automatically disabled February 21, 2024 20:22

Pull request was converted to draft

@pr-commenter
Copy link

pr-commenter bot commented Feb 22, 2024

Benchmarks

Benchmark execution time: 2024-02-27 20:00:44

Comparing candidate commit 4c88a54 in PR branch zachg/have_sampled_reference_sampling_priority_v1 with baseline commit acc0297 in branch main.

Found 3 performance improvements and 5 performance regressions! Performance is the same for 111 metrics, 9 unstable metrics.

scenario:coreapiscenario-context_with_data_no_listeners

  • 🟥 max_rss_usage [+705.416KB; +837.957KB] or [+2.412%; +2.866%]

scenario:coreapiscenario-core_dispatch_listeners

  • 🟥 max_rss_usage [+657.052KB; +819.556KB] or [+2.246%; +2.802%]

scenario:coreapiscenario-core_dispatch_no_listeners

  • 🟥 max_rss_usage [+680.495KB; +844.036KB] or [+2.329%; +2.889%]

scenario:coreapiscenario-set_item

  • 🟥 max_rss_usage [+611.161KB; +797.044KB] or [+2.091%; +2.727%]

scenario:httppropagationinject-ids_only

  • 🟩 max_rss_usage [-749.993KB; -654.526KB] or [-2.504%; -2.185%]

scenario:httppropagationinject-with_tags_max_size

  • 🟩 max_rss_usage [-757.150KB; -676.860KB] or [-2.525%; -2.257%]

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

  • 🟥 max_rss_usage [+603.832KB; +741.704KB] or [+2.024%; +2.486%]

scenario:sethttpmeta-useragentvariant_not_exists_2

  • 🟩 max_rss_usage [-999.950KB; -680.639KB] or [-3.290%; -2.239%]

ddtrace/_trace/span.py Outdated Show resolved Hide resolved
ddtrace/_trace/span.py Outdated Show resolved Hide resolved
ddtrace/_trace/span.py Outdated Show resolved Hide resolved
ddtrace/_trace/span.py Outdated Show resolved Hide resolved
@ZStriker19 ZStriker19 changed the title chore: make span.sampled reference span.context.sampling_priority chore: make span.sampled reference span.context.sampling_priority and deprecate it Feb 26, 2024
@ZStriker19 ZStriker19 force-pushed the zachg/have_sampled_reference_sampling_priority_v1 branch from c85a1a4 to 3f5c763 Compare February 26, 2024 21:46
@emmettbutler emmettbutler self-requested a review February 27, 2024 16:36
@mabdinur mabdinur enabled auto-merge (squash) February 27, 2024 19:09
Copy link
Contributor

@Yun-Kim Yun-Kim left a comment

Choose a reason for hiding this comment

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

LGTM for ml_obs 👍

@mabdinur mabdinur merged commit 81511c9 into main Feb 27, 2024
141 of 143 checks passed
@mabdinur mabdinur deleted the zachg/have_sampled_reference_sampling_priority_v1 branch February 27, 2024 21:17
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.

None yet

4 participants