mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-12 00:55:12 +00:00
* chore: move to new org * logging * fix: org rename caos -> zitadel Co-authored-by: adlerhurst <[email protected]>
27 lines
638 B
Go
27 lines
638 B
Go
package otel
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/zitadel/zitadel/internal/telemetry/tracing"
|
|
otlpgrpc "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
|
|
sdk_trace "go.opentelemetry.io/otel/sdk/trace"
|
|
)
|
|
|
|
type Config struct {
|
|
Fraction float64
|
|
MetricPrefix string
|
|
Endpoint string
|
|
}
|
|
|
|
func (c *Config) NewTracer() error {
|
|
sampler := sdk_trace.ParentBased(sdk_trace.TraceIDRatioBased(c.Fraction))
|
|
exporter, err := otlpgrpc.New(context.Background(), otlpgrpc.WithEndpoint(c.Endpoint), otlpgrpc.WithInsecure())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
tracing.T = NewTracer(c.MetricPrefix, sampler, exporter)
|
|
return nil
|
|
}
|