github.com/thanos-io/thanos@v0.32.5/pkg/tracing/stackdriver/stackdriver.go (about) 1 // Copyright (c) The Thanos Authors. 2 // Licensed under the Apache License 2.0. 3 4 package stackdriver 5 6 import ( 7 "context" 8 "io" 9 10 "github.com/go-kit/log" 11 "github.com/opentracing/opentracing-go" 12 "gopkg.in/yaml.v2" 13 ) 14 15 // Config - YAML configuration. 16 type Config struct { 17 ServiceName string `yaml:"service_name"` 18 ProjectId string `yaml:"project_id"` 19 SampleFactor uint64 `yaml:"sample_factor"` 20 } 21 22 // NewTracer create tracer from YAML. 23 func NewTracer(ctx context.Context, logger log.Logger, conf []byte) (opentracing.Tracer, io.Closer, error) { 24 config := Config{} 25 if err := yaml.Unmarshal(conf, &config); err != nil { 26 return nil, nil, err 27 } 28 return newGCloudTracer(ctx, logger, config.ProjectId, config.SampleFactor, config.ServiceName) 29 }