mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-17 14:37:02 +00:00
monitoring: Add OpenMetrics exporter
This patch makes chasquid's monitoring server expose an OpenMetrics metrics endpoint. It adds a new package "expvarom" which implements an HTTP handler that exports expvar variables in the OpenMetrics text format. Then, the handler is registered by the monitoring server at /metrics (where most things expect it to be). The existing exported variables are also extended with descriptions, which is optional, but improves the readability of the metrics.
This commit is contained in:
@@ -56,7 +56,6 @@ package aliases
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"expvar"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
@@ -66,13 +65,15 @@ import (
|
||||
"time"
|
||||
|
||||
"blitiri.com.ar/go/chasquid/internal/envelope"
|
||||
"blitiri.com.ar/go/chasquid/internal/expvarom"
|
||||
"blitiri.com.ar/go/chasquid/internal/normalize"
|
||||
"blitiri.com.ar/go/chasquid/internal/trace"
|
||||
)
|
||||
|
||||
// Exported variables.
|
||||
var (
|
||||
hookResults = expvar.NewMap("chasquid/aliases/hookResults")
|
||||
hookResults = expvarom.NewMap("chasquid/aliases/hookResults",
|
||||
"result", "count of aliases hook results, by hook and result")
|
||||
)
|
||||
|
||||
// Recipient represents a single recipient, after resolving aliases.
|
||||
|
||||
Reference in New Issue
Block a user