mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 11:04:25 +00:00
cf6f4d6894
* fix(tracing): parsing of fraction * log id
38 lines
808 B
Go
38 lines
808 B
Go
package log
|
|
|
|
import (
|
|
stdout "go.opentelemetry.io/otel/exporters/stdout/stdouttrace"
|
|
sdk_trace "go.opentelemetry.io/otel/sdk/trace"
|
|
|
|
"github.com/zitadel/zitadel/internal/telemetry/tracing"
|
|
"github.com/zitadel/zitadel/internal/telemetry/tracing/otel"
|
|
)
|
|
|
|
type Config struct {
|
|
Fraction float64
|
|
}
|
|
|
|
func NewTracer(rawConfig map[string]interface{}) (err error) {
|
|
c := new(Config)
|
|
c.Fraction, err = otel.FractionFromConfig(rawConfig["fraction"])
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return c.NewTracer()
|
|
}
|
|
|
|
type Tracer struct {
|
|
otel.Tracer
|
|
}
|
|
|
|
func (c *Config) NewTracer() error {
|
|
sampler := sdk_trace.ParentBased(sdk_trace.TraceIDRatioBased(c.Fraction))
|
|
exporter, err := stdout.New(stdout.WithPrettyPrint())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
tracing.T, err = otel.NewTracer(sampler, exporter)
|
|
return err
|
|
}
|