zitadel/internal/telemetry/metrics/config/config.go
Livio Spring 9b6dad18cb
feat: provide metrics endpoint (#3902)
* feat: provide metrics endpoint

* config

* enable otel metrics by default

Co-authored-by: Florian Forster <florian@caos.ch>
2022-07-18 10:42:32 +02:00

31 lines
619 B
Go

package config
import (
"github.com/zitadel/zitadel/internal/errors"
"github.com/zitadel/zitadel/internal/telemetry/metrics/otel"
)
type Config struct {
Type string
Config map[string]interface{} `mapstructure:",remain"`
}
var meter = map[string]func(map[string]interface{}) error{
"otel": otel.NewTracerFromConfig,
"none": NoMetrics,
"": NoMetrics,
}
func (c *Config) NewMeter() error {
t, ok := meter[c.Type]
if !ok {
return errors.ThrowInternalf(nil, "METER-Dfqsx", "config type %s not supported", c.Type)
}
return t(c.Config)
}
func NoMetrics(_ map[string]interface{}) error {
return nil
}