zero/telemetry: internal envoy stats scraper and metrics producer (#5136)

This commit is contained in:
Denis Mishin 2024-06-16 20:41:05 -04:00 committed by GitHub
parent c3534df885
commit c1dec06afa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 667 additions and 301 deletions

View file

@ -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)
}