Skip to content

Commit

Permalink
Refine ParentBased sampler descirption
Browse files Browse the repository at this point in the history
  • Loading branch information
pellared authored Sep 27, 2023
1 parent 5817c07 commit 5847bd3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions content/en/docs/instrumentation/go/sampling.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ Other samplers include:
which samples a fraction of spans, based on the fraction given to the sampler.
If you set .5, half of all the spans are sampled.
- [`ParentBased`](https://pkg.go.dev/go.opentelemetry.io/otel/sdk/trace#ParentBased),
which behaves differently based on the incoming sampling decision.
`ParentBased` samples spans that have parents that were sampled, and doesn't
sample spans whose parents were not sampled.
is a sampler decorator which behaves differently, based on the parent of the

This comment has been minimized.

Copy link
@dashpole

dashpole Sep 27, 2023

Contributor

I prefer the term "composite" to "decorator"

This comment has been minimized.

Copy link
@pellared

pellared Sep 27, 2023

Author Member

But this is a decorator, not a composite😉

This comment has been minimized.

Copy link
@dashpole

dashpole Sep 27, 2023

Contributor

Neat. We should update the godocs for the ParentBased sampler in that case :)

This comment has been minimized.

Copy link
@MrAlias

MrAlias Sep 27, 2023

Contributor

Huh? We're still talking about Go right?

20230927_095247

Based on the definitions you provided, the parent based sampler is described as a composite.

This comment has been minimized.

Copy link
@pellared

pellared Sep 27, 2023

Author Member

The intent of a composite is to "compose" objects into tree structures to represent part-whole hierarchies.

What problems can the Composite design pattern solve? [...] A part-whole hierarchy should be represented as tree structure

ParentBased does not produce a tree. Composite aims to solve a different (but kind of similar) problem.
Another reference: https://sourcemaking.com/design_patterns/composite

The key feature of the ParentBased is how it changes the "behavior" of the wrapped sample. Another reference: https://sourcemaking.com/design_patterns/decorator. We decorate the existing sampler so that it handles the sampling based on the parent's span.

This comment has been minimized.

Copy link
@cartermp

cartermp Sep 27, 2023

Contributor

FWIW the spec describes it as a composite sampler, so I'd prefer to use that. From a functional programming standpoint, it's certainly a compositional system, too.

This comment has been minimized.

Copy link
@pellared
span. If the span has no parent, the decorated sampler is used to make
sampling decision based on the parent of the span. By default, `ParentBased`
samples spans that have parents that were sampled, and doesn't sample spans
whose parents were not sampled.

By default, the tracer provider uses a `ParentBased` sampler with the
`AlwaysSample` sampler.
Expand Down

0 comments on commit 5847bd3

Please sign in to comment.