mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-14 03:54:21 +00:00
fa9f581d56
* chore: move to new org * logging * fix: org rename caos -> zitadel Co-authored-by: adlerhurst <silvan.reusser@gmail.com>
29 lines
658 B
Go
29 lines
658 B
Go
package log
|
|
|
|
import (
|
|
"github.com/zitadel/zitadel/internal/telemetry/tracing"
|
|
"github.com/zitadel/zitadel/internal/telemetry/tracing/otel"
|
|
stdout "go.opentelemetry.io/otel/exporters/stdout/stdouttrace"
|
|
sdk_trace "go.opentelemetry.io/otel/sdk/trace"
|
|
)
|
|
|
|
type Config struct {
|
|
Fraction float64
|
|
MetricPrefix string
|
|
}
|
|
|
|
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 = &Tracer{Tracer: *(otel.NewTracer(c.MetricPrefix, sampler, exporter))}
|
|
return nil
|
|
}
|