MCPcopy
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. Events recorded with the Unsampled option will be sent regardless of the sample rate. Sampling is based on invocation ID, so an entire invocation will be included or excluded as a whole. This ensures that related events are no

(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.

Callers 2

MainFunction · 0.92
TestServiceSamplingFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestServiceSamplingFunction · 0.68