Documentation
¶
Index ¶
- func DefaultSampler(ratio int) bool
- func GetLogger() log.Logger
- func GetMeter() metric.Meter
- func GetTracer() trace.Tracer
- func RecordCount(ctx context.Context, name string, value int64, tags ...attribute.KeyValue)
- func RecordHistogram(ctx context.Context, name string, value float64, tags ...attribute.KeyValue)
- func RecordMetric(ctx context.Context, name string, value float64, tags ...attribute.KeyValue)
- func SetConfig(conf Config)
- func SetSamplingConfig(config *gql.GetSamplingConfigResponse)
- func Shutdown()
- func StartOTLP() error
- type Config
- type CustomSampler
- type ExportSampler
- type LogSamplingResult
- type ReadonlySpanSubset
- type SamplerFunc
- type SamplingResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultSampler ¶
DefaultSampler determines if an item should be sampled based on the sampling ratio. This function is not used for any purpose requiring cryptographic security.
func GetLogger ¶
GetLogger returns the current logger instance. The result of this function should not be cached unless the caller is sure that OTLP has been started.
func GetMeter ¶
GetMeter returns the current meter instance. The result of this function should not be cached unless the caller is sure that OTLP has been started.
func GetTracer ¶
GetTracer returns the current tracer instance. The result of this function should not be cached unless the caller is sure that OTLP has been started.
func RecordCount ¶
RecordCount is used to record arbitrary counts in your golang backend.
func RecordHistogram ¶
RecordHistogram is used to record arbitrary histograms in your golang backend.
func RecordMetric ¶
RecordMetric is used to record arbitrary metrics in your golang backend.
func SetConfig ¶
func SetConfig(conf Config)
SetConfig sets the configuration for the OTLP provider. The configuration must be set before calling StartOTLP.
func SetSamplingConfig ¶
func SetSamplingConfig(config *gql.GetSamplingConfigResponse)
SetSamplingConfig sets the sampling configuration for the custom sampler. This function is called when the sampling configuration is received from the LaunchDarkly API.
Types ¶
type Config ¶
type Config struct {
OtlpEndpoint string
ResourceAttributes []attribute.KeyValue
Sampler sdktrace.Sampler
}
Config contains the configuration for the OTLP provider.
type CustomSampler ¶
type CustomSampler struct {
// contains filtered or unexported fields
}
CustomSampler is a custom sampler that uses sampling configuration to determine if a span should be sampled
func NewCustomSampler ¶
func NewCustomSampler(sampler SamplerFunc) *CustomSampler
NewCustomSampler creates a new CustomSampler with the given sampler function
func (*CustomSampler) IsSamplingEnabled ¶
func (cs *CustomSampler) IsSamplingEnabled() bool
IsSamplingEnabled returns true if sampling is enabled
func (*CustomSampler) SampleLog ¶
func (cs *CustomSampler) SampleLog(record sdklog.Record) LogSamplingResult
SampleLog samples a log record based on the sampling configuration
func (*CustomSampler) SampleSpan ¶
func (cs *CustomSampler) SampleSpan(span ReadonlySpanSubset) SamplingResult
SampleSpan samples a span based on the sampling configuration
func (*CustomSampler) SetConfig ¶
func (cs *CustomSampler) SetConfig(config *gql.GetSamplingConfigSamplingSamplingConfig)
SetConfig sets the sampling configuration
type ExportSampler ¶
type ExportSampler interface {
// SampleSpan samples a span and returns the result
SampleSpan(span ReadonlySpanSubset) SamplingResult
// SampleLog samples a log record and returns the result
SampleLog(record sdklog.Record) LogSamplingResult
// IsSamplingEnabled returns true if sampling is enabled
IsSamplingEnabled() bool
// SetConfig sets the sampling configuration
SetConfig(config *gql.GetSamplingConfigSamplingSamplingConfig)
}
ExportSampler defines the interface for export samplers
type LogSamplingResult ¶
type LogSamplingResult struct {
// Sample indicates whether the span/log should be sampled
Sample bool
// Attributes contains additional attributes to add to the span/log
Attributes []log.KeyValue
}
LogSamplingResult represents the result of sampling a log record
type ReadonlySpanSubset ¶
type ReadonlySpanSubset interface {
// Events returns all the events that occurred within in the spans
// lifetime.
Events() []trace.Event
// Name returns the name of the span.
Name() string
// Attributes returns the defining attributes of the span.
// The order of the returned attributes is not guaranteed to be stable across invocations.
Attributes() []attribute.KeyValue
}
ReadonlySpanSubset implements the components of the trace.ReadonlySpan that are needed for sampling. The trace.ReadonlySpan interface cannot be directly implemented, because it contains a `private()` method. So we define this subset so we can make instances in unit tests.
type SamplerFunc ¶
SamplerFunc is a function type for sampling decisions
type SamplingResult ¶
type SamplingResult struct {
// Sample indicates whether the span/log should be sampled
Sample bool
// Attributes contains additional attributes to add to the span/log
Attributes []attribute.KeyValue
}
SamplingResult represents the result of sampling a span or log