Comments (3)
@connorbrinton Thanks for reporting this and including a small reproduction case. As you've discovered, the sampling code is complex. We'll look into this and see if we can figure out what's going on.
from dd-trace-py.
Hi @connorbrinton,
- "dropping trace ... with ... spans" is only logged if a span is unsampled (dropped) AND DD_TRACE_COMPUTE_STATS=True.
- If the reproduction is run with
DD_TRACE_COMPUTE_STATS=True
then we see this log message onfastapi.request
spans
- If the reproduction is run with
- Sampling decisions are currently made by the first span in a trace. Sampling on resource name on root spans are not supported. This allows us to avoid generating partial traces.
- If
allow_false == True
then the span will be kept no matter what. This field is used to override sampling decisions for RateSamplers. By default the tracer uses a DatadogSampler (which is not a rate sampler) so this field is irrelevant to most users.allow_false
is a confusing argument that maintains legacy behavior. We are looking into removing it.
I apologize for the confusion. Trace sampling is a confusing feature that we are actively trying to simplify. By default the tracer makes a sampling decision by setting the _sampling_priority_v1
tag on spans and then all spans are sent to the Datadog agent. If _sampling_priority_v1
equals 2 or 1 the span is kept by the agent and if _sampling_priority_v1
is equal to 0 or -1 the agent will drop the span. Below is a span generated by hitting the /ready
endpoint in your reproduction. In this payload you can see '_sampling_priority_v1': -1
is set so spans are being dropped.
finishing span name='fastapi.request' id=364833566968571663 trace_id=135397972624940070559008041258285491854 parent_id=None service='fastapi' resource='GET /readyz' type='web' start=1708962676.4127822 end=1708962676.4250052 duration=0.012223 error=0 tags={'_dd.base_service': '', '_dd.p.dm': '-3', '_dd.p.tid': '65dcb37400000000', 'asgi.spec_version': '2.3', 'asgi.version': '3.0', 'component': 'fastapi', 'http.method': 'GET', 'http.route': '/readyz', 'http.status_code': '204', 'http.url': 'http://localhost:8000/readyz', 'http.useragent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36', 'http.version': '1.1', 'language': 'python', 'runtime-id': '31c4c041e9e14cbc92f4fd47e4104cd0', 'span.kind': 'server'} metrics={'_dd.rule_psr': 0.0, '_dd.top_level': 1, '_dd.tracer_kr': 1.0, '_sampling_priority_v1': -1, 'process_id': 60174} (enabled:True)
creating new intake connection to http://localhost:8126 with timeout 2
Sending request: PUT v0.5/traces {'Datadog-Meta-Lang': 'python', 'Datadog-Meta-Lang-Version': '3.10.5', 'Datadog-Meta-Lang-Interpreter': 'CPython', 'Datadog-Meta-Tracer-Version': '2.5.2', 'Datadog-Client-Computed-Top-Level': 'yes', 'Content-Type': 'application/msgpack', 'X-Datadog-Trace-Count': '1'}
Based on my investigation sampling appears to be working as expected in the tracer, however there could be an issue in the datadog agent. I would reccomend opening an issue here and our support team can help investigate the root cause: https://www.datadoghq.com/support/
from dd-trace-py.
Feel free to reopen if you have any further questions and thanks again for bringing this to our attention.
from dd-trace-py.
Related Issues (20)
- Support celery task shadow name HOT 1
- gevent could not work with ddtrace in pytest HOT 5
- if i only use Profiler should i import ddtrace.auto before gevent.monkey.patch_all? HOT 4
- why memory allocation profiler could not get real thread name? HOT 3
- Add `trace_connect` for pymysql HOT 3
- Compatibility Issue with pytest 8.0 Collection Changes HOT 2
- DD_RUNTIME_METRICS_ENABLED environment variable not documented HOT 1
- Got object of type 'dict' instead of a code object during stack unwinding
- Error installing ddtrace 1.18.3 with poetry 1.4.2 HOT 2
- Unable to build package file mapping; TypeError: expected str, bytes or os.PathLike object, not Path HOT 1
- NameError: name 'telemetry' is not defined
- ddtrace versions 2.2.0 and above increase the duration of "django.request" HOT 10
- pytest-xdist + coverage + intelligent test runner does not work HOT 1
- CI Visibility: source code integration file path incorrect when not running tests from repo root
- AttributeError: 'dict' object has no attribute '__name__' HOT 2
- `inspect.formatargspec()` import error for Python 3.12 on AWS Lambda HOT 2
- uWSGI Segmentation Fault HOT 10
- ddtrace failure if pytest `no:legacypath` is set HOT 5
- Here's my first simple attempt at replicating this behavior. It makes a bunch of requests to a basic django ASGI app and averages the time they take. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dd-trace-py.