Documentation
¶
Overview ¶
Package app_metrics provides application-level metrics including log sampling statistics. It tracks the count of sampled and dropped log entries at different log levels.
Example usage:
logCounter := app_metrics.NewLogCounter(reg) logger := zap.New(core, zap.Hooks( logCounter.SampledLogCounter(), logCounter.DroppedLogCounter(), ), )
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LogCounter ¶
type LogCounter struct {
// contains filtered or unexported fields
}
LogCounter collects metrics for log sampling, tracking the count of sampled and dropped log entries at different log levels.
func NewLogCounter ¶
func NewLogCounter(registry *metrics.Registry) LogCounter
NewLogCounter creates a new LogCounter instance and registers its metrics with the provided registry. Metrics are labeled by log level and sampling status.
func (LogCounter) DroppedLogCounter ¶
func (c LogCounter) DroppedLogCounter() func(zapcore.Entry, zapcore.SamplingDecision)
DroppedLogCounter returns a hook function that increments the dropped counter when a log entry is dropped due to sampling.
func (LogCounter) SampledLogCounter ¶
func (c LogCounter) SampledLogCounter() func(entry zapcore.Entry) error
SampledLogCounter returns a hook function that increments the sampled counter when a log entry is sampled (not dropped due to sampling).