Skip to content

refactor(tracing): break span-sampling cycle #13061

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

Closed
wants to merge 4 commits into from

Conversation

P403n1x87
Copy link
Contributor

We break the cycle between the span object and the sampling logic by moving some methods and functions around

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

@P403n1x87 P403n1x87 added changelog/no-changelog A changelog entry is not required for this PR. Tracing Distributed Tracing labels Apr 4, 2025
Copy link
Contributor

github-actions bot commented Apr 4, 2025

CODEOWNERS have been resolved as:

ddtrace/_trace/processor/__init__.py                                    @DataDog/apm-sdk-api-python
ddtrace/_trace/sampler.py                                               @DataDog/apm-sdk-api-python
ddtrace/_trace/sampling_rule.py                                         @DataDog/apm-sdk-api-python
ddtrace/_trace/span.py                                                  @DataDog/apm-sdk-api-python
ddtrace/appsec/_trace_utils.py                                          @DataDog/asm-python
ddtrace/internal/ci_visibility/filters.py                               @DataDog/ci-app-libraries
ddtrace/internal/sampling.py                                            @DataDog/apm-sdk-api-python
ddtrace/propagation/http.py                                             @DataDog/apm-sdk-api-python
tests/integration/test_sampling.py                                      @DataDog/apm-core-python
tests/tracer/test_processors.py                                         @DataDog/apm-sdk-api-python
tests/tracer/test_sampler.py                                            @DataDog/apm-sdk-api-python
tests/tracer/test_single_span_sampling_rules.py                         @DataDog/apm-sdk-api-python

Copy link
Contributor

github-actions bot commented Apr 4, 2025

Bootstrap import analysis

Comparison of import times between this PR and base.

Summary

The average import time from this PR is: 237 ± 6 ms.

The average import time from base is: 235 ± 4 ms.

The import time difference between this PR and base is: 1.9 ± 0.2 ms.

Import time breakdown

The following import paths have appeared:

ddtrace.auto 0.629 ms (0.27%)
ddtrace 0.629 ms (0.27%)
ddtrace.trace 0.629 ms (0.27%)
ddtrace._trace.filters 0.629 ms (0.27%)
ddtrace._trace.processor 0.629 ms (0.27%)
ddtrace._trace.sampler 0.629 ms (0.27%)
ddtrace._trace.span 0.629 ms (0.27%)
ddtrace._trace.sampling_rule 0.629 ms (0.27%)
ddtrace.internal.glob_matching 0.264 ms (0.11%)

The following import paths have disappeared:

ddtrace.auto 0.719 ms (0.30%)
ddtrace 0.719 ms (0.30%)
ddtrace.trace 0.719 ms (0.30%)
ddtrace._trace.filters 0.719 ms (0.30%)
ddtrace._trace.processor 0.719 ms (0.30%)
ddtrace._trace.sampler 0.719 ms (0.30%)
ddtrace._trace.span 0.719 ms (0.30%)
ddtrace.internal.sampling 0.719 ms (0.30%)
ddtrace._trace.sampling_rule 0.719 ms (0.30%)
ddtrace.internal.glob_matching 0.274 ms (0.12%)

The following import paths have grown:

ddtrace.auto 0.471 ms (0.20%)
ddtrace.bootstrap.sitecustomize 0.317 ms (0.13%)
ddtrace.bootstrap.preload 0.317 ms (0.13%)
ddtrace.internal.products 0.317 ms (0.13%)
importlib.metadata 0.213 ms (0.09%)
importlib.metadata._meta 0.070 ms (0.03%)
ddtrace.internal.remoteconfig._connectors 0.104 ms (0.04%)
ctypes 0.104 ms (0.04%)
_ctypes 0.104 ms (0.04%)
ddtrace 0.154 ms (0.07%)
ddtrace.trace 0.154 ms (0.07%)
ddtrace._trace.filters 0.154 ms (0.07%)
ddtrace._trace.processor 0.154 ms (0.07%)
ddtrace._trace.sampler 0.154 ms (0.07%)
ddtrace._trace.span 0.154 ms (0.07%)
ddtrace.internal._rand 0.105 ms (0.04%)

The following import paths have shrunk:

ddtrace.auto 1.379 ms (0.58%)
ddtrace.bootstrap.sitecustomize 0.716 ms (0.30%)
ddtrace.bootstrap.preload 0.716 ms (0.30%)
ddtrace.internal.products 0.716 ms (0.30%)
ddtrace.internal.remoteconfig.client 0.558 ms (0.24%)
importlib.metadata 0.158 ms (0.07%)
csv 0.096 ms (0.04%)
importlib.metadata._collections 0.062 ms (0.03%)
ddtrace 0.663 ms (0.28%)

@P403n1x87 P403n1x87 force-pushed the refactor/span-sampling branch 2 times, most recently from c43a555 to 5249449 Compare April 4, 2025 10:08
We break the cycle between the span object and the sampling logic by
moving some methods and functions around
@P403n1x87 P403n1x87 force-pushed the refactor/span-sampling branch from 5249449 to 46cd1c9 Compare April 4, 2025 10:30
@pr-commenter
Copy link

pr-commenter bot commented Apr 15, 2025

Benchmarks

Benchmark execution time: 2025-04-15 15:45:02

Comparing candidate commit 758ae26 in PR branch refactor/span-sampling with baseline commit 70e052b in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 392 metrics, 2 unstable metrics.

@P403n1x87 P403n1x87 force-pushed the refactor/span-sampling branch from c727d5f to bb2ad1c Compare April 30, 2025 09:45
@P403n1x87 P403n1x87 force-pushed the refactor/span-sampling branch from bb2ad1c to 58a9859 Compare April 30, 2025 10:23
@github-actions github-actions bot added the stale label May 31, 2025
Copy link
Contributor

github-actions bot commented Jun 1, 2025

This pull request has been automatically closed after a period of inactivity.
After this much time, it will likely be easier to open a new pull request with the
same changes than to update this one from the base branch. Please comment or reopen
if you think this pull request was closed in error.

@github-actions github-actions bot closed this Jun 1, 2025
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. stale Tracing Distributed Tracing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant