config

package
v0.0.0-...-1215978 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDataset = "ds"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthConfiguration

type AuthConfiguration struct {
	SkipAuth bool
	Endpoint string `validate:"url"`
	Key      string
	Secret   string
	TenantId string
}

type Config

type Config interface {
	IsTest() bool
	// RegisterReloadCallback takes a name and a function that will be called
	// when the configuration is reloaded. This will happen infrequently. If
	// consumers of configuration set config values on startup, they should
	// check their values haven't changed and re-start anything that needs
	// restarting with the new values.
	RegisterReloadCallback(callback func())

	// GetListenAddr returns the address and port on which to listen for
	// incoming events
	GetListenAddr() (string, error)

	// GetPeerListenAddr returns the address and port on which to listen for
	// peer traffic
	GetPeerListenAddr() (string, error)

	// GetPeerListenAddr returns the address and port on which to listen for
	// GRPC peer traffic
	GetGRPCPeerListenAddr() (string, error)

	// GetCompressPeerCommunication will be true if tracing-proxy should compress
	// data before forwarding it to a peer.
	GetCompressPeerCommunication() bool

	// GetGRPCListenAddr returns the address and port on which to listen for
	// incoming events over gRPC
	GetGRPCListenAddr() (string, error)

	// GetPeers returns a list of other servers participating in this proxy cluster
	GetPeers() ([]string, error)

	GetPeerManagementType() (string, error)

	// GetPeerManagementStrategy returns the strategy specified for
	// Peer management.
	GetPeerManagementStrategy() (string, error)

	// GetRedisHost returns the address of a Redis instance to use for peer
	// management.
	GetRedisHost() (string, error)

	// GetRedisUsername returns the username of a Redis instance to use for peer
	// management.
	GetRedisUsername() (string, error)

	// GetRedisPassword returns the password of a Redis instance to use for peer
	// management.
	GetRedisPassword() (string, error)

	// GetRedisPrefix returns the prefix string used in the keys for peer
	// management.
	GetRedisPrefix() string

	// GetRedisDatabase returns the ID of the Redis database to use for peer management.
	GetRedisDatabase() int

	// GetUseTLS returns true when TLS must be enabled to dial the Redis instance to
	// use for peer management.
	GetUseTLS() (bool, error)

	// UseTLSInsecure returns true when certificate checks are disabled
	GetUseTLSInsecure() (bool, error)

	// GetOpsrampAPI returns the base URL (protocol, hostname, and port) of
	// the upstream Honeycomb API server
	GetOpsrampAPI() (string, error)

	// GetLoggingLevel returns the verbosity with which we should log
	GetLoggingLevel() (string, error)

	// GetSendDelay returns the number of seconds to pause after a trace is
	// complete before sending it, to allow stragglers to arrive
	GetSendDelay() (time.Duration, error)

	// GetBatchTimeout returns how often to send off batches in seconds
	GetBatchTimeout() time.Duration

	// GetTraceTimeout is how long to wait before sending a trace even if it's
	// not complete. This should be longer than the longest expected trace
	// duration.
	GetTraceTimeout() (time.Duration, error)

	// GetMaxBatchSize is the number of events to be included in the batch for sending
	GetMaxBatchSize() uint

	// GetThreshold is used to caliculate the apdex score
	GetThreshold() float64

	// GetLogsEnpoint is used to get endpoint for logs
	GetLogsEndpoint() string

	// Send Events as Logs
	GetSendEvents() bool

	// GetOtherConfig attempts to fill the passed in struct with the contents of
	// a subsection of the config.   This is used by optional configurations to
	// allow different implementations of necessary interfaces configure
	// themselves
	GetOtherConfig(name string, configStruct interface{}) error

	// GetCollectorType returns the type of the collector to use. Valid types
	// are in the collect package
	GetCollectorType() (string, error)

	// GetInMemCollectorCacheCapacity returns the config specific to the InMemCollector
	GetInMemCollectorCacheCapacity() (InMemoryCollectorCacheCapacity, error)

	// GetSamplerConfigForDataset returns the sampler type and name to use for the given dataset
	GetSamplerConfigForDataset(string) (interface{}, string, error)

	// GetAllSamplerRules returns all dataset rules in a map, including the default
	GetAllSamplerRules() (map[string]interface{}, error)

	// GetLogrusConfig returns the config specific to Logrus
	GetLogrusConfig() (*LogrusLoggerConfig, error)

	// GetMetricsConfig returns the config specific to PrometheusMetrics
	GetMetricsConfig() MetricsConfig

	// GetUpstreamBufferSize returns the size of the libtrace buffer to use for the upstream
	// libtrace client
	GetUpstreamBufferSize() int
	// GetPeerBufferSize returns the size of the libtrace buffer to use for the peer forwarding
	// libtrace client
	GetPeerBufferSize() int

	GetIdentifierInterfaceName() (string, error)

	GetUseIPV6Identifier() (bool, error)

	GetRedisIdentifier() (string, error)

	// GetSendTickerValue returns the duration to use to check for traces to send
	GetSendTickerValue() time.Duration

	// GetDebugServiceAddr sets the IP and port the debug service will run on (you must provide the
	// command line flag -d to start the debug service)
	GetDebugServiceAddr() (string, error)

	GetIsDryRun() bool

	GetDryRunFieldName() string

	GetAddHostMetadataToTrace() bool

	GetAddAdditionalMetadata() map[string]string

	GetSendMetricsToOpsRamp() bool

	// GetUseTLS returns true when TLS must be enabled to dial
	GetGlobalUseTLS() bool

	// GetUseTLSInsecureSkip returns false when certificate checks are disabled
	GetGlobalUseTLSInsecureSkip() bool

	// GetProxyConfig returns proxy configuration
	GetProxyConfig() ProxyConfiguration

	// GetAuthConfig return the authentication configuration
	GetAuthConfig() AuthConfiguration

	GetRetryConfig() *retry.Config

	GetTenantId() (string, error)

	GetDataset() (string, error)

	GetAddRuleReasonToTrace() bool

	GetEnvironmentCacheTTL() time.Duration

	GetDatasetPrefix() string

	// GetQueryAuthToken returns the token that must be used to access the /query endpoints
	GetQueryAuthToken() string

	GetGRPCMaxConnectionIdle() time.Duration

	GetGRPCMaxConnectionAge() time.Duration

	GetGRPCMaxConnectionAgeGrace() time.Duration

	GetGRPCTime() time.Duration

	GetGRPCTimeout() time.Duration

	GetPeerTimeout() time.Duration

	GetAdditionalErrorFields() []string

	GetAddSpanCountToRoot() bool

	GetCacheOverrunStrategy() string

	GetConfigMetadata() []ConfigMetadata

	GetSampleCacheConfig() SampleCacheConfig
}

func NewConfig

func NewConfig(config, rules string, errorCallback func(error)) (Config, error)

NewConfig creates a new config struct

type ConfigMetadata

type ConfigMetadata struct {
	Type     string `json:"type"`
	ID       string `json:"id"`
	Hash     string `json:"hash"`
	LoadedAt string `json:"loaded_at"`
}

type DeterministicSamplerConfig

type DeterministicSamplerConfig struct {
	SampleRate int `validate:"required,gte=1"`
}

type DynamicSamplerConfig

type DynamicSamplerConfig struct {
	SampleRate                   int64 `validate:"required,gte=1"`
	ClearFrequencySec            int64
	FieldList                    []string `validate:"required"`
	UseTraceLength               bool
	AddSampleRateKeyToTrace      bool
	AddSampleRateKeyToTraceField string `validate:"required_with=AddSampleRateKeyToTrace"`
}

type EMADynamicSamplerConfig

type EMADynamicSamplerConfig struct {
	GoalSampleRate      int `validate:"gte=1"`
	AdjustmentInterval  int
	Weight              float64 `validate:"gt=0,lt=1"`
	AgeOutValue         float64
	BurstMultiple       float64
	BurstDetectionDelay uint
	MaxKeys             int

	FieldList                    []string `validate:"required"`
	UseTraceLength               bool
	AddSampleRateKeyToTrace      bool
	AddSampleRateKeyToTraceField string `validate:"required_with=AddSampleRateKeyToTrace"`
}

type GRPCServerParameters

type GRPCServerParameters struct {
	MaxConnectionIdle     time.Duration
	MaxConnectionAge      time.Duration
	MaxConnectionAgeGrace time.Duration
	Time                  time.Duration
	Timeout               time.Duration
}

GRPCServerParameters allow you to configure the GRPC ServerParameters used by refinery's own GRPC server: https://pkg.go.dev/google.golang.org/grpc/keepalive#ServerParameters

type InMemoryCollectorCacheCapacity

type InMemoryCollectorCacheCapacity struct {
	// CacheCapacity must be less than math.MaxInt32
	CacheCapacity int `validate:"required,lt=2147483647"`
	MaxAlloc      uint64
}

type LogrusLoggerConfig

type LogrusLoggerConfig struct {
	LogFormatter string `validate:"required" toml:"LogFormatter"`
	LogOutput    string `validate:"required,oneof= stdout stderr file" toml:"LogOutput"`
	File         struct {
		FileName   string `toml:"FileName"`
		MaxSize    int    `toml:"MaxSize"`
		MaxBackups int    `toml:"MaxBackups"`
		Compress   bool   `toml:"Compress"`
	} `toml:"File"`
}

type MetricsConfig

type MetricsConfig struct {
	Enable            bool
	ListenAddr        string `validate:"required"`
	OpsRampAPI        string
	ReportingInterval int64
	MetricsList       []string
}

type MockConfig

type MockConfig struct {
	Callbacks                            []func()
	GetAPIKeysErr                        error
	GetAPIKeysVal                        []string
	GetCollectorTypeErr                  error
	GetCollectorTypeVal                  string
	GetInMemoryCollectorCacheCapacityErr error
	GetInMemoryCollectorCacheCapacityVal InMemoryCollectorCacheCapacity
	GetOpsrampAPIErr                     error
	GetOpsrampAPIVal                     string
	GetListenAddrErr                     error
	GetListenAddrVal                     string
	GetPeerListenAddrErr                 error
	GetPeerListenAddrVal                 string
	GetCompressPeerCommunicationsVal     bool
	GetGRPCListenAddrErr                 error
	GetGRPCListenAddrVal                 string
	GetLoggerTypeErr                     error
	GetLoggerTypeVal                     string
	GetLoggingLevelErr                   error
	GetLoggingLevelVal                   string
	GetOtherConfigErr                    error
	// GetOtherConfigVal must be a JSON representation of the config struct to be populated.
	GetOtherConfigVal          string
	GetPeersErr                error
	GetPeersVal                []string
	GetRedisHostErr            error
	GetRedisHostVal            string
	GetRedisUsernameErr        error
	GetRedisUsernameVal        string
	GetRedisPasswordErr        error
	GetRedisPasswordVal        string
	GetUseTLSErr               error
	GetUseTLSVal               bool
	GetUseTLSInsecureErr       error
	GetUseTLSInsecureVal       bool
	GetSamplerTypeErr          error
	GetSamplerTypeName         string
	GetSamplerTypeVal          interface{}
	GetMetricsTypeErr          error
	GetMetricsTypeVal          string
	GetOpsRampMetricsConfigErr error
	GetOpsRampMetricsConfigVal MetricsConfig
	GetSendDelayErr            error
	GetSendDelayVal            time.Duration
	GetBatchTimeoutVal         time.Duration
	GetTraceTimeoutErr         error
	GetTraceTimeoutVal         time.Duration
	GetMaxBatchSizeVal         uint
	GetUpstreamBufferSizeVal   int
	GetPeerBufferSizeVal       int
	SendTickerVal              time.Duration
	IdentifierInterfaceName    string
	UseIPV6Identifier          bool
	RedisIdentifier            string
	PeerManagementType         string
	PeerManagementStrategy     string
	DebugServiceAddr           string
	DryRun                     bool
	DryRunFieldName            string
	AddHostMetadataToTrace     bool
	AddRuleReasonToTrace       bool
	EnvironmentCacheTTL        time.Duration
	DatasetPrefix              string
	QueryAuthToken             string
	GRPCMaxConnectionIdle      time.Duration
	GRPCMaxConnectionAge       time.Duration
	GRPCMaxConnectionAgeGrace  time.Duration
	GRPCTime                   time.Duration
	GRPCTimeout                time.Duration
	PeerTimeout                time.Duration
	AdditionalErrorFields      []string
	AddSpanCountToRoot         bool
	CacheOverrunStrategy       string
	SampleCache                SampleCacheConfig
	CfgMetadata                []ConfigMetadata

	Mux sync.RWMutex
}

