@@ -358,9 +358,10 @@ Priority sampling
358358Priority sampling consists in deciding if a trace will be kept by using a `priority ` attribute that will be propagated
359359for distributed traces. Its value gives indication to the Agent and to the backend on how important the trace is.
360360
361- - 0: Don't keep the trace.
362- - 1: The sampler automatically decided to keep the trace.
363- - 2: The user asked the keep the trace.
361+ The sampler can set the priority to the following values::
362+
363+ - `AUTO_REJECT `: the sampler automatically decided to reject the trace
364+ - `AUTO_KEEP `: the sampler automatically decided to keep the trace
364365
365366For now, priority sampling is disabled by default. Enabling it ensures that your sampled distributed traces will be complete.
366367To enable the priority sampling::
@@ -370,15 +371,29 @@ To enable the priority sampling::
370371Once enabled, the sampler will automatically assign a priority of 0 or 1 to traces, depending on their service and volume.
371372
372373You can also set this priority manually to either drop a non-interesting trace or to keep an important one.
373- For that, set the `context.sampling_priority ` to 0 or 2. It has to be done before any context propagation (fork, RPC calls)
374- to be effective::
374+ For that, set the `context.sampling_priority ` to -1 or 2.
375+
376+ - `USER_REJECT `: the user asked to reject the trace
377+ - `USER_KEEP `: the user asked to keep the trace
378+
379+ When not using distributed tracing, you may change the priority at any time,
380+ as long as the trace is not finished yet.
381+ But it has to be done before any context propagation (fork, RPC calls) to be effective in a distributed context.
382+ Changing the priority after context has been propagated causes different parts of a distributed trace
383+ to use different priorities. Some parts might be kept, some parts might be rejected,
384+ and this can cause the trace to be partially stored and remain incomplete.
385+
386+ If you change the priority, we recommend you do it as soon as possible, when the root span has just been created.
387+
388+
389+ from ddtrace.ext.priority import USER_REJECT, USER_KEEP
375390
376391 context = tracer.context_provider.active()
377392 # Indicate to not keep the trace
378- context.sampling_priority = 0
393+ context.sampling_priority = USER_REJECT
379394
380395 # Indicate to keep the trace
381- span.context.sampling_priority = 2
396+ span.context.sampling_priority = USER_KEEP
382397
383398
384399Pre-sampling
@@ -586,4 +601,3 @@ Indices and tables
586601* :ref: `genindex `
587602* :ref: `modindex `
588603* :ref: `search `
589-
0 commit comments