Skip to content

cli-plugins/plugin: add PersistentPostRunE for shutting down otel providers - #7433

Open
jsternberg wants to merge 1 commit into
docker:masterfrom
jsternberg:trace-and-metrics-shutdown
Open

jsternberg wants to merge 1 commit into
docker:masterfrom
jsternberg:trace-and-metrics-shutdown

Conversation

@jsternberg

Copy link
Copy Markdown
Contributor

OTEL providers provided by this library to plugins were not properly
shut down. Metrics from the CLI were forcibly flushed in a separate area
and the buildx command does its own flushing, but this didn't apply to
traces.

Add shutdown on post run for plugins. This will allow compose to use the
tracer provider from this library rather than roll its own custom one.

@codecov-commenter

codecov-commenter commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 24 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cli-plugins/plugin/plugin.go 0.00% 21 Missing ⚠️
cli/command/telemetry.go 0.00% 1 Missing ⚠️
cli/command/telemetry_docker.go 0.00% 1 Missing ⚠️
cli/command/telemetry_utils.go 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟡 NEEDS ATTENTION

Comment thread cli-plugins/plugin/plugin.go
Comment thread cli-plugins/plugin/plugin.go
…viders

OTEL providers provided by this library to plugins were not properly
shut down. Metrics from the CLI were forcibly flushed in a separate area
and the `buildx` command does its own flushing, but this didn't apply to
traces.

Add shutdown on post run for plugins. This will allow compose to use the
tracer provider from this library rather than roll its own custom one.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
@jsternberg
jsternberg force-pushed the trace-and-metrics-shutdown branch from bcd15ee to f2a66e4 Compare October 23, 2026 18:52
Comment on lines +83 to +84
PersistentPostRunE = func(cmd *cobra.Command, _ []string) error {
persistentPostRunOnce.Do(func() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will only run for commands that succeed - is this what we want here?

}
})
}
wg.Wait()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these Shutdown methods have a guarantee to finish in the given timeout?

If not, perhaps we should run this in a goroutine which we would only wait for the ExportTimeout and if they dont manage to return in that time, just continue with shutdown

@thaJeztah thaJeztah added this to the 29.10.0 milestone Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants