MCPcopy
hub / github.com/kopia/kopia / maybeStartTraceExporter

Method maybeStartTraceExporter

cli/observability_flags.go:240–268  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

238}
239
240func (c *observabilityFlags) maybeStartTraceExporter(ctx context.Context) error {
241 if !c.otlpTrace {
242 return nil
243 }
244
245 // Create the OTLP exporter.
246 se := otlptracegrpc.NewUnstarted()
247
248 r := resource.NewWithAttributes(
249 semconv.SchemaURL,
250 semconv.ServiceNameKey.String("kopia"),
251 semconv.ServiceVersionKey.String(repo.BuildVersion),
252 )
253
254 tp := trace.NewTracerProvider(
255 trace.WithBatcher(se),
256 trace.WithResource(r),
257 )
258
259 if err := se.Start(ctx); err != nil {
260 return errors.Wrap(err, "unable to start OTLP exporter")
261 }
262
263 otel.SetTracerProvider(tp)
264
265 c.traceProvider = tp
266
267 return nil
268}
269
270func (c *observabilityFlags) stop(ctx context.Context) {
271 if c.dumpAllocatorStats {

Callers 1

startMethod · 0.95

Calls 2

StartMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected