mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
have the tracingExporter to own resources it initializes
Signed-off-by: Yingrong Zhao <yingrong.zhao@gmail.com>
This commit is contained in:
parent
ea2f299ba0
commit
1869fa9db2
@ -43,7 +43,7 @@ func validateTracingConfig(samplingRate int) error {
|
||||
type tracingExporter struct {
|
||||
exporter tracesdk.SpanExporter
|
||||
opts []otelgrpc.Option
|
||||
shutdown func(ctx context.Context)
|
||||
provider *tracesdk.TracerProvider
|
||||
}
|
||||
|
||||
func newTracingExporter(ctx context.Context, cfg *Config) (*tracingExporter, error) {
|
||||
@ -80,6 +80,7 @@ func newTracingExporter(ctx context.Context, cfg *Config) (*tracingExporter, err
|
||||
tracesdk.ParentBased(determineSampler(cfg.ExperimentalDistributedTracingSamplingRatePerMillion)),
|
||||
),
|
||||
)
|
||||
|
||||
options := []otelgrpc.Option{
|
||||
otelgrpc.WithPropagators(
|
||||
propagation.NewCompositeTextMapPropagator(
|
||||
@ -103,15 +104,17 @@ func newTracingExporter(ctx context.Context, cfg *Config) (*tracingExporter, err
|
||||
return &tracingExporter{
|
||||
exporter: exporter,
|
||||
opts: options,
|
||||
shutdown: func(ctx context.Context) {
|
||||
traceProvider.Shutdown(ctx)
|
||||
},
|
||||
provider: traceProvider,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (te *tracingExporter) Close(ctx context.Context) {
|
||||
te.exporter.Shutdown(ctx)
|
||||
te.shutdown(ctx)
|
||||
if te.exporter != nil {
|
||||
te.exporter.Shutdown(ctx)
|
||||
}
|
||||
if te.provider != nil {
|
||||
te.provider.Shutdown(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
func determineSampler(samplingRate int) tracesdk.Sampler {
|
||||
|
Loading…
x
Reference in New Issue
Block a user