//#region src/sampling/types.d.ts /** * The telemetry entry point a sampling rule can target. */ type SamplingKind = 'job' | 'command' | 'http'; /** * Context passed to sampling rules for background job executions. */ interface JobSamplingContext { kind: 'job'; system: string; name: string; queue?: string; jobId?: string; attempt?: number; } /** * Context passed to sampling rules for CLI command executions. */ interface CommandSamplingContext { kind: 'command'; name: string; } /** * Context passed to sampling rules for HTTP request executions. */ interface HttpSamplingContext { kind: 'http'; method: string; path: string; route?: string; } /** * Context passed to a Monocle sampling callback. */ type SamplingContext = JobSamplingContext | CommandSamplingContext | HttpSamplingContext; /** * Options for keeping unsampled traces when they end with an error. */ interface KeepErrorsOptions { /** * Maximum number of spans to buffer per trace before truncation metadata is added. */ maxSpans?: number; } /** * The base rule selected by a sampling callback. */ type SamplingRuleKind = 'default' | 'always' | 'never' | 'rate'; /** * Runtime representation of a sampling rule. */ interface SamplingRule { kind: SamplingRuleKind; rate?: number; errorMode?: 'keep'; maxSpans?: number; } /** * User callback that maps a telemetry entry point to a sampling rule. */ type SamplingConfig = (context: SamplingContext) => SamplingRule | undefined; /** * Internal decision produced after resolving a sampling rule. */ type SamplingDecision = { action: 'record'; } | { action: 'drop'; } | { action: 'buffer'; rule: SamplingRule; sampled: boolean; }; //#endregion export { CommandSamplingContext, HttpSamplingContext, JobSamplingContext, KeepErrorsOptions, SamplingConfig, SamplingContext, SamplingDecision, SamplingKind, SamplingRule, SamplingRuleKind };