Skip to content

feat(go): Add explicit ForceSample marker to the span-kind sampler - #738

Draft
ccschmitz-launchdarkly wants to merge 1 commit into
mainfrom
chris/o11y-1880-force-sample-attribute
Draft

feat(go): Add explicit ForceSample marker to the span-kind sampler#738
ccschmitz-launchdarkly wants to merge 1 commit into
mainfrom
chris/o11y-1880-force-sample-attribute

Conversation

@ccschmitz-launchdarkly

@ccschmitz-launchdarkly ccschmitz-launchdarkly commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Adds launchdarkly.sampling.force and a ForceSample() span start option that the Go sampler honors for any span kind, so callers can say "always keep this span" without abusing SpanKind to mean it — the coupling that caused INC-241.

Groundwork for O11Y-1880; the consuming change lands in observability.

Two decisions worth a look:

  • The marker outranks the unsampled-parent drop from fix(go): Honor unsampled parent in span-kind sampler #722. That drop stops a child's kind from re-rolling a decision the trace already made; an explicit per-call marker is a deliberate statement. The paths that need it are leaf event spans whose payload lives in their own attributes, where orphaning is harmless but dropping loses data.
  • Only a genuine boolean true counts. OTel packs bool and int into the same numeric field, so Value.AsBool() alone reads Int(key, 1) as true — which would make the marker as easy to trip accidentally as the SpanKind it replaces. A test covers this.

The attribute stays on the exported span deliberately, so a server-side sampling rule can match it and dial every force-sampled span down without a deploy.

The dogfood tracer has no way to say "always keep this span" except by
setting a SpanKind the sampling map happens to map to 1.0. That coupling
caused INC-241: adding the correct Producer kind to kafka.submit raised
self-telemetry ~159x, which drove ingest autoscaling into its task cap and
exhausted subnet addresses and Postgres connections.

Add launchdarkly.sampling.force plus a ForceSample() span start option that
the sampler honors for any kind, so callers can express the intent directly
and SpanKind can go back to being purely semantic.

The marker outranks the unsampled-parent drop from #722: that drop exists to
stop a child's kind from silently re-rolling a decision the trace already
made, whereas an explicit per-call marker is a deliberate statement. The
paths that need it are leaf event spans carrying their payload in their own
attributes, where being orphaned is harmless but being dropped loses data.

Only a genuine boolean true counts. OTel packs bool and int into the same
numeric field, so Value.AsBool() alone would read Int(key, 1) as true and
make the marker as easy to trip by accident as the SpanKind it replaces.

The attribute is left on the exported span on purpose, so a server-side
sampling rule can match it and dial every force-sampled span back down
without a deploy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant