35 lines
807 B
Go
Raw Normal View History

2020-03-24 14:15:01 +01:00
package config
import (
"github.com/zitadel/zitadel/internal/telemetry/tracing/google"
"github.com/zitadel/zitadel/internal/telemetry/tracing/log"
"github.com/zitadel/zitadel/internal/telemetry/tracing/otel"
"github.com/zitadel/zitadel/internal/zerrors"
2020-03-24 14:15:01 +01:00
)
2022-04-28 14:44:13 +02:00
type Config struct {
2020-03-24 14:15:01 +01:00
Type string
2022-04-28 14:44:13 +02:00
Config map[string]interface{} `mapstructure:",remain"`
2020-03-24 14:15:01 +01:00
}
2022-04-28 14:44:13 +02:00
func (c *Config) NewTracer() error {
t, ok := tracer[c.Type]
2020-03-24 14:15:01 +01:00
if !ok {
return zerrors.ThrowInternalf(nil, "TRACE-dsbjh", "config type %s not supported", c.Type)
2020-03-24 14:15:01 +01:00
}
2022-04-28 14:44:13 +02:00
return t(c.Config)
2020-03-24 14:15:01 +01:00
}
2020-07-09 14:34:20 +02:00
2022-04-28 14:44:13 +02:00
var tracer = map[string]func(map[string]interface{}) error{
"otel": otel.NewTracerFromConfig,
"google": google.NewTracer,
"log": log.NewTracer,
"none": NoTracer,
"": NoTracer,
}
2020-07-09 14:34:20 +02:00
2022-04-28 14:44:13 +02:00
func NoTracer(_ map[string]interface{}) error {
2020-07-09 14:34:20 +02:00
return nil
}