config

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: Apache-2.0 Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config interface {
	// 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)

	// GetCompressPeerCommunication will be true if refinery 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)

	// GetAPIKeys returns a list of Honeycomb API keys
	GetAPIKeys() ([]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)

	// GetHoneycombAPI returns the base URL (protocol, hostname, and port) of
	// the upstream Honeycomb API server
	GetHoneycombAPI() (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

	// 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

	// GetLoggerType returns the type of the logger to use. Valid types are in
	// the logger package
	GetLoggerType() (string, error)

	// GetHoneycombLoggerConfig returns the config specific to the HoneycombLogger
	GetHoneycombLoggerConfig() (HoneycombLoggerConfig, 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)

	// GetMetricsType returns the type of metrics to use. Valid types are in the
	// metrics package
	GetMetricsType() (string, error)

	// GetHoneycombMetricsConfig returns the config specific to HoneycombMetrics
	GetHoneycombMetricsConfig() (HoneycombMetricsConfig, error)

	// GetPrometheusMetricsConfig returns the config specific to PrometheusMetrics
	GetPrometheusMetricsConfig() (PrometheusMetricsConfig, error)

	// GetUpstreamBufferSize returns the size of the libhoney buffer to use for the upstream
	// libhoney client
	GetUpstreamBufferSize() int
	// GetPeerBufferSize returns the size of the libhoney buffer to use for the peer forwarding
	// libhoney 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

	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

	GetStressReliefConfig() StressReliefConfig

	GetAdditionalAttributes() map[string]string

	GetTraceIdFieldNames() []string

	GetParentIdFieldNames() []string
}

func NewConfig

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

NewConfig creates a new config struct

type ConfigMetadata added in v1.19.0

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 added in v1.16.0

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 HoneycombLevel

type HoneycombLevel int

type HoneycombLoggerConfig

type HoneycombLoggerConfig struct {
	LoggerHoneycombAPI      string `validate:"required,url"`
	LoggerAPIKey            string `validate:"required"`
	LoggerDataset           string `validate:"required"`
	LoggerSamplerEnabled    bool
	LoggerSamplerThroughput int
	Level                   HoneycombLevel
}

type HoneycombMetricsConfig

type HoneycombMetricsConfig struct {
	MetricsHoneycombAPI      string `validate:"required,url"`
	MetricsAPIKey            string `validate:"required"`
	MetricsDataset           string `validate:"required"`
	MetricsReportingInterval int64  `validate:"required"`
}

type InMemoryCollectorCacheCapacity

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

type MockConfig

type MockConfig struct {
	Callbacks                            []func()
	GetAPIKeysErr                        error
	GetAPIKeysVal                        []string
	GetCollectorTypeErr                  error
	GetCollectorTypeVal                  string
	GetInMemoryCollectorCacheCapacityErr error
	GetInMemoryCollectorCacheCapacityVal InMemoryCollectorCacheCapacity
	GetHoneycombAPIErr                   error
	GetHoneycombAPIVal                   string
	GetListenAddrErr                     error
	GetListenAddrVal                     string
	GetPeerListenAddrErr                 error
	GetPeerListenAddrVal                 string
	GetCompressPeerCommunicationsVal     bool
	GetGRPCListenAddrErr                 error
	GetGRPCListenAddrVal                 string
	GetLoggerTypeErr                     error
	GetLoggerTypeVal                     string
	GetHoneycombLoggerConfigErr          error
	GetHoneycombLoggerConfigVal          HoneycombLoggerConfig
	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
	GetRedisDatabaseVal           int
	GetRedisPrefixVal             string
	GetUseTLSErr                  error
	GetUseTLSVal                  bool
	GetUseTLSInsecureErr          error
	GetUseTLSInsecureVal          bool
	GetSamplerTypeErr             error
	GetSamplerTypeName            string
	GetSamplerTypeVal             interface{}
	GetMetricsTypeErr             error
	GetMetricsTypeVal             string
	GetHoneycombMetricsConfigErr  error
	GetHoneycombMetricsConfigVal  HoneycombMetricsConfig
	GetPrometheusMetricsConfigErr error
	GetPrometheusMetricsConfigVal PrometheusMetricsConfig
	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
	StressRelief                  StressReliefConfig
	AdditionalAttributes          map[string]string
	TraceIdFieldNames             []string
	ParentIdFieldNames            []string
	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) GetAddHostMetadataToTrace added in v1.2.0

func (m *MockConfig) GetAddHostMetadataToTrace() bool

func (*MockConfig) GetAddRuleReasonToTrace added in v1.16.0

func (m *MockConfig) GetAddRuleReasonToTrace() bool

func (*MockConfig) GetAddSpanCountToRoot added in v1.18.0

func (f *MockConfig) GetAddSpanCountToRoot() bool

func (*MockConfig) GetAdditionalAttributes added in v1.20.0

func (f *MockConfig) GetAdditionalAttributes() map[string]string

func (*MockConfig) GetAdditionalErrorFields added in v1.17.0

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

func (*MockConfig) GetAllSamplerRules added in v1.16.0

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

GetAllSamplerRules returns all dataset rules, including the default

func (*MockConfig) GetBatchTimeout added in v1.17.0

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

func (*MockConfig) GetCacheOverrunStrategy added in v1.19.0

func (f *MockConfig) GetCacheOverrunStrategy() string

func (*MockConfig) GetCollectorType

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

func (*MockConfig) GetCompressPeerCommunication added in v0.16.0

func (m *MockConfig) GetCompressPeerCommunication() bool

func (*MockConfig) GetConfigMetadata added in v1.19.0

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

func (*MockConfig) GetDatasetPrefix added in v1.14.0

func (f *MockConfig) GetDatasetPrefix() string

func (*MockConfig) GetDebugServiceAddr

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

func (*MockConfig) GetDryRunFieldName

func (m *MockConfig) GetDryRunFieldName() string

func (*MockConfig) GetEnvironmentCacheTTL added in v1.11.0

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

func (*MockConfig) GetGRPCListenAddr added in v0.16.0

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

func (*MockConfig) GetGRPCMaxConnectionAge added in v1.16.0

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

func (*MockConfig) GetGRPCMaxConnectionAgeGrace added in v1.16.0

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

func (*MockConfig) GetGRPCMaxConnectionIdle added in v1.16.0

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

func (*MockConfig) GetGRPCTime added in v1.16.0

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

func (*MockConfig) GetGRPCTimeout added in v1.16.0

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

func (*MockConfig) GetHoneycombAPI

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

func (*MockConfig) GetHoneycombLoggerConfig

func (m *MockConfig) GetHoneycombLoggerConfig() (HoneycombLoggerConfig, error)

func (*MockConfig) GetHoneycombMetricsConfig

func (m *MockConfig) GetHoneycombMetricsConfig() (HoneycombMetricsConfig, error)

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) GetMaxBatchSize added in v1.8.0

func (m *MockConfig) GetMaxBatchSize() uint

func (*MockConfig) GetMetricsType

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

func (*MockConfig) GetOtherConfig

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

func (*MockConfig) GetParentIdFieldNames added in v1.20.0

func (f *MockConfig) GetParentIdFieldNames() []string

func (*MockConfig) GetPeerBufferSize

func (m *MockConfig) GetPeerBufferSize() int

func (*MockConfig) GetPeerListenAddr

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

func (*MockConfig) GetPeerManagementStrategy added in v1.20.0

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

func (*MockConfig) GetPeerManagementType

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

func (*MockConfig) GetPeerTimeout added in v1.16.0

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

func (*MockConfig) GetPeers

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

func (*MockConfig) GetPrometheusMetricsConfig

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

func (*MockConfig) GetQueryAuthToken added in v1.16.0

func (f *MockConfig) GetQueryAuthToken() string

func (*MockConfig) GetRedisDatabase added in v1.20.0

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 added in v0.15.0

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

func (*MockConfig) GetRedisPrefix added in v1.20.0

func (m *MockConfig) GetRedisPrefix() string

func (*MockConfig) GetRedisUsername added in v1.10.0

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

func (*MockConfig) GetSampleCacheConfig added in v1.20.0

func (f *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) GetSendTickerValue

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

func (*MockConfig) GetStressReliefConfig added in v1.20.0

func (f *MockConfig) GetStressReliefConfig() StressReliefConfig

func (*MockConfig) GetTraceIdFieldNames added in v1.20.0

func (f *MockConfig) GetTraceIdFieldNames() []string

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 added in v0.15.0

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

func (*MockConfig) GetUseTLSInsecure added in v1.2.0

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

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
	RedisPrefix             string `validate:"required"`
	RedisDatabase           int    `validate:"gte=0,lte=15"`
	UseTLS                  bool
	UseTLSInsecure          bool
	IdentifierInterfaceName string
	UseIPV6Identifier       bool
	RedisIdentifier         string
	Timeout                 time.Duration
	Strategy                string `validate:"required,oneof= legacy hash"`
}

type PrometheusMetricsConfig

type PrometheusMetricsConfig struct {
	MetricsListenAddr string `validate:"required"`
}

type RulesBasedDownstreamSampler added in v1.5.0

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 added in v1.20.0

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 added in v1.20.0

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 StressReliefConfig added in v1.20.0

type StressReliefConfig struct {
	Mode                      string `validate:"required,oneof= always never monitor"`
	ActivationLevel           uint
	DeactivationLevel         uint
	StressSamplingRate        uint64
	MinimumActivationDuration time.Duration
	StartStressedDuration     time.Duration
}

type TotalThroughputSamplerConfig added in v0.13.0

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