mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-24 16:47:47 +00:00
9b6dad18cb
* feat: provide metrics endpoint * config * enable otel metrics by default Co-authored-by: Florian Forster <florian@caos.ch>
31 lines
619 B
Go
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
|
|
}
|