Skip to content

Add metrics for log events #3150

Open
Open
@StephenButtolph

Description

@StephenButtolph

Different log levels are frequently not enabled when running in production due to processing costs. However, significant changes in the frequency of logs is unexpected. To enable monitoring of disabled logs, it would be nice to add a metric that records how frequently different log levels would be logged.

This interface defines the different log levels:

// Log that a fatal error has occurred. The program should likely exit soon
// after this is called
Fatal(msg string, fields ...zap.Field)
// Log that an error has occurred. The program should be able to recover
// from this error
Error(msg string, fields ...zap.Field)
// Log that an event has occurred that may indicate a future error or
// vulnerability
Warn(msg string, fields ...zap.Field)
// Log an event that may be useful for a user to see to measure the progress
// of the protocol
Info(msg string, fields ...zap.Field)
// Log an event that may be useful for understanding the order of the
// execution of the protocol
Trace(msg string, fields ...zap.Field)
// Log an event that may be useful for a programmer to see when debuging the
// execution of the protocol
Debug(msg string, fields ...zap.Field)
// Log extremely detailed events that can be useful for inspecting every
// aspect of the program
Verbo(msg string, fields ...zap.Field)

It would be nice to add metrics here:

// Should only be called from [Level] functions.
func (l *log) log(level Level, msg string, fields ...zap.Field) {
if ce := l.internalLogger.Check(zapcore.Level(level), msg); ce != nil {
ce.Write(fields...)
}
}
that would count the number of calls by loggerName and log level

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Backlog 🧊

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions