forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
1,113 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package config | ||
|
||
import ( | ||
"time" | ||
|
||
"go.opentelemetry.io/collector/config/configmodels" | ||
) | ||
|
||
// PolicyType indicates the type of sampling policy. | ||
type PolicyType string | ||
|
||
const ( | ||
// AlwaysSample samples all traces, typically used for debugging. | ||
AlwaysSample PolicyType = "always_sample" | ||
// 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" | ||
// StringAttribute sample traces that a attribute, of type string, matching | ||
// one of the listed values. | ||
StringAttribute PolicyType = "string_attribute" | ||
// RateLimiting allows all traces until the specified limits are satisfied. | ||
RateLimiting PolicyType = "rate_limiting" | ||
// Properties allows all traces that conform to specified properties. | ||
Properties PolicyType = "properties" | ||
// Cascading provides ability to specify several rules organized by priority an with ingestion budget | ||
Cascading PolicyType = "cascading" | ||
) | ||
|
||
// PolicyCfg holds the common configuration to all policies. | ||
type PolicyCfg struct { | ||
// Name given to the instance of the policy to make easy to identify it in metrics and logs. | ||
Name string `mapstructure:"name"` | ||
// Type of the policy this will be used to match the proper configuration of the policy. | ||
Type PolicyType `mapstructure:"type"` | ||
// Configs for numeric attribute filter sampling policy evaluator. | ||
NumericAttributeCfg NumericAttributeCfg `mapstructure:"numeric_attribute"` | ||
// Configs for string attribute filter sampling policy evaluator. | ||
StringAttributeCfg StringAttributeCfg `mapstructure:"string_attribute"` | ||
// Configs for rate limiting filter sampling policy evaluator. | ||
RateLimitingCfg RateLimitingCfg `mapstructure:"rate_limiting"` | ||
// Configs for properties sampling policy evaluator. | ||
PropertiesCfg PropertiesCfg `mapstructure:"properties"` | ||
// SpansPerSecond specifies the total budget that should never be exceeded for cascading rule | ||
SpansPerSecond int64 `mapstructure:"spans_per_second"` | ||
// Rules provide a list of prioritized rules for filling the budgets | ||
Rules []CascadingRuleCfg `mapstructure:"rules"` | ||
} | ||
|
||
// CascadingRuleCfg holds specification of a given rule and its budget | ||
type CascadingRuleCfg struct { | ||
// Name, as simple as that | ||
Name string `mapstructure:"name"` | ||
// SpansPerSecond specifies the budget available for cascading policy rule | ||
SpansPerSecond int64 `mapstructure:"spans_per_second"` | ||
// Configs for numeric attribute filter sampling policy evaluator. | ||
NumericAttributeCfg *NumericAttributeCfg `mapstructure:"numeric_attribute"` | ||
// Configs for string attribute filter sampling policy evaluator. | ||
StringAttributeCfg *StringAttributeCfg `mapstructure:"string_attribute"` | ||
// Configs for properties sampling policy evaluator. | ||
PropertiesCfg *PropertiesCfg `mapstructure:"properties"` | ||
} | ||
|
||
// PropertiesCfg holds the configurable settings to create a duration filter | ||
type PropertiesCfg struct { | ||
// NamePattern (optional) describes a regular expression that must be met by any span operation name. | ||
NamePattern *string `mapstructure:"name_pattern"` | ||
// MinDurationMicros (optional) is the minimum duration of trace to be considered a match. | ||
MinDurationMicros *int64 `mapstructure:"min_duration_micros"` | ||
// MinNumberOfSpans (optional) is the minimum number spans that must be present in a matching trace. | ||
MinNumberOfSpans *int `mapstructure:"min_number_of_spans"` | ||
} | ||
|
||
// NumericAttributeCfg holds the configurable settings to create a numeric attribute filter | ||
// sampling policy evaluator. | ||
type NumericAttributeCfg struct { | ||
// Tag that the filter is going to be matching against. | ||
Key string `mapstructure:"key"` | ||
// MinValue is the minimum value of the attribute to be considered a match. | ||
MinValue int64 `mapstructure:"min_value"` | ||
// MaxValue is the maximum value of the attribute to be considered a match. | ||
MaxValue int64 `mapstructure:"max_value"` | ||
} | ||
|
||
// StringAttributeCfg holds the configurable settings to create a string attribute filter | ||
// sampling policy evaluator. | ||
type StringAttributeCfg struct { | ||
// Tag that the filter is going to be matching against. | ||
Key string `mapstructure:"key"` | ||
// Values is the set of attribute values that if any is equal to the actual attribute value to be considered a match. | ||
Values []string `mapstructure:"values"` | ||
} | ||
|
||
// RateLimitingCfg holds the configurable settings to create a rate limiting | ||
// sampling policy evaluator. | ||
type RateLimitingCfg struct { | ||
// SpansPerSecond sets the limit on the maximum nuber of spans that can be processed each second. | ||
SpansPerSecond int64 `mapstructure:"spans_per_second"` | ||
} | ||
|
||
// Config holds the configuration for tail-based sampling. | ||
type Config struct { | ||
configmodels.ProcessorSettings `mapstructure:",squash"` | ||
// DecisionWait is the desired wait time from the arrival of the first span of | ||
// trace until the decision about sampling it or not is evaluated. | ||
DecisionWait time.Duration `mapstructure:"decision_wait"` | ||
// NumTraces is the number of traces kept on memory. Typically most of the data | ||
// of a trace is released after a sampling decision is taken. | ||
NumTraces uint64 `mapstructure:"num_traces"` | ||
// ExpectedNewTracesPerSec sets the expected number of new traces sending to the tail sampling processor | ||
// per second. This helps with allocating data structures with closer to actual usage size. | ||
ExpectedNewTracesPerSec uint64 `mapstructure:"expected_new_traces_per_sec"` | ||
// PolicyCfgs sets the tail-based sampling policy which makes a sampling decision | ||
// for a given trace when requested. | ||
PolicyCfgs []PolicyCfg `mapstructure:"policies"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.