Draft
Conversation
Expose Prometheus counters for the run (daemon) command: - composeflux_deployments_total / composeflux_deployment_failures_total - composeflux_image_updates_total / composeflux_image_update_failures_total - composeflux_stacks_pruned_total Adds --metrics-addr flag (default :9090) with graceful HTTP server shutdown. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Open
There was a problem hiding this comment.
Pull request overview
This PR adds Prometheus instrumentation to ComposeFlux by introducing counter metrics for key reconciliation actions and exposing them via a dedicated /metrics HTTP endpoint on the run command.
Changes:
- Add Prometheus counter metrics for deployments, image updates, failures, and pruning.
- Increment those metrics from the reconciler’s
Sync,SyncImages, andPrunepaths. - Add a
--metrics-addrflag torunto optionally start a/metricsserver with graceful shutdown.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
internal/reconcile/sync.go |
Increments deployment and image update counters (and failure counters) during reconciliation. |
internal/reconcile/prune.go |
Increments a counter when managed stacks are successfully pruned. |
internal/metrics/metrics.go |
Defines and registers the Prometheus CounterVec metrics. |
cmd/composeflux/run.go |
Adds --metrics-addr and starts/stops a Prometheus /metrics HTTP server in daemon mode. |
go.mod |
Promotes github.com/prometheus/client_golang to a direct dependency. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+33
to
+37
| go func() { | ||
| slog.Info("Starting metrics server", "addr", r.MetricsAddr) | ||
| if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed { | ||
| slog.Error("Metrics server failed", "error", err) | ||
| } |
|
|
||
| type RunCmd struct { | ||
| CommonConfig `embed:""` | ||
| MetricsAddr string `name:"metrics-addr" help:"Prometheus metrics listen address. Empty to disable." env:"METRICS_ADDR" default:":9090" group:"Metrics Options:"` |
| if r.MetricsAddr != "" { | ||
| mux := http.NewServeMux() | ||
| mux.Handle("/metrics", promhttp.Handler()) | ||
| srv := &http.Server{Addr: r.MetricsAddr, Handler: mux} |
Update README, docs site, and Getting Started with metrics feature: - Add Prometheus Metrics to features list - Add METRICS_ADDR env var to configuration reference - Add metrics port and env var to sample compose.yml - Update compose-dev.yml with metrics port and dev config Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
composeflux_deployments_total,composeflux_deployment_failures_total,composeflux_image_updates_total,composeflux_image_update_failures_total,composeflux_stacks_pruned_total/metricsendpoint on--metrics-addr(default:9090, empty to disable) for theruncommand onlyMetrics
composeflux_deployments_totalstack_namecomposeflux_deployment_failures_totalstack_namecomposeflux_image_updates_totalstack_namecomposeflux_image_update_failures_totalstack_namecomposeflux_stacks_pruned_totalstack_nameTest plan
--metrics-addr :9090and verifycurl localhost:9090/metricsreturns all 5 metricscomposeflux_deployments_totalincrementscomposeflux_image_updates_totalincrementscomposeflux_stacks_pruned_totalincrements--metrics-addr ""and verify no HTTP server starts🤖 Generated with Claude Code