mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-29 08:57:18 +02:00
zero/telemetry: internal envoy stats scraper and metrics producer (#5136)
This commit is contained in:
parent
c3534df885
commit
c1dec06afa
19 changed files with 667 additions and 301 deletions
|
@ -5,25 +5,20 @@ import (
|
|||
)
|
||||
|
||||
type config struct {
|
||||
producers map[string]*metricsProducer
|
||||
producers []metric.Producer
|
||||
}
|
||||
|
||||
type Option func(*config)
|
||||
|
||||
// WithProducer adds a metric producer to the reporter
|
||||
func WithProducer(name string, p metric.Producer) Option {
|
||||
func WithProducer(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)
|
||||
c.producers = append(c.producers, p)
|
||||
}
|
||||
}
|
||||
|
||||
func getConfig(opts ...Option) config {
|
||||
c := config{
|
||||
producers: make(map[string]*metricsProducer),
|
||||
}
|
||||
var c config
|
||||
for _, opt := range opts {
|
||||
opt(&c)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue