diff --git a/processor/tailsamplingprocessor/README.md b/processor/tailsamplingprocessor/README.md index c88f51892d55..b7b54bbf225b 100644 --- a/processor/tailsamplingprocessor/README.md +++ b/processor/tailsamplingprocessor/README.md @@ -29,6 +29,7 @@ The following configuration options are required: Multiple policies exist today and it is straight forward to add more. These include: - `always_sample`: Sample all traces - `latency`: Sample based on the duration of the trace. The duration is determined by looking at the earliest start time and latest end time, without taking into consideration what happened in between. +- `duration`: Sample based on the *bounded* duration of the trace. Otherwise identical to latency - `numeric_attribute`: Sample based on number attributes (resource and record) - `probabilistic`: Sample a percentage of traces. Read [a comparison with the Probabilistic Sampling Processor](#probabilistic-sampling-processor-compared-to-the-tail-sampling-processor-with-the-probabilistic-policy). - `status_code`: Sample based upon the status code (`OK`, `ERROR` or `UNSET`) @@ -78,6 +79,11 @@ processors: type: latency, latency: {threshold_ms: 5000} }, + { + name: test-policy-2a, + type: duration, + latency: {lower_bound_ms: 5000, upper_bound_ms: 10000} + }, { name: test-policy-3, type: numeric_attribute, diff --git a/processor/tailsamplingprocessor/config.go b/processor/tailsamplingprocessor/config.go index 91ae169fd015..e37c9da57e90 100644 --- a/processor/tailsamplingprocessor/config.go +++ b/processor/tailsamplingprocessor/config.go @@ -17,6 +17,8 @@ const ( AlwaysSample PolicyType = "always_sample" // Latency sample traces that are longer than a given threshold. Latency PolicyType = "latency" + // Duration sample traces that are longer than a given threshold. + Duration PolicyType = "duration" // NumericAttribute sample traces that have a given numeric attribute in a specified // range, e.g.: attribute "http.status_code" >= 399 and <= 999. NumericAttribute PolicyType = "numeric_attribute" @@ -54,6 +56,8 @@ type sharedPolicyCfg struct { Type PolicyType `mapstructure:"type"` // Configs for latency filter sampling policy evaluator. LatencyCfg LatencyCfg `mapstructure:"latency"` + // Configs for duration filter sampling policy evaluator. + DurationCfg DurationCfg `mapstructure:"duration"` // Configs for numeric attribute filter sampling policy evaluator. NumericAttributeCfg NumericAttributeCfg `mapstructure:"numeric_attribute"` // Configs for probabilistic sampling policy evaluator. @@ -130,6 +134,15 @@ type LatencyCfg struct { ThresholdMs int64 `mapstructure:"threshold_ms"` } +// DurationCfg holds the configurable settings to create a duration filter sampling policy +// evaluator, which is essentially a latency sampler with two bounds +type DurationCfg struct { + // Lower bound in milliseconds. + LowerDurationMs int64 `mapstructure:"lower_bound_ms"` + // Upper bound in milliseconds. + UpperDurationMs int64 `mapstructure:"upper_bound_ms"` +} + // NumericAttributeCfg holds the configurable settings to create a numeric attribute filter // sampling policy evaluator. type NumericAttributeCfg struct {