Skip to content

feat(micrometer): add meter logging on shutdown#21673

Merged
squakez merged 1 commit intoapache:mainfrom
squakez:feat/23089
Mar 2, 2026
Merged

feat(micrometer): add meter logging on shutdown#21673
squakez merged 1 commit intoapache:mainfrom
squakez:feat/23089

Conversation

@squakez
Copy link
Contributor

@squakez squakez commented Mar 2, 2026

This PR enables the possibility to log certain meters (or all of them) when the application is shutting down. This is a great help for monitoring applications that crashes or even controlled shutdown (ie, cronjob, serverless, ...).

Adding the following configurations:

camel.metrics.logMetricsOnShutdown=true #default false
camel.metrics.logMetricsOnShutdownFilters=app.info,camel.exchanges.* #default *

when the application shutdowns it returns:

...
2026-03-02 10:50:13.021  INFO 269172 --- [           main] icrometer.json.AbstractMicrometerService : Micrometer component is stopping, here a list of metrics collected so far.
2026-03-02 10:50:13.049  INFO 269172 --- [           main] icrometer.json.AbstractMicrometerService : {"name":"camel.exchanges.external.redeliveries","type":"counter","value":0.0,"tags":{"routeId":"","kind":"CamelRoute","camelContext":"camel-1","eventType":"context"}}
2026-03-02 10:50:13.050  INFO 269172 --- [           main] icrometer.json.AbstractMicrometerService : {"name":"camel.exchanges.succeeded","type":"counter","value":0.0,"tags":{"routeId":"","kind":"CamelRoute","camelContext":"camel-1","eventType":"context"}}
2026-03-02 10:50:13.050  INFO 269172 --- [           main] icrometer.json.AbstractMicrometerService : {"name":"camel.exchanges.failed","type":"counter","value":0.0,"tags":{"routeId":"","kind":"CamelRoute","camelContext":"camel-1","eventType":"context"}}
2026-03-02 10:50:13.050  INFO 269172 --- [           main] icrometer.json.AbstractMicrometerService : {"name":"camel.exchanges.total","type":"counter","value":0.0,"tags":{"routeId":"","kind":"CamelRoute","camelContext":"camel-1","eventType":"context"}}
2026-03-02 10:50:13.051  INFO 269172 --- [           main] icrometer.json.AbstractMicrometerService : {"name":"app.info","type":"gauge","value":"NaN","tags":{"camel.runtime.provider":"Main","camel.runtime.version":"4.19.0-SNAPSHOT","camel.context":"camel-1","camel.version":"4.19.0-SNAPSHOT"}}
2026-03-02 10:50:13.051  INFO 269172 --- [           main] icrometer.json.AbstractMicrometerService : {"name":"camel.exchanges.failures.handled","type":"counter","value":0.0,"tags":{"routeId":"","kind":"CamelRoute","camelContext":"camel-1","eventType":"context"}}
2026-03-02 10:50:13.055  INFO 269172 --- [ntloop-thread-0] tform.http.vertx.VertxPlatformHttpServer : Vert.x HttpServer stopped
2026-03-02 10:50:13.069  INFO 269172 --- [           main] e.camel.impl.engine.AbstractCamelContext : Apache Camel 4.19.0-SNAPSHOT (camel-1) shutdown in 62ms (uptime:2s)

...

Closes CAMEL-23089

Description

Target

  • I checked that the commit is targeting the correct branch (Camel 4 uses the main branch)

Tracking

  • If this is a large change, bug fix, or code improvement, I checked there is a JIRA issue filed for the change (usually before you start working on it).

Apache Camel coding standards and style

  • I checked that each commit in the pull request has a meaningful subject line and body.
  • I have run mvn clean install -DskipTests locally from root folder and I have committed all auto-generated changes.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2026

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using build-all, build-dependents, skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@davsclaus
Copy link
Contributor

There are uncommitted changes
HEAD detached at pull/21673/merge
Changes not staged for commit:
(use "git add ..." to update what will be committed)
(use "git restore ..." to discard changes in working directory)
modified: catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json

@davsclaus
Copy link
Contributor

Maybe CSB and/or CEQ need to add these options as well

@squakez
Copy link
Contributor Author

squakez commented Mar 2, 2026

Maybe CSB and/or CEQ need to add these options as well

Yeah, I need to check that part once this is merged, thanks.

@squakez squakez merged commit 634c94f into apache:main Mar 2, 2026
5 checks passed
@squakez squakez deleted the feat/23089 branch March 2, 2026 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants