Skip to content

Commit

Permalink
Add logger name label to prometheus logging metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
janos committed Aug 4, 2023
1 parent bb53e43 commit f926c21
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions logging/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,18 @@ func NewMetrics(options *MetricsOptions) (c *Metrics) {
Name: options.Name,
Help: options.Help,
},
[]string{"level"},
[]string{"logger", "level"},
)
return &Metrics{
vector: vector,
}
}

func (c *Metrics) Inc(level slog.Level) {
c.vector.WithLabelValues(level.String()).Inc()
func (c *Metrics) Inc(loggerName string, level slog.Level) {
c.vector.With(prometheus.Labels{
"logger": loggerName,
"level": level.String(),
}).Inc()
}

// Metrics returns all Prometheus metrics that should be registered.
Expand Down

0 comments on commit f926c21

Please sign in to comment.