Skip to content

Tracer doesn't flush implicitly on shutdown. #7596

@feldentm-SAP

Description

@feldentm-SAP

Description

Currently, shutdown of a tracer requires this wrapper:

// Shutdown will flush any remaining spans and shut down the exporter.
	return tracerProvider.Shutdown
	return func(ctx context.Context) error {
		// apparently, an explicit force flush is required to be sure that buffers are flushed
		tracerProvider.ForceFlush(ctx)
		return tracerProvider.Shutdown(ctx)
	}

Our naive assumption was that Shutdown would also ForceFlush implicitly.
We classify this as a bug, because the result is that even with proper calls to Shutdown, buffered spans will be lost.

Environment

  • OS: linux
  • Architecture: any
  • Go Version: go 1.25.1
  • opentelemetry-go version: go.opentelemetry.io/otel/sdk v1.38.0

Steps To Reproduce

Trying to trace a kubernetes job with defer.End() on a span in main had a 100% success rate for both the issue and the fix.

Expected behavior

Shutdown should call ForceFlush but continue in case of errors, because on EOL for a job, the best you can do is try to flush everything and close all connections.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions