Documentation
¶
Index ¶
- Constants
- func ByExcluding(predicate func(*core.LogEvent) bool) core.LogEventFilter
- func ByIncluding(predicate func(*core.LogEvent) bool) core.LogEventFilter
- func IsSamplingDebugEnabled() bool
- func MatchAllProperties(matchers ...core.LogEventFilter) core.LogEventFilter
- func MatchAnyProperty(matchers ...core.LogEventFilter) core.LogEventFilter
- func MatchProperty(propertyName string, expectedValue any) core.LogEventFilter
- func MatchPropertyAbsent(propertyName string) core.LogEventFilter
- func MatchPropertyContains(propertyName string, substring string) core.LogEventFilter
- func MatchPropertyExists(propertyName string) core.LogEventFilter
- func MatchPropertyRegex(propertyName string, pattern string) core.LogEventFilter
- func MinimumLevelFilter(level core.LogEventLevel) core.LogEventFilter
- func SetSamplingDebugEnabled(enabled bool)
- func When(condition bool, filter core.LogEventFilter) core.LogEventFilter
- type BackoffCounter
- type BackoffState
- type CompositeFilter
- type ExpressionFilter
- type HashSamplingFilter
- type LevelFilter
- type NotFilter
- type OrFilter
- type PerMessageSamplingFilter
- func NewBackoffSamplingFilter(key string, factor float64, state *BackoffState) *PerMessageSamplingFilter
- func NewConditionalSamplingFilter(predicate func() bool, n uint64) *PerMessageSamplingFilter
- func NewCounterSamplingFilter(n uint64) *PerMessageSamplingFilter
- func NewDurationSamplingFilter(duration time.Duration) *PerMessageSamplingFilter
- func NewFirstNSamplingFilter(n uint64) *PerMessageSamplingFilter
- func NewGroupSamplingFilter(groupName string, n uint64, manager *SamplingGroupManager) *PerMessageSamplingFilter
- func NewRateSamplingFilter(rate float32) *PerMessageSamplingFilter
- type PredicateFilter
- type RateLimitFilter
- type SamplingFilter
- type SamplingGroupManager
- func (m *SamplingGroupManager) CacheHits() uint64
- func (m *SamplingGroupManager) CacheMisses() uint64
- func (m *SamplingGroupManager) CacheStats() (hits, misses uint64)
- func (m *SamplingGroupManager) GetOrCreateGroup(name string) *atomic.Uint64
- func (m *SamplingGroupManager) ResetAll()
- func (m *SamplingGroupManager) ResetGroup(name string)
- func (m *SamplingGroupManager) Warmup(groupNames []string)
- type SamplingMode
- type SamplingStats
- type SourceContextLevelFilter
- func (f *SourceContextLevelFilter) AddOverride(sourceContext string, level core.LogEventLevel)
- func (f *SourceContextLevelFilter) IsEnabled(event *core.LogEvent) bool
- func (f *SourceContextLevelFilter) RemoveOverride(sourceContext string)
- func (f *SourceContextLevelFilter) SetDefaultLevel(level core.LogEventLevel)
Constants ¶
const ( // DefaultSamplingCacheCapacity is the default capacity for LRU caches used in sampling DefaultSamplingCacheCapacity = 10000 // DefaultBackoffFactor is the default multiplication factor for exponential backoff when invalid values are provided DefaultBackoffFactor = 2.0 )
Default constants for sampling configurations
Variables ¶
This section is empty.
Functions ¶
func ByExcluding ¶
func ByExcluding(predicate func(*core.LogEvent) bool) core.LogEventFilter
ByExcluding creates a filter that excludes events matching the predicate.
func ByIncluding ¶
func ByIncluding(predicate func(*core.LogEvent) bool) core.LogEventFilter
ByIncluding creates a filter that includes only events matching the predicate.
func IsSamplingDebugEnabled ¶ added in v0.10.0
func IsSamplingDebugEnabled() bool
IsSamplingDebugEnabled returns whether sampling debug is enabled
func MatchAllProperties ¶
func MatchAllProperties(matchers ...core.LogEventFilter) core.LogEventFilter
MatchAllProperties creates a filter that matches when all properties match.
func MatchAnyProperty ¶
func MatchAnyProperty(matchers ...core.LogEventFilter) core.LogEventFilter
MatchAnyProperty creates a filter that matches when any of the properties match.
func MatchProperty ¶
func MatchProperty(propertyName string, expectedValue any) core.LogEventFilter
MatchProperty creates a filter that matches when a property equals a specific value.
func MatchPropertyAbsent ¶
func MatchPropertyAbsent(propertyName string) core.LogEventFilter
MatchPropertyAbsent creates a filter that matches when a property does not exist.
func MatchPropertyContains ¶
func MatchPropertyContains(propertyName string, substring string) core.LogEventFilter
MatchPropertyContains creates a filter that matches when a property contains a substring.
func MatchPropertyExists ¶
func MatchPropertyExists(propertyName string) core.LogEventFilter
MatchPropertyExists creates a filter that matches when a property exists.
func MatchPropertyRegex ¶
func MatchPropertyRegex(propertyName string, pattern string) core.LogEventFilter
MatchPropertyRegex creates a filter that matches when a property matches a regex pattern.
func MinimumLevelFilter ¶
func MinimumLevelFilter(level core.LogEventLevel) core.LogEventFilter
MinimumLevelFilter is a convenience function that creates a level filter.
func SetSamplingDebugEnabled ¶ added in v0.10.0
func SetSamplingDebugEnabled(enabled bool)
SetSamplingDebugEnabled sets the sampling debug flag in a thread-safe manner
func When ¶
func When(condition bool, filter core.LogEventFilter) core.LogEventFilter
When creates a conditional filter that applies when the condition is true.
Types ¶
type BackoffCounter ¶ added in v0.10.0
type BackoffCounter struct {
// contains filtered or unexported fields
}
BackoffCounter tracks state for exponential backoff sampling.
type BackoffState ¶ added in v0.10.0
type BackoffState struct {
// contains filtered or unexported fields
}
BackoffState manages exponential backoff sampling state with LRU eviction.
func NewBackoffState ¶ added in v0.10.0
func NewBackoffState(capacity int) *BackoffState
NewBackoffState creates a new backoff state manager with the specified capacity.
func (*BackoffState) GetOrCreateCounter ¶ added in v0.10.0
func (b *BackoffState) GetOrCreateCounter(key string, factor float64) *BackoffCounter
GetOrCreateCounter returns the backoff counter for a key.
func (*BackoffState) Warmup ¶ added in v0.10.0
func (b *BackoffState) Warmup(keys []string, defaultFactor float64)
Warmup pre-populates the cache with common backoff keys to avoid cold-start spikes.
type CompositeFilter ¶
type CompositeFilter struct {
// contains filtered or unexported fields
}
CompositeFilter combines multiple filters with AND logic.
func NewCompositeFilter ¶
func NewCompositeFilter(filters ...core.LogEventFilter) *CompositeFilter
NewCompositeFilter creates a filter that requires all sub-filters to pass.
func (*CompositeFilter) Add ¶
func (f *CompositeFilter) Add(filter core.LogEventFilter)
Add adds a new filter to the composite.
type ExpressionFilter ¶
type ExpressionFilter struct {
// contains filtered or unexported fields
}
ExpressionFilter filters log events based on property values.
func NewExpressionFilter ¶
func NewExpressionFilter(propertyName string, matcher func(any) bool) *ExpressionFilter
NewExpressionFilter creates a filter that matches based on a property value.
type HashSamplingFilter ¶
type HashSamplingFilter struct {
// contains filtered or unexported fields
}
HashSamplingFilter samples events based on a hash of a property value. This ensures consistent sampling for the same property values.
func NewHashSamplingFilter ¶
func NewHashSamplingFilter(propertyName string, rate float32) *HashSamplingFilter
NewHashSamplingFilter creates a filter that samples based on property value hash.
type LevelFilter ¶
type LevelFilter struct {
// contains filtered or unexported fields
}
LevelFilter filters log events based on their level.
func NewLevelFilter ¶
func NewLevelFilter(minimumLevel core.LogEventLevel) *LevelFilter
NewLevelFilter creates a filter that only allows events at or above the specified level.
type NotFilter ¶
type NotFilter struct {
// contains filtered or unexported fields
}
NotFilter inverts the result of another filter.
func NewNotFilter ¶
func NewNotFilter(inner core.LogEventFilter) *NotFilter
NewNotFilter creates a filter that inverts another filter's result.
type OrFilter ¶
type OrFilter struct {
// contains filtered or unexported fields
}
OrFilter combines multiple filters with OR logic.
func NewOrFilter ¶
func NewOrFilter(filters ...core.LogEventFilter) *OrFilter
NewOrFilter creates a filter that passes if any sub-filter passes.
type PerMessageSamplingFilter ¶ added in v0.10.0
type PerMessageSamplingFilter struct {
// contains filtered or unexported fields
}
PerMessageSamplingFilter provides per-message sampling capabilities.
func NewBackoffSamplingFilter ¶ added in v0.10.0
func NewBackoffSamplingFilter(key string, factor float64, state *BackoffState) *PerMessageSamplingFilter
NewBackoffSamplingFilter creates a filter with exponential backoff sampling.
func NewConditionalSamplingFilter ¶ added in v0.10.0
func NewConditionalSamplingFilter(predicate func() bool, n uint64) *PerMessageSamplingFilter
NewConditionalSamplingFilter creates a filter that samples based on a predicate.
func NewCounterSamplingFilter ¶ added in v0.10.0
func NewCounterSamplingFilter(n uint64) *PerMessageSamplingFilter
NewCounterSamplingFilter creates a filter that samples every nth message.
func NewDurationSamplingFilter ¶ added in v0.10.0
func NewDurationSamplingFilter(duration time.Duration) *PerMessageSamplingFilter
NewDurationSamplingFilter creates a filter that samples at most once per duration.
func NewFirstNSamplingFilter ¶ added in v0.10.0
func NewFirstNSamplingFilter(n uint64) *PerMessageSamplingFilter
NewFirstNSamplingFilter creates a filter that logs only the first n occurrences.
func NewGroupSamplingFilter ¶ added in v0.10.0
func NewGroupSamplingFilter(groupName string, n uint64, manager *SamplingGroupManager) *PerMessageSamplingFilter
NewGroupSamplingFilter creates a filter that samples within a named group.
func NewRateSamplingFilter ¶ added in v0.10.0
func NewRateSamplingFilter(rate float32) *PerMessageSamplingFilter
NewRateSamplingFilter creates a filter that samples a percentage of messages.
func (*PerMessageSamplingFilter) GetStats ¶ added in v0.10.0
func (f *PerMessageSamplingFilter) GetStats() SamplingStats
GetStats returns the current sampling statistics.
func (*PerMessageSamplingFilter) IsEnabled ¶ added in v0.10.0
func (f *PerMessageSamplingFilter) IsEnabled(event *core.LogEvent) bool
IsEnabled determines if the event should be logged based on the sampling mode.
func (*PerMessageSamplingFilter) Reset ¶ added in v0.10.0
func (f *PerMessageSamplingFilter) Reset()
Reset resets the sampling counters.
type PredicateFilter ¶
type PredicateFilter struct {
// contains filtered or unexported fields
}
PredicateFilter filters log events based on a custom predicate function.
func NewPredicateFilter ¶
func NewPredicateFilter(predicate func(*core.LogEvent) bool) *PredicateFilter
NewPredicateFilter creates a filter that uses a custom predicate function.
type RateLimitFilter ¶
type RateLimitFilter struct {
// contains filtered or unexported fields
}
RateLimitFilter limits the number of events per time window.
func NewRateLimitFilter ¶
func NewRateLimitFilter(maxEvents int, windowNanos int64) *RateLimitFilter
NewRateLimitFilter creates a filter that limits events to maxEvents per window.
type SamplingFilter ¶
type SamplingFilter struct {
// contains filtered or unexported fields
}
SamplingFilter filters log events based on sampling rules.
func NewSamplingFilter ¶
func NewSamplingFilter(rate float32) *SamplingFilter
NewSamplingFilter creates a filter that samples events at the specified rate. Rate should be between 0.0 (no events) and 1.0 (all events).
type SamplingGroupManager ¶ added in v0.10.0
type SamplingGroupManager struct {
// contains filtered or unexported fields
}
SamplingGroupManager manages shared counters for sampling groups with LRU eviction.
func NewSamplingGroupManager ¶ added in v0.10.0
func NewSamplingGroupManager(capacity int) *SamplingGroupManager
NewSamplingGroupManager creates a new sampling group manager with the specified capacity.
func (*SamplingGroupManager) CacheHits ¶ added in v0.10.0
func (m *SamplingGroupManager) CacheHits() uint64
CacheHits returns the number of cache hits.
func (*SamplingGroupManager) CacheMisses ¶ added in v0.10.0
func (m *SamplingGroupManager) CacheMisses() uint64
CacheMisses returns the number of cache misses.
func (*SamplingGroupManager) CacheStats ¶ added in v0.10.0
func (m *SamplingGroupManager) CacheStats() (hits, misses uint64)
CacheStats returns both hit and miss statistics.
func (*SamplingGroupManager) GetOrCreateGroup ¶ added in v0.10.0
func (m *SamplingGroupManager) GetOrCreateGroup(name string) *atomic.Uint64
GetOrCreateGroup returns the counter for a group, creating it if necessary.
func (*SamplingGroupManager) ResetAll ¶ added in v0.10.0
func (m *SamplingGroupManager) ResetAll()
ResetAll resets all group counters by clearing the cache.
func (*SamplingGroupManager) ResetGroup ¶ added in v0.10.0
func (m *SamplingGroupManager) ResetGroup(name string)
ResetGroup resets the counter for a specific group.
func (*SamplingGroupManager) Warmup ¶ added in v0.10.0
func (m *SamplingGroupManager) Warmup(groupNames []string)
Warmup pre-populates the cache with common group names to avoid cold-start spikes.
type SamplingMode ¶ added in v0.10.0
type SamplingMode int
SamplingMode represents the type of sampling active on the filter.
const ( ModeNone SamplingMode = iota ModeCounter ModeRate ModeDuration ModeFirst ModeGroup ModeConditional ModeBackoff )
type SamplingStats ¶ added in v0.10.0
SamplingStats contains sampling statistics.
type SourceContextLevelFilter ¶
type SourceContextLevelFilter struct {
// contains filtered or unexported fields
}
SourceContextLevelFilter filters log events based on source context and minimum level.
func NewSourceContextLevelFilter ¶
func NewSourceContextLevelFilter(defaultLevel core.LogEventLevel, overrides map[string]core.LogEventLevel) *SourceContextLevelFilter
NewSourceContextLevelFilter creates a new filter with source context level overrides.
func (*SourceContextLevelFilter) AddOverride ¶
func (f *SourceContextLevelFilter) AddOverride(sourceContext string, level core.LogEventLevel)
AddOverride adds or updates a source context level override.
func (*SourceContextLevelFilter) IsEnabled ¶
func (f *SourceContextLevelFilter) IsEnabled(event *core.LogEvent) bool
IsEnabled determines if a log event should be processed based on its source context and level.
func (*SourceContextLevelFilter) RemoveOverride ¶
func (f *SourceContextLevelFilter) RemoveOverride(sourceContext string)
RemoveOverride removes a source context level override.
func (*SourceContextLevelFilter) SetDefaultLevel ¶
func (f *SourceContextLevelFilter) SetDefaultLevel(level core.LogEventLevel)
SetDefaultLevel updates the default minimum level.