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