2020-03-24 14:15:01 +01:00
|
|
|
package google
|
|
|
|
|
|
|
|
import (
|
|
|
|
"go.opencensus.io/trace"
|
|
|
|
|
2020-03-30 07:23:43 +02:00
|
|
|
"github.com/caos/zitadel/internal/errors"
|
2020-03-24 14:15:01 +01:00
|
|
|
"github.com/caos/zitadel/internal/tracing"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Config struct {
|
|
|
|
ProjectID string
|
|
|
|
MetricPrefix string
|
|
|
|
Fraction float64
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Config) NewTracer() error {
|
|
|
|
if !envIsSet() {
|
2020-03-30 07:23:43 +02:00
|
|
|
return errors.ThrowInvalidArgument(nil, "GOOGL-sdh3a", "env not properly set, GOOGLE_APPLICATION_CREDENTIALS is misconfigured or missing")
|
2020-03-24 14:15:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
tracing.T = &Tracer{projectID: c.ProjectID, metricPrefix: c.MetricPrefix, sampler: trace.ProbabilitySampler(c.Fraction)}
|
|
|
|
|
|
|
|
return tracing.T.Start()
|
|
|
|
}
|