MCPcopy Create free account
hub / github.com/cli/cli / WithSampleRate

Function WithSampleRate

internal/telemetry/telemetry.go:164–168  ·  view source on GitHub ↗

WithSampleRate allows setting a sample rate (0-100) for telemetry events. Rates 0 and 100 retain all events. Sampling is based on invocation ID, so an entire invocation will be included or excluded as a whole. This ensures that related events are not split between sampled and unsampled, which could

(rate int)

Source from the content-addressed store, hash-verified

162// Sampling is based on invocation ID, so an entire invocation will be included or excluded as a whole. This ensures that related events are not split between sampled and unsampled,
163// which could lead to incomplete data and incorrect assumptions.
164func WithSampleRate(rate int) telemetryServiceOption {
165 return func(s *telemetryServiceOpts) {
166 s.sampleRate = rate
167 }
168}
169
170// LogFlusher returns a flush function that writes telemetry payloads to the provided log writer. This is used for the "log" telemetry mode, which is intended for debugging and development.
171// When there are no events to report (for example the command opted out of telemetry, the user is on GHES, or no events were recorded), a "Telemetry payload: none" marker is written so that the absence of events is observable.

Calls

no outgoing calls