Path: blob/main/component/otelcol/extension/jaeger_remote_sampling/internal/jaegerremotesampling/config.go
4096 views
// Copyright The OpenTelemetry Authors1//2// Licensed under the Apache License, Version 2.0 (the "License");3// you may not use this file except in compliance with the License.4// You may obtain a copy of the License at5//6// http://www.apache.org/licenses/LICENSE-2.07//8// Unless required by applicable law or agreed to in writing, software9// distributed under the License is distributed on an "AS IS" BASIS,10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.11// See the License for the specific language governing permissions and12// limitations under the License.1314package jaegerremotesampling1516import (17"errors"18"time"1920"go.opentelemetry.io/collector/config"21"go.opentelemetry.io/collector/config/configgrpc"22"go.opentelemetry.io/collector/config/confighttp"23)2425var (26errTooManySources = errors.New("too many sources specified, has to be either 'file' or 'remote'")27errNoSources = errors.New("no sources specified, has to be either 'file' or 'remote'")28errAtLeastOneProtocol = errors.New("no protocols selected to serve the strategies, use 'grpc', 'http', or both")29)3031// Config has the configuration for the extension enabling the health check32// extension, used to report the health status of the service.33type Config struct {34config.ExtensionSettings `mapstructure:",squash"`35*confighttp.HTTPServerSettings `mapstructure:"http"`36*configgrpc.GRPCServerSettings `mapstructure:"grpc"`3738// Source configures the source for the strategies file. One of `remote` or `file` has to be specified.39Source Source `mapstructure:"source"`40}4142type Source struct {43// Remote defines the remote location for the file44Remote *configgrpc.GRPCClientSettings `mapstructure:"remote"`4546// File specifies a local file as the strategies source47File string `mapstructure:"file"`4849// ReloadInterval determines the periodicity to refresh the strategies50ReloadInterval time.Duration `mapstructure:"reload_interval"`5152// Contents is a field added for the Grafana Agent that allows dynamic mapping of sampling rules53// through flow54Contents string `mapstructure:"contents"`55}5657var _ config.Extension = (*Config)(nil)5859// Validate checks if the extension configuration is valid60func (cfg *Config) Validate() error {61if cfg.HTTPServerSettings == nil && cfg.GRPCServerSettings == nil {62return errAtLeastOneProtocol63}6465if cfg.Source.File != "" && cfg.Source.Remote != nil {66return errTooManySources67}6869if cfg.Source.File == "" && cfg.Source.Remote == nil {70return errNoSources71}7273return nil74}757677