mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-05 12:23:03 +02:00
## Summary Add some more metrics: - Authenticate token verification - Authorization log duration - Authorization evaluator and header evaluator - IDP token session creator HTTP and gRPC endpoints are already instrumented via middleware, which covers authenticate, proxy and databroker endpoints. Postgres is also already instrumented using `otelpgx`. ## Related issues - [ENG-2407](https://linear.app/pomerium/issue/ENG-2407/add-additional-metrics-and-tracing-spans-to-pomerium) ## Checklist - [x] reference any related issues - [ ] updated unit tests - [ ] add appropriate label (`enhancement`, `bug`, `breaking`, `dependencies`, `ci`) - [x] ready for review
42 lines
947 B
Go
42 lines
947 B
Go
package metrics
|
|
|
|
import (
|
|
"go.opentelemetry.io/otel"
|
|
"go.opentelemetry.io/otel/exporters/prometheus"
|
|
"go.opentelemetry.io/otel/metric"
|
|
sdk_metric "go.opentelemetry.io/otel/sdk/metric"
|
|
)
|
|
|
|
// Meter is the global meter for Pomerium.
|
|
var Meter metric.Meter
|
|
|
|
func init() {
|
|
e, err := prometheus.New(prometheus.WithNamespace("pomerium"))
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
otel.SetMeterProvider(sdk_metric.NewMeterProvider(
|
|
sdk_metric.WithReader(e),
|
|
))
|
|
|
|
Meter = otel.Meter("")
|
|
}
|
|
|
|
// Int64Counter returns an int64 counter.
|
|
func Int64Counter(name string, options ...metric.Int64CounterOption) metric.Int64Counter {
|
|
c, err := Meter.Int64Counter(name, options...)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return c
|
|
}
|
|
|
|
// Int64Histogram returns an int64 histogram.
|
|
func Int64Histogram(name string, options ...metric.Int64HistogramOption) metric.Int64Histogram {
|
|
c, err := Meter.Int64Histogram(name, options...)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return c
|
|
}
|