_telemetrysampler

command
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Command telemetrysampler is a reference post-trace sampler plugin that demonstrates well-behaved use of the sdk.HostAware telemetry façade. It implements both sdk.Sampler and sdk.HostAware: the engine calls UseHost once (per group, before the first Decide) and the sampler caches the Host to emit bounded metrics and structured logs from Decide.

Decision logic: keep all traces, but increment a "decisions" counter (with a "verdict" label set to "keep") and emit a sparse Info log so the host's rate-limiter and cardinality cap are exercised in a benign way. The sampler is nil-safe: if UseHost was never called (host is nil) Decide proceeds silently without emitting any telemetry.

Config JSON (from SamplerPlugin.config Struct):

{ "logEvery": 100 }

logEvery controls how many batches are processed between Info log emissions; the default is 100. 0 or a negative value is treated as 100.

Build it as a Go plugin (the leading-underscore directory is intentionally excluded from `go build ./...` and linters, exactly like the reference _example directory, yet remains buildable by explicit path):

CGO_ENABLED=1 go build -buildmode=plugin -trimpath \
  -o telemetrysampler.so \
  ./test/plugins/_telemetrysampler

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL