Skip to content

Commit 7d0d13b

Browse files
committed
Clarify README
1 parent 175691c commit 7d0d13b

File tree

1 file changed

+13
-54
lines changed

1 file changed

+13
-54
lines changed

lib/samplers/README.md

Lines changed: 13 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Customers configure how they would like their transactions to be sampled under o
1414
- `remote_parent_sampled`: The sampler for when the upstream service has sampled the trace.
1515
- `remote_parent_not_sampled`: The sampler for when the upstream service has not sampled the trace.
1616

17-
NOTE: `distributed_tracing.sampler` only exists for backward compatiability and will be deprecated in favor of `distributed_tracing.sampler.full_granularity`. For now, `full_granularity` will take precedence over the old path.
17+
NOTE: `distributed_tracing.sampler` only exists for backward compatiability and may be deprecated in favor of `distributed_tracing.sampler.full_granularity`. For now, `full_granularity` will take precedence over the old path.
1818

1919
### Full Config in Accordance to Spec
2020

@@ -68,64 +68,23 @@ distributed_tracing:
6868

6969
## Solution
7070

71-
There are three sampler modes, each with three sampler sections, resulting in potentially nine different sampling decisions that the agent would have to support.
72-
73-
### Seperate Sampler Instances
74-
75-
We create a new `Sampler` instance for each sampler modes' section, resulting in 9 samplers. It would be something like (left-hand side represents the current instance's name if it exists):
71+
There are three sampler modes, each with three sampler sections, resulting in potentially nine different sampling decisions that the agent would have to support. We create a new `Sampler` instance (`AdaptiveSampler`, `AlwaysOnSampler`, `AlwaysOffSampler`, or `TraceIdRatioBasedSampler`, defined in this folder) for each of these sampler modes' sections.
7672

7773
`agent.sampler` would be defined as:
7874

79-
* `agent.sampler.full_granularity.root`
80-
* `agent.sampler.full_granularity.remote_parent_sampled`
81-
* `agent.sampler.full_granularity.remote_parent_not_sampled`
82-
* `agent.sampler.partial_granularity.root`
83-
* `agent.sampler.partial_granularity.remote_parent_sampled`
84-
* `agent.sampler.partial_granularity.remote_parent_not_sampled`
75+
* `agent.sampler.fullGranularity.root`
76+
* `agent.sampler.fullGranularity.remoteParentSampled`
77+
* `agent.sampler.fullGranularity.remoteParentNotSampled`
78+
* `agent.sampler.partialGranularity.root`
79+
* `agent.sampler.partialGranularity.remoteParentSampled`
80+
* `agent.sampler.partialGranularity.remoteParentNotSampled`
8581

86-
Will be deprecated, `full_granularity` takes precedence:
82+
These fields currently exist (before core tracing was implemented); `agent.sampler.fullGranularity.*` will take precedence over these fields:
8783

8884
* `agent.sampler.root`
89-
* `agent.sampler.remote_parent_sampled`
90-
* `agent.sampler.remote_parent_not_sampled`
85+
* `agent.sampler.remoteParentSampled`
86+
* `agent.sampler.remoteParentNotSampled`
9187

92-
`Transaction.prototype._calculatePriority` would be modified like:
88+
These samplers have a `applySamplingDecision({transaction})` function, which `Transaction` calls (in `lib/transaction/index.js`) to update its `sampled` field and therefore its `priority`.
9389

94-
```javascript
95-
...
96-
// Decide sampling from w3c data
97-
let full_sampler = null
98-
let partial_sampler = null
99-
if (traceparent.isSampled === true) {
100-
full_sampler = this.agent.sampler.full_granularity.remote_parent_sampled
101-
partial_sampler = this.agent.sampler.partial_granularity.remote_parent_sampled
102-
} else if (traceparent.isSampled === false) {
103-
full_sampler = this.agent.sampler.full_granularity.remote_parent_not_sampled
104-
partial_sampler = this.agent.sampler.partial_granularity.remote_parent_not_sampled
105-
}
106-
this._calculatePriority(full_sampler, partial_sampler, tracestate)
107-
...
108-
109-
110-
Transaction.prototype._calculatePriority = function _calculatePriority(full_sampler = null, partial_sampler = null, tracestate = null) {
111-
// full_sampler would be `agent.sampler.full_granularity`
112-
// partial_sampler would be `agent.sampler.partial_granularity`
113-
// root is default because there's only one place (see above) where
114-
// `remote_parent_sampled` and `remote_parent_not_sampled` is supplied instead
115-
if (!full_sampler){
116-
full_sampler = agent.sampler.full_granularity.root
117-
}
118-
if (!parital_sampler){
119-
partial_sampler=agent.sampler.partial_sampler.root
120-
}
121-
122-
if (this.priority === null) {
123-
full_sampler.applySamplingDecision({ transaction: this, tracestate })
124-
125-
// If full_granularity does not sample, it goes to parital_granularity's sampling decision
126-
if(this.sampled = false){
127-
partial_sampler.applySamplingDecision({ transaction: this, tracestate })
128-
}
129-
}
130-
}
131-
```
90+
Unlike the other samplers, the `AdaptiveSampler` must share state with other `AdaptiveSamplers` with the same `sampling_target`, which complicates our seperate sampler instances approach. This will be fixed shortly, and this document will be updated to describe that solution.

0 commit comments

Comments
 (0)