|
1 | | -<!--- Hugo front matter used to generate the website version of this page: |
2 | | -linkTitle: Probability Sampling |
3 | | ----> |
4 | | - |
5 | 1 | # TraceState: Probability Sampling |
6 | 2 |
|
7 | | -**Status**: [Development](../document-status.md) |
8 | | - |
9 | | -<details> |
10 | | -<summary>Table of Contents</summary> |
11 | | - |
12 | | -<!-- toc --> |
13 | | - |
14 | | -- [Overview](#overview) |
15 | | - * [Definitions](#definitions) |
16 | | - + [Sampling](#sampling) |
17 | | - + [Adjusted count](#adjusted-count) |
18 | | - + [Sampler](#sampler) |
19 | | - + [Parent-based sampler](#parent-based-sampler) |
20 | | - + [Probability sampler](#probability-sampler) |
21 | | - + [Consistent probability sampler](#consistent-probability-sampler) |
22 | | - + [Trace completeness](#trace-completeness) |
23 | | - + [Non-probability sampler](#non-probability-sampler) |
24 | | - + [Always-on consistent probability sampler](#always-on-consistent-probability-sampler) |
25 | | - + [Always-off sampler](#always-off-sampler) |
26 | | -- [Consistent Probability sampling](#consistent-probability-sampling) |
27 | | - * [Conformance](#conformance) |
28 | | - * [Completeness guarantee](#completeness-guarantee) |
29 | | - * [Context invariants](#context-invariants) |
30 | | - + [Sampled flag](#sampled-flag) |
31 | | - - [Requirement: Inconsistent p-values are unset](#requirement-inconsistent-p-values-are-unset) |
32 | | - + [P-value](#p-value) |
33 | | - - [Requirement: Out-of-range p-values are unset](#requirement-out-of-range-p-values-are-unset) |
34 | | - + [R-value](#r-value) |
35 | | - - [Requirement: Out-of-range r-values unset both p and r](#requirement-out-of-range-r-values-unset-both-p-and-r) |
36 | | - - [Requirement: R-value is generated with the correct probabilities](#requirement-r-value-is-generated-with-the-correct-probabilities) |
37 | | - + [Examples: Context invariants](#examples-context-invariants) |
38 | | - - [Example: Probability sampled context](#example-probability-sampled-context) |
39 | | - - [Example: Probability unsampled](#example-probability-unsampled) |
40 | | - * [Samplers](#samplers) |
41 | | - + [ParentConsistentProbabilityBased sampler](#parentconsistentprobabilitybased-sampler) |
42 | | - - [Requirement: ParentConsistentProbabilityBased API](#requirement-parentconsistentprobabilitybased-api) |
43 | | - - [Requirement: ParentConsistentProbabilityBased does not modify valid tracestate](#requirement-parentconsistentprobabilitybased-does-not-modify-valid-tracestate) |
44 | | - - [Requirement: ParentConsistentProbabilityBased calls the configured root sampler for root spans](#requirement-parentconsistentprobabilitybased-calls-the-configured-root-sampler-for-root-spans) |
45 | | - - [Requirement: ParentConsistentProbabilityBased respects the sampled flag for non-root spans](#requirement-parentconsistentprobabilitybased-respects-the-sampled-flag-for-non-root-spans) |
46 | | - + [ConsistentProbabilityBased sampler](#consistentprobabilitybased-sampler) |
47 | | - - [Requirement: TraceIdRatioBased API compatibility](#requirement-traceidratiobased-api-compatibility) |
48 | | - - [Requirement: ConsistentProbabilityBased sampler sets r for root span](#requirement-consistentprobabilitybased-sampler-sets-r-for-root-span) |
49 | | - - [Requirement: ConsistentProbabilityBased sampler unsets p when not sampled](#requirement-consistentprobabilitybased-sampler-unsets-p-when-not-sampled) |
50 | | - - [Requirement: ConsistentProbabilityBased sampler sets p when sampled](#requirement-consistentprobabilitybased-sampler-sets-p-when-sampled) |
51 | | - - [Requirement: ConsistentProbabilityBased sampler records unbiased adjusted counts](#requirement-consistentprobabilitybased-sampler-records-unbiased-adjusted-counts) |
52 | | - - [Requirement: ConsistentProbabilityBased sampler sets r for non-root span](#requirement-consistentprobabilitybased-sampler-sets-r-for-non-root-span) |
53 | | - - [Requirement: ConsistentProbabilityBased sampler decides not to sample for probabilities less than 2**-62](#requirement-consistentprobabilitybased-sampler-decides-not-to-sample-for-probabilities-less-than-2-62) |
54 | | - + [Examples: Consistent probability samplers](#examples-consistent-probability-samplers) |
55 | | - - [Example: Setting R-value for a root span](#example-setting-r-value-for-a-root-span) |
56 | | - - [Example: Handling inconsistent P-value](#example-handling-inconsistent-p-value) |
57 | | - - [Example: Handling corrupt R-value](#example-handling-corrupt-r-value) |
58 | | - * [Composition rules](#composition-rules) |
59 | | - + [List of requirements](#list-of-requirements) |
60 | | - - [Requirement: Combining multiple sampling decisions using logical `or`](#requirement-combining-multiple-sampling-decisions-using-logical-or) |
61 | | - - [Requirement: Combine multiple consistent probability samplers using the minimum p-value](#requirement-combine-multiple-consistent-probability-samplers-using-the-minimum-p-value) |
62 | | - - [Requirement: Unset p when multiple consistent probability samplers decide not to sample](#requirement-unset-p-when-multiple-consistent-probability-samplers-decide-not-to-sample) |
63 | | - - [Requirement: Use probability sampler p-value when its decision to sample is combined with non-probability samplers](#requirement-use-probability-sampler-p-value-when-its-decision-to-sample-is-combined-with-non-probability-samplers) |
64 | | - - [Requirement: Use p-value 63 when a probability sampler decision not to sample is combined with a non-probability sampler decision to sample](#requirement-use-p-value-63-when-a-probability-sampler-decision-not-to-sample-is-combined-with-a-non-probability-sampler-decision-to-sample) |
65 | | - + [Examples: Composition](#examples-composition) |
66 | | - - [Example: Probability and non-probability sampler in a root context](#example-probability-and-non-probability-sampler-in-a-root-context) |
67 | | - - [Example: Two consistent probability samplers](#example-two-consistent-probability-samplers) |
68 | | - * [Producer and consumer recommendations](#producer-and-consumer-recommendations) |
69 | | - + [Trace producer: completeness](#trace-producer-completeness) |
70 | | - - [Recommendation: use non-descending power-of-two probabilities](#recommendation-use-non-descending-power-of-two-probabilities) |
71 | | - + [Trace producer: correctness](#trace-producer-correctness) |
72 | | - - [Recommendation: sampler delegation](#recommendation-sampler-delegation) |
73 | | - + [Trace producer: interoperability with `ParentBased` sampler](#trace-producer-interoperability-with-parentbased-sampler) |
74 | | - + [Trace producer: interoperability with `TraceIDRatioBased` sampler](#trace-producer-interoperability-with-traceidratiobased-sampler) |
75 | | - + [Trace consumer](#trace-consumer) |
76 | | - - [Recommendation: Recognize inconsistent r-values](#recommendation-recognize-inconsistent-r-values) |
77 | | - * [Appendix: Statistical test requirements](#appendix-statistical-test-requirements) |
78 | | - + [Test procedure: non-powers of two](#test-procedure-non-powers-of-two) |
79 | | - - [Requirement: Pass 12 non-power-of-two statistical tests](#requirement-pass-12-non-power-of-two-statistical-tests) |
80 | | - + [Test procedure: exact powers of two](#test-procedure-exact-powers-of-two) |
81 | | - - [Requirement: Pass 3 power-of-two statistical tests](#requirement-pass-3-power-of-two-statistical-tests) |
82 | | - + [Test implementation](#test-implementation) |
83 | | -- [Appendix](#appendix) |
84 | | - * [Methods for generating R-values](#methods-for-generating-r-values) |
85 | | - |
86 | | -<!-- tocstop --> |
87 | | - |
88 | | -</details> |
| 3 | +**Status**: Archived |
| 4 | + |
| 5 | +This document contains the final state of the old, experimental |
| 6 | +"tracestate probability sampling" specification. This specification is |
| 7 | +recorded as an OTEP so that we can remove it from the OpenTelemetry |
| 8 | +specification and still refer to it. |
| 9 | + |
| 10 | +Changes to the document made below, summarized: |
| 11 | + |
| 12 | +- Links to [`sdk.md`][SDK_SPEC]: references were general in nature, as the SDK |
| 13 | + specification was never updated to refer to this document; these |
| 14 | + links were updated to a current permalink to avoid breaking in the |
| 15 | + future. |
| 16 | +- Links to [`tracestate-handling.md`][TRACESTATE_HANDLING]: |
| 17 | + these links were updated to a version of the file that was current |
| 18 | + when this file was written, before |
| 19 | + [PR#4162](https://github.com/open-telemetry/opentelemetry-specification/pull/4162) |
| 20 | + added the new specification. |
| 21 | +- Remove the table of contents. |
| 22 | + |
| 23 | +[TRACESTATE_HANDLING]: https://github.com/open-telemetry/opentelemetry-specification/blob/ec3779c3d0044503a1ec |
| 24 | +[SDK_SPEC]: https://github.com/open-telemetry/opentelemetry-specification/blob/03e4ea2748e18e63d1e00e58e373ca55768fb1b0/specification/trace/tracestate-handling.md |
89 | 25 |
|
90 | 26 | ## Overview |
91 | 27 |
|
@@ -256,7 +192,7 @@ values via the context, termed "p-value" and "r-value". |
256 | 192 |
|
257 | 193 | Both fields are propagated via the OpenTelemetry `tracestate` under |
258 | 194 | the `ot` vendor tag using the rules for [tracestate |
259 | | -handling](tracestate-handling.md). Both fields are represented as |
| 195 | +specification][TRACESTATE_HANDLING]. Both fields are represented as |
260 | 196 | unsigned decimal integers requiring at most 6 bits of information. |
261 | 197 |
|
262 | 198 | This sampling scheme selects items from among a fixed set of 63 |
@@ -326,7 +262,7 @@ information: the TraceId, the SpanId, and the trace flags. The |
326 | 262 | `sampled` trace flag has been defined by W3C to signal an intent to |
327 | 263 | sample the context. |
328 | 264 |
|
329 | | -The [Sampler API](sdk.md#sampler) is responsible for setting the |
| 265 | +The [Sampler API][SDK_SPEC#sampler] is responsible for setting the |
330 | 266 | `sampled` flag and the `tracestate`. |
331 | 267 |
|
332 | 268 | P-value and r-value are set in the OpenTelemetry `tracestate`, under |
@@ -478,7 +414,7 @@ unsampled context. |
478 | 414 | #### ParentConsistentProbabilityBased sampler |
479 | 415 |
|
480 | 416 | The `ParentConsistentProbabilityBased` sampler is meant as an optional |
481 | | -replacement for the [`ParentBased` Sampler](sdk.md#parentbased). It is |
| 417 | +replacement for the [`ParentBased` Sampler][SDK_SPEC#parentbased]. It is |
482 | 418 | required to first validate the `tracestate` and then respect the |
483 | 419 | `sampled` flag in the W3C traceparent. |
484 | 420 |
|
@@ -508,7 +444,7 @@ traceparent header. |
508 | 444 |
|
509 | 445 | The `ConsistentProbabilityBased` sampler is meant as an optional |
510 | 446 | replacement for the [`TraceIdRatioBased` |
511 | | -Sampler](sdk.md#traceidratiobased). In the case where it is used as a |
| 447 | +Sampler][SDK_SPEC#traceidratiobased]. In the case where it is used as a |
512 | 448 | root sampler, the `ConsistentProbabilityBased` sampler is required to |
513 | 449 | produce a valid `tracestate`. In the case where it is used in a |
514 | 450 | non-root context, it is required to validate the incoming `tracestate` |
@@ -764,7 +700,7 @@ the parent's sampled trace flag or the OpenTelemetry tracestate |
764 | 700 | r-value and p-value, as these decisions would lead to incorrect |
765 | 701 | adjusted counts. |
766 | 702 |
|
767 | | -For example, the built-in [`ParentBased` sampler](sdk.md#parentbased) |
| 703 | +For example, the built-in [`ParentBased` sampler][SDK_SPEC#parentbased] |
768 | 704 | supports configuring the delegated-to sampler based on whether the parent |
769 | 705 | context is remote or non-remote, sampled or unsampled. If a |
770 | 706 | `ParentBased` sampler delegates to a `ConsistentProbabilityBased` |
@@ -794,7 +730,7 @@ replacing `TraceIDRatioBased` samplers with conforming |
794 | 730 |
|
795 | 731 | #### Trace producer: interoperability with `TraceIDRatioBased` sampler |
796 | 732 |
|
797 | | -The [`TraceIDRatioBased` specification](sdk.md#traceidratiobased) |
| 733 | +The [`TraceIDRatioBased` specification][SDK_SPEC#traceidratiobased] |
798 | 734 | includes a RECOMMENDATION against being used for non-root spans |
799 | 735 | because it does not specify how to make the sampler decision |
800 | 736 | consistent across the trace. A `TraceIDRatioBased` sampler at the |
|
0 commit comments