Documentation
ΒΆ
Index ΒΆ
- Variables
- func CompactionFNV32a(input string) string
- func CompactionFNV64a(input string) string
- func CompactionFNV128a(input string) string
- func MatchAll() func(context.Context, *slog.Record) string
- func MatchByAttribute(groups []string, key string) func(context.Context, *slog.Record) string
- func MatchByContextValue(key any) func(context.Context, *slog.Record) string
- func MatchByLevel() func(context.Context, *slog.Record) string
- func MatchByLevelAndMessage() func(context.Context, *slog.Record) string
- func MatchByMessage() func(context.Context, *slog.Record) string
- func MatchBySource() func(context.Context, *slog.Record) string
- type AbsoluteSamplingOption
- type CustomSamplingOption
- type Matcher
- type ThresholdSamplingOption
- type UniformSamplingOption
Constants ΒΆ
This section is empty.
Variables ΒΆ
View Source
var DefaultMatcher = MatchByLevelAndMessage()
Functions ΒΆ
func CompactionFNV32a ΒΆ added in v1.3.0
func CompactionFNV64a ΒΆ added in v1.3.0
func CompactionFNV128a ΒΆ added in v1.3.0
func MatchByAttribute ΒΆ added in v1.1.0
func MatchByContextValue ΒΆ added in v1.1.0
func MatchByLevelAndMessage ΒΆ added in v1.1.0
func MatchByMessage ΒΆ added in v1.1.0
Types ΒΆ
type AbsoluteSamplingOption ΒΆ added in v1.2.0
type AbsoluteSamplingOption struct {
// This will log all entries with the same hash until max is reached,
// in a `Tick` interval as-is. Following that, it will reduce log throughput
// depending on previous interval.
Tick time.Duration
Max uint64
// Group similar logs (default: by level and message)
Matcher Matcher
Buffer func(generator func(string) any) buffer.Buffer[string]
// Optional hooks
OnAccepted func(context.Context, slog.Record)
OnDropped func(context.Context, slog.Record)
// contains filtered or unexported fields
}
func (AbsoluteSamplingOption) NewMiddleware ΒΆ added in v1.2.0
func (o AbsoluteSamplingOption) NewMiddleware() slogmulti.Middleware
NewMiddleware returns a slog-multi middleware.
type CustomSamplingOption ΒΆ added in v0.2.0
type CustomSamplingOption struct {
// The sample rate for sampling traces in the range [0.0, 1.0].
Sampler func(context.Context, slog.Record) float64
// Optional hooks
OnAccepted func(context.Context, slog.Record)
OnDropped func(context.Context, slog.Record)
}
func (CustomSamplingOption) NewMiddleware ΒΆ added in v0.2.0
func (o CustomSamplingOption) NewMiddleware() slogmulti.Middleware
NewMiddleware returns a slog-multi middleware.
type Matcher ΒΆ added in v1.1.0
Matcher is a function that returns a string hash for a given record. Returning []byte would have been much much better, but go's hashmap doesn't support it. π€¬
type ThresholdSamplingOption ΒΆ added in v0.2.0
type ThresholdSamplingOption struct {
// This will log the first `Threshold` log entries with the same hash,
// in a `Tick` interval as-is. Following that, it will allow `Rate` in the range [0.0, 1.0].
Tick time.Duration
Threshold uint64
Rate float64
// Group similar logs (default: by level and message)
Matcher Matcher
Buffer func(generator func(string) any) buffer.Buffer[string]
// Optional hooks
OnAccepted func(context.Context, slog.Record)
OnDropped func(context.Context, slog.Record)
// When true, the first accepted record after a suppression window includes
// a "slog_sampling.dropped_count" attribute with the number of records that
// were dropped in the previous window. This gives operators visibility into
// suppression volume without a separate summary goroutine.
IncludeDroppedCount bool
// contains filtered or unexported fields
}
func (ThresholdSamplingOption) NewMiddleware ΒΆ added in v0.2.0
func (o ThresholdSamplingOption) NewMiddleware() slogmulti.Middleware
NewMiddleware returns a slog-multi middleware.
type UniformSamplingOption ΒΆ added in v0.2.0
type UniformSamplingOption struct {
// The sample rate for sampling traces in the range [0.0, 1.0].
Rate float64
// Optional hooks
OnAccepted func(context.Context, slog.Record)
OnDropped func(context.Context, slog.Record)
}
func (UniformSamplingOption) NewMiddleware ΒΆ added in v0.2.0
func (o UniformSamplingOption) NewMiddleware() slogmulti.Middleware
NewMiddleware returns a slog-multi middleware.
Source Files
ΒΆ
Click to show internal directories.
Click to hide internal directories.