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

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
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/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: 238 ± 5 ms.

The average import time from base is: 245 ± 5 ms.

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

Import time breakdown

The following import paths have appeared:

ddtrace.auto 0.616 ms (0.26%)
ddtrace 0.616 ms (0.26%)
ddtrace.trace 0.616 ms (0.26%)
ddtrace._trace.filters 0.616 ms (0.26%)
ddtrace._trace.processor 0.616 ms (0.26%)
ddtrace._trace.sampler 0.616 ms (0.26%)
ddtrace._trace.span 0.616 ms (0.26%)
ddtrace._trace.sampling_rule 0.616 ms (0.26%)
ddtrace.internal.glob_matching 0.267 ms (0.11%)

The following import paths have disappeared:

ddtrace.auto 0.734 ms (0.31%)
ddtrace 0.734 ms (0.31%)
ddtrace.trace 0.734 ms (0.31%)
ddtrace._trace.filters 0.734 ms (0.31%)
ddtrace._trace.processor 0.734 ms (0.31%)
ddtrace._trace.sampler 0.734 ms (0.31%)
ddtrace._trace.span 0.734 ms (0.31%)
ddtrace.internal.sampling 0.734 ms (0.31%)
ddtrace._trace.sampling_rule 0.734 ms (0.31%)
ddtrace.internal.glob_matching 0.365 ms (0.15%)

The following import paths have grown:

ddtrace.auto 1.464 ms (0.61%)
ddtrace.bootstrap.sitecustomize 1.307 ms (0.55%)
ddtrace.bootstrap.preload 1.307 ms (0.55%)
ddtrace.internal.products 1.141 ms (0.48%)
importlib.metadata 0.931 ms (0.39%)
importlib.abc 0.857 ms (0.36%)
importlib.resources 0.857 ms (0.36%)
importlib.resources._legacy 0.857 ms (0.36%)
importlib.metadata._itertools 0.074 ms (0.03%)
multiprocessing 0.075 ms (0.03%)
multiprocessing.context 0.075 ms (0.03%)
ddtrace.internal.symbol_db.remoteconfig 0.071 ms (0.03%)
ddtrace.internal.symbol_db.symbols 0.071 ms (0.03%)
ddtrace.settings.symbol_db 0.071 ms (0.03%)
ddtrace.internal.remoteconfig.worker 0.063 ms (0.03%)
ddtrace.internal.runtime.runtime_metrics 0.096 ms (0.04%)
ddtrace.settings.profiling 0.070 ms (0.03%)
ddtrace.internal.datadog.profiling.stack_v2 0.070 ms (0.03%)
ddtrace.internal.datadog.profiling.stack_v2._stack_v2 0.070 ms (0.03%)
ddtrace 0.156 ms (0.07%)
ddtrace.trace 0.156 ms (0.07%)
ddtrace._trace.filters 0.156 ms (0.07%)
ddtrace._trace.processor 0.156 ms (0.07%)
ddtrace._trace.sampler 0.156 ms (0.07%)
ddtrace._trace.span 0.049 ms (0.02%)
ddtrace.internal.sampling 0.049 ms (0.02%)

The following import paths have shrunk:

ddtrace.auto 4.144 ms (1.74%)
ddtrace.bootstrap.sitecustomize 3.245 ms (1.36%)
ddtrace.bootstrap.preload 3.245 ms (1.36%)
ddtrace.internal.products 2.951 ms (1.24%)
importlib.metadata 1.036 ms (0.43%)
importlib.abc 1.036 ms (0.43%)
importlib.resources 0.070 ms (0.03%)
ddtrace.internal.remoteconfig.client 0.711 ms (0.30%)
ddtrace.internal.symbol_db.remoteconfig 0.202 ms (0.08%)
ddtrace.internal.symbol_db.symbols 0.202 ms (0.08%)
ddtrace.settings.dynamic_instrumentation 0.098 ms (0.04%)
multiprocessing 0.089 ms (0.04%)
multiprocessing.context 0.089 ms (0.04%)
multiprocessing.process 0.089 ms (0.04%)
ddtrace.settings.profiling 0.136 ms (0.06%)
ddtrace.vendor.psutil 0.023 ms (0.01%)
ddtrace.vendor.psutil._pslinux 0.023 ms (0.01%)
glob 0.023 ms (0.01%)
ddtrace.settings.crashtracker 0.115 ms (0.05%)
ddtrace.internal.flare.flare 0.043 ms (0.02%)
ddtrace 0.898 ms (0.38%)
ddtrace._logger 0.114 ms (0.05%)
logging 0.114 ms (0.05%)
traceback 0.114 ms (0.05%)
contextlib 0.114 ms (0.05%)
ddtrace.trace 0.100 ms (0.04%)
ddtrace._trace.filters 0.100 ms (0.04%)
ddtrace._trace.processor 0.100 ms (0.04%)
ddtrace._trace.sampler 0.100 ms (0.04%)
ddtrace._trace.span 0.100 ms (0.04%)

@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
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. Tracing Distributed Tracing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant