mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-15 20:38:00 +00:00
cf6f4d6894
* fix(tracing): parsing of fraction * log id
40 lines
918 B
Go
40 lines
918 B
Go
package google
|
|
|
|
import (
|
|
texporter "github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace"
|
|
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 {
|
|
ProjectID string
|
|
Fraction float64
|
|
}
|
|
|
|
func NewTracer(rawConfig map[string]interface{}) (err error) {
|
|
c := new(Config)
|
|
c.ProjectID, _ = rawConfig["projectid"].(string)
|
|
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 := texporter.New(texporter.WithProjectID(c.ProjectID))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
tracing.T, err = otel.NewTracer(sampler, exporter)
|
|
return err
|
|
}
|