mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-03 04:16:03 +02:00
* zero: refactor controller * refactor zero telemetry and controller * wire with connect handler * cr
31 lines
592 B
Go
31 lines
592 B
Go
package reporter
|
|
|
|
import (
|
|
"go.opentelemetry.io/otel/sdk/metric"
|
|
)
|
|
|
|
type config struct {
|
|
producers map[string]*metricsProducer
|
|
}
|
|
|
|
type Option func(*config)
|
|
|
|
// WithProducer adds a metric producer to the reporter
|
|
func WithProducer(name string, p metric.Producer) Option {
|
|
return func(c *config) {
|
|
if _, ok := c.producers[name]; ok {
|
|
panic("duplicate producer name " + name)
|
|
}
|
|
c.producers[name] = newProducer(name, p)
|
|
}
|
|
}
|
|
|
|
func getConfig(opts ...Option) config {
|
|
c := config{
|
|
producers: make(map[string]*metricsProducer),
|
|
}
|
|
for _, opt := range opts {
|
|
opt(&c)
|
|
}
|
|
return c
|
|
}
|