MockConfig will respond with whatever config it's set to do during initialization

func (*MockConfig) GetAPIKeys

func (m *MockConfig) GetAPIKeys() ([]string, error)

func (*MockConfig) GetAddAdditionalMetadata

func (m *MockConfig) GetAddAdditionalMetadata() map[string]string

func (*MockConfig) GetAddHostMetadataToTrace

func (m *MockConfig) GetAddHostMetadataToTrace() bool

func (*MockConfig) GetAddRuleReasonToTrace

func (m *MockConfig) GetAddRuleReasonToTrace() bool

func (*MockConfig) GetAddSpanCountToRoot

func (m *MockConfig) GetAddSpanCountToRoot() bool

func (*MockConfig) GetAdditionalErrorFields

func (m *MockConfig) GetAdditionalErrorFields() []string

func (*MockConfig) GetAllSamplerRules

func (m *MockConfig) GetAllSamplerRules() (map[string]interface{}, error)

GetAllSamplerRules returns all dataset rules, including the default

func (*MockConfig) GetAuthConfig

func (m *MockConfig) GetAuthConfig() AuthConfiguration

func (*MockConfig) GetBatchTimeout

func (m *MockConfig) GetBatchTimeout() time.Duration

func (*MockConfig) GetCacheOverrunStrategy

func (m *MockConfig) GetCacheOverrunStrategy() string

func (*MockConfig) GetCollectorType

func (m *MockConfig) GetCollectorType() (string, error)

func (*MockConfig) GetCompressPeerCommunication

func (m *MockConfig) GetCompressPeerCommunication() bool

func (*MockConfig) GetConfigMetadata

func (m *MockConfig) GetConfigMetadata() []ConfigMetadata

func (*MockConfig) GetDataset

func (m *MockConfig) GetDataset() (string, error)

func (*MockConfig) GetDatasetPrefix

func (m *MockConfig) GetDatasetPrefix() string

func (*MockConfig) GetDebugServiceAddr

func (m *MockConfig) GetDebugServiceAddr() (string, error)

func (*MockConfig) GetDryRunFieldName

func (m *MockConfig) GetDryRunFieldName() string

func (*MockConfig) GetEnvironmentCacheTTL

func (m *MockConfig) GetEnvironmentCacheTTL() time.Duration

func (*MockConfig) GetGRPCListenAddr

func (m *MockConfig) GetGRPCListenAddr() (string, error)

func (*MockConfig) GetGRPCMaxConnectionAge

func (m *MockConfig) GetGRPCMaxConnectionAge() time.Duration

func (*MockConfig) GetGRPCMaxConnectionAgeGrace

func (m *MockConfig) GetGRPCMaxConnectionAgeGrace() time.Duration

func (*MockConfig) GetGRPCMaxConnectionIdle

func (m *MockConfig) GetGRPCMaxConnectionIdle() time.Duration

func (*MockConfig) GetGRPCPeerListenAddr

func (m *MockConfig) GetGRPCPeerListenAddr() (string, error)

func (*MockConfig) GetGRPCTime

func (m *MockConfig) GetGRPCTime() time.Duration

func (*MockConfig) GetGRPCTimeout

func (m *MockConfig) GetGRPCTimeout() time.Duration

func (*MockConfig) GetGlobalUseTLS

func (m *MockConfig) GetGlobalUseTLS() bool

func (*MockConfig) GetGlobalUseTLSInsecureSkip

func (m *MockConfig) GetGlobalUseTLSInsecureSkip() bool

func (*MockConfig) GetIdentifierInterfaceName

func (m *MockConfig) GetIdentifierInterfaceName() (string, error)

func (*MockConfig) GetInMemCollectorCacheCapacity

func (m *MockConfig) GetInMemCollectorCacheCapacity() (InMemoryCollectorCacheCapacity, error)

func (*MockConfig) GetIsDryRun

func (m *MockConfig) GetIsDryRun() bool

func (*MockConfig) GetListenAddr

func (m *MockConfig) GetListenAddr() (string, error)

func (*MockConfig) GetLoggerType

func (m *MockConfig) GetLoggerType() (string, error)

func (*MockConfig) GetLoggingLevel

func (m *MockConfig) GetLoggingLevel() (string, error)

func (*MockConfig) GetLogrusConfig

func (m *MockConfig) GetLogrusConfig() (*LogrusLoggerConfig, error)

func (*MockConfig) GetLogsEndpoint

func (m *MockConfig) GetLogsEndpoint() string

func (*MockConfig) GetMaxBatchSize

func (m *MockConfig) GetMaxBatchSize() uint

func (*MockConfig) GetMetricsConfig

func (m *MockConfig) GetMetricsConfig() MetricsConfig

func (*MockConfig) GetMetricsType

func (m *MockConfig) GetMetricsType() (string, error)

func (*MockConfig) GetOpsrampAPI

func (m *MockConfig) GetOpsrampAPI() (string, error)

func (*MockConfig) GetOtherConfig

func (m *MockConfig) GetOtherConfig(name string, iface interface{}) error

func (*MockConfig) GetPeerBufferSize

func (m *MockConfig) GetPeerBufferSize() int

func (*MockConfig) GetPeerListenAddr

func (m *MockConfig) GetPeerListenAddr() (string, error)

func (*MockConfig) GetPeerManagementStrategy

func (m *MockConfig) GetPeerManagementStrategy() (string, error)

func (*MockConfig) GetPeerManagementType

func (m *MockConfig) GetPeerManagementType() (string, error)

func (*MockConfig) GetPeerTimeout

func (m *MockConfig) GetPeerTimeout() time.Duration

func (*MockConfig) GetPeers

func (m *MockConfig) GetPeers() ([]string, error)

func (*MockConfig) GetPrometheusMetricsConfig

func (m *MockConfig) GetPrometheusMetricsConfig() (MetricsConfig, error)

func (*MockConfig) GetProxyConfig

func (m *MockConfig) GetProxyConfig() ProxyConfiguration

func (*MockConfig) GetQueryAuthToken

func (m *MockConfig) GetQueryAuthToken() string

func (*MockConfig) GetRedisDatabase

func (m *MockConfig) GetRedisDatabase() int

func (*MockConfig) GetRedisHost

func (m *MockConfig) GetRedisHost() (string, error)

func (*MockConfig) GetRedisIdentifier

func (m *MockConfig) GetRedisIdentifier() (string, error)

func (*MockConfig) GetRedisPassword

func (m *MockConfig) GetRedisPassword() (string, error)

func (*MockConfig) GetRedisPrefix

func (m *MockConfig) GetRedisPrefix() string

func (*MockConfig) GetRedisUsername

func (m *MockConfig) GetRedisUsername() (string, error)

func (*MockConfig) GetRetryConfig

func (m *MockConfig) GetRetryConfig() *retry.Config

func (*MockConfig) GetSampleCacheConfig

func (m *MockConfig) GetSampleCacheConfig() SampleCacheConfig

func (*MockConfig) GetSamplerConfigForDataset

func (m *MockConfig) GetSamplerConfigForDataset(dataset string) (interface{}, string, error)

TODO: allow per-dataset mock values

func (*MockConfig) GetSendDelay

func (m *MockConfig) GetSendDelay() (time.Duration, error)

func (*MockConfig) GetSendEvents

func (m *MockConfig) GetSendEvents() bool

func (*MockConfig) GetSendMetricsToOpsRamp

func (m *MockConfig) GetSendMetricsToOpsRamp() bool

func (*MockConfig) GetSendTickerValue

func (m *MockConfig) GetSendTickerValue() time.Duration

func (*MockConfig) GetTenantId

func (m *MockConfig) GetTenantId() (string, error)

func (*MockConfig) GetThreshold

func (m *MockConfig) GetThreshold() float64

func (*MockConfig) GetTraceTimeout

func (m *MockConfig) GetTraceTimeout() (time.Duration, error)

func (*MockConfig) GetUpstreamBufferSize

func (m *MockConfig) GetUpstreamBufferSize() int

func (*MockConfig) GetUseIPV6Identifier

func (m *MockConfig) GetUseIPV6Identifier() (bool, error)

func (*MockConfig) GetUseTLS

func (m *MockConfig) GetUseTLS() (bool, error)

func (*MockConfig) GetUseTLSInsecure

func (m *MockConfig) GetUseTLSInsecure() (bool, error)

func (*MockConfig) IsTest

func (m *MockConfig) IsTest() bool

func (*MockConfig) RegisterReloadCallback

func (m *MockConfig) RegisterReloadCallback(callback func())

func (*MockConfig) ReloadConfig

func (m *MockConfig) ReloadConfig()

type PeerManagementConfig

type PeerManagementConfig struct {
	Type                    string   `validate:"required,oneof= file redis"`
	Peers                   []string `validate:"dive,url"`
	RedisHost               string
	RedisUsername           string
	RedisPassword           string
	UseTLS                  bool
	UseTLSInsecure          bool
	IdentifierInterfaceName string
	UseIPV6Identifier       bool
	RedisIdentifier         string
	Timeout                 time.Duration
	Strategy                string `validate:"required,oneof= legacy hash"`
}

type ProxyConfiguration

type ProxyConfiguration struct {
	Protocol string
	Host     string
	Port     string
	Username string
	Password string
}

type RulesBasedDownstreamSampler

type RulesBasedDownstreamSampler struct {
	DynamicSampler         *DynamicSamplerConfig
	EMADynamicSampler      *EMADynamicSamplerConfig
	TotalThroughputSampler *TotalThroughputSamplerConfig
}

type RulesBasedSamplerCondition

type RulesBasedSamplerCondition struct {
	Field    string
	Operator string
	Value    interface{}
	Datatype string
	Matches  func(value any, exists bool) bool
}

func (*RulesBasedSamplerCondition) Init

func (*RulesBasedSamplerCondition) String

func (r *RulesBasedSamplerCondition) String() string

type RulesBasedSamplerConfig

type RulesBasedSamplerConfig struct {
	Rule              []*RulesBasedSamplerRule
	CheckNestedFields bool
}

func (*RulesBasedSamplerConfig) String

func (r *RulesBasedSamplerConfig) String() string

type RulesBasedSamplerRule

type RulesBasedSamplerRule struct {
	Name       string
	SampleRate int
	Sampler    *RulesBasedDownstreamSampler
	Drop       bool
	Scope      string `validate:"oneof=span trace"`
	Condition  []*RulesBasedSamplerCondition
}

func (*RulesBasedSamplerRule) String

func (r *RulesBasedSamplerRule) String() string

type SampleCacheConfig

type SampleCacheConfig struct {
	Type              string        `validate:"required,oneof= legacy cuckoo"`
	KeptSize          uint          `validate:"gte=500"`
	DroppedSize       uint          `validate:"gte=100_000"`
	SizeCheckInterval time.Duration `validate:"gte=1_000_000_000"` // 1 second minimum
}

type TotalThroughputSamplerConfig

type TotalThroughputSamplerConfig struct {
	GoalThroughputPerSec         int64 `validate:"gte=1"`
	ClearFrequencySec            int64
	FieldList                    []string `validate:"required"`
	UseTraceLength               bool
	AddSampleRateKeyToTrace      bool
	AddSampleRateKeyToTraceField string `validate:"required_with=AddSampleRateKeyToTrace"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL