Documentation ¶
Overview ¶
It implements a sampler and a global provider placeholder so samplers can be created before setting the global provider. Once the global provider is set, any prob ebuilt before setting it is initialized with the new global provider.
Index ¶
- Constants
- func Sample(ctx context.Context, name string, schema sample.Schema, sample sample.Sample) bool
- func SetProvider(pp Provider) error
- type Option
- func WithInitalValueDigest(location control.ComputationLocation) Option
- func WithInitialDeterministicSamplingIn(samplingRate int32) Option
- func WithInitialLimiterInLimit(l int32) Option
- func WithInitialLimiterOutLimit(l int32) Option
- func WithInitialStructDigest(location control.ComputationLocation) Option
- func WithTags(tags ...string) Option
- func WithUpdateStatsPeriod(p time.Duration) Option
- func WithoutDefaultInitialConfig() Option
- type Provider
- type ProviderOption
- type Sampler
- type Settings
Constants ¶
const ( ProducerTag = control.ProducerTag ConsumerTag = control.ConsumerTag RequestTag = control.RequestTag ResponseTag = control.ResponseTag // DLQTag is used to tag samples that are sent to a dead letter queue // Automatically enables an event that notifies when a sample is sent to a DLQ DLQTag = control.DLQTag )
re-exported known tags
const DLQEventName = "sample_sent_to_dlq"
Variables ¶
This section is empty.
Functions ¶
func Sample ¶ added in v0.3.1
Sample samples the given data sample using the given sampler name and schema. If a sampler with the given name is not registered, it will be created. Note that if there is any error creating the sampler, it wont't be reported and the sample will be silently discarded.
func SetProvider ¶ added in v0.3.0
SetProvider sets the global provider. It can only be set once. It may return sampler initialization errors because the creation of samplers created with the default global provider are deferred until it is set
Types ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
func WithInitalValueDigest ¶ added in v0.1.0
func WithInitalValueDigest(location control.ComputationLocation) Option
WithInitalValueDigest enables the computation of value digest. Location defines where this computation must take place (in the sampler of in the collector). In case of computing the digest in the collector, the raw samples are exported (that can have an impact in the sampler performance)
func WithInitialDeterministicSamplingIn ¶ added in v0.1.0
WithInitialDeterministicSamplingIn defines a deterministic sampling strategy which will be applied when a sample is received and before processing it in any way (e.g. before determining if a sample belongs to a stream which would require parsing it and evaluating the stream rules). Sampling is performed after the input limiter has been applied. This configuration is only used the first time a sampler is registered with a server, posterior executions will use the configuration stored in the server and the provided configuration will be ignored.
func WithInitialLimiterInLimit ¶ added in v0.1.0
WithInitialLimiterInLimit sets the initial limiter in rate limit. This configuration is only used the first time a sampler is registered with a server, posterior executions will use the configuration stored in the server and the provided configuration will be ignored.
func WithInitialLimiterOutLimit ¶ added in v0.1.0
WithInitialLimiterInLimit sets the initial limiter in rate limit. This configuration is only used the first time a sampler is registered with a server, posterior executions will use the configuration stored in the server and the provided configuration will be ignored.
func WithInitialStructDigest ¶ added in v0.1.0
func WithInitialStructDigest(location control.ComputationLocation) Option
WithInitalStructDigest enables the computation of struct digest. Location defines where this computation must take place (in the sampler of in the collector). In case of computing the digest in the collector, the raw samples are exported (that can have an impact in the sampler performance)
func WithTags ¶ added in v0.3.0
WithTags can be used to specify tags to classify the Sampler or to specify its type. There are known tags that can be used to identify the Sampler type and may be used by the platform to provide additional functionality automnatically. See the tags constants defined in this file.
func WithUpdateStatsPeriod ¶
WithUpdateStatsPeriod specifies the period to send sampler stats to server If the provided period is less than a second, it will be set to 1 second.
func WithoutDefaultInitialConfig ¶ added in v0.1.0
func WithoutDefaultInitialConfig() Option
WithoutDefaultInitialConfig avoids setting the default 'all' stream and digest. This configuration is only used the first time a sampler is registered with a server, posterior executions will use the configuration stored in the server and the provided configuration will be ignored.
type Provider ¶
type Provider interface { // Sampler creates a new sampler with the specified schema. It currently supports Dynamic and Proto schemas. // * A Dynamic schema does not enforce any structure to the sampled data and is compatible with all the Sample*() // methods. The downside, is that it is slower than the Proto schema since it needs to determine at runtime the sampled // data format. // * A Proto schema requires the caller to provide a proto message (type proto.Message) to define the sampler schema. // All sampled data is expected to be provided as proto messages with the sampler.SampleProto() method, and it should // be the same type as the one provided when defining the sampler schema. Sampler(name string, schema sample.Schema, opts ...Option) (Sampler, error) }
Provider defines a sampler provider object capable of creating new samplers.
func NewProvider ¶
NewProvider creates a new sampler provider capable of creating new samplers. After initializing a provider, it is recommended to set it as the global provider for easier access.
provider := NewProvider(...) sampler.SetProvider(provider)
Then, to create new samplers do:
sampler, err := sampler.New(...)
which is equivalent to creating a sampler using the global provider:
sampler, err := provider.Sampler(...)
type ProviderOption ¶ added in v0.3.0
type ProviderOption interface {
// contains filtered or unexported methods
}
func WithBearerAuth ¶
func WithBearerAuth(token string) ProviderOption
WithBearerAuth sets authorization based on a Bearer token
func WithLogger ¶
func WithLogger(l logging.Logger) ProviderOption
WithLogger provides a logger instance to log the Provider and Sampler activity
func WithSamplerErrorChannel ¶ added in v0.1.0
func WithSamplerErrorChannel(errCh chan error) ProviderOption
WithErrorChannel received a channel where Sampler errors will be sent. The avoid blocking the Sampler, it won't block if the channel is full so it is responsibility of the provider to ensure the channel has enough buffer to avoid losing errors.
type Sampler ¶
type Sampler interface { // Sample samples the given data sample. Returns true if the sample has been exported. Sample(ctx context.Context, sample sample.Sample) bool // Close closes all Sampler connections with the Control and Data planes. Once closed, // the Sampler can't be reused and none of its methods can be called. Close() error }
Sampler defines the sampler public interface
type Settings ¶
type Settings struct { // ResourceName sets the resource name common to all samplers created by this provider // For example, the service or the data pipeline operator name ResourceName string // ControlServerAddr specifies the address where the control server is listening at. // Format addr:port ControlServerAddr string // ControlServerAddr specifies the address where the data server is listening at. // By default, it sends the data samples encoded as OTLP logs following the OTLP gRPC // protocol, so it works with any OTLP gRPC logs compatible collector. // Format addr:port DataServerAddr string }