You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "davsclaus (via GitHub)" <gi...@apache.org> on 2026/05/26 14:33:55 UTC
[PR] CAMEL-23617: Add option to capture message payload size for observation [camel]
davsclaus opened a new pull request, #23532:
URL: https://github.com/apache/camel/pull/23532
## Summary
Adds message size tracking to Camel, capturing body and header sizes per endpoint for both incoming (IN) and outgoing (OUT) directions.
- Introduces `MessageSizeStrategy` SPI and `DefaultMessageSizeStrategy` for computing body/header byte sizes (supports `byte[]`, `String`, `StreamCache`, `WrappedFile`, `File`, `Path`, `Content-Length` header fallback)
- Tracks min/max/mean sizes per endpoint in `RuntimeEndpointRegistry` via exchange events (`ExchangeCreatedEvent` for IN, `ExchangeSendingEvent` for OUT)
- Exposes size statistics via JMX (`RuntimeEndpointRegistry` MBean), dev console (`EndpointDevConsole`), and CLI (`camel get endpoint`)
- CLI shows `BODY-SIZE`/`HDR-SIZE` columns (mean values) by default when data is available, with `--verbose` for min/max breakdown and `--sort size` support
- Sizes displayed as human-readable (`512 B`, `1.5 KB`, `2.3 MB`) in CLI table, raw bytes in JSON output
- Sets `CamelMessageBodySize` and `CamelMessageHeadersSize` exchange properties for IN direction, usable during routing
- Auto-enabled by the dev profile; requires `messageSizeEnabled=true` and `Extended` statistics level
- Includes bundled `message-size` example for Camel JBang/TUI
- Includes documentation (`message-size.adoc`) and JMX docs update
## Test plan
- [x] `ManagedMessageSizeTest` verifies endpoint-level size statistics and exchange properties
- [x] Validated YAML DSL route via Camel MCP tools
- [x] Manual testing with `camel run` and `camel get endpoint` / `camel get endpoint --verbose` / `camel get endpoint --sort -size`
_Claude Code on behalf of Claus Ibsen_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23617: Add option to capture message payload size for observation [camel]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #23532:
URL: https://github.com/apache/camel/pull/23532#issuecomment-4547742395
<!-- ci-tested-modules -->
:test_tube: **CI tested the following changed modules:**
- `catalog/camel-catalog`
- `core/camel-api`
- `core/camel-base-engine`
- `core/camel-console`
- `core/camel-core-engine`
- `core/camel-main`
- `core/camel-management-api`
- `core/camel-management`
- `core/camel-support`
- `docs`
- `dsl/camel-jbang/camel-jbang-core`
> :information_source: Dependent modules were not tested because the total number of affected modules exceeded the threshold (50). Use the `test-dependents` label to force testing all dependents.
:warning: **Some tests are disabled on GitHub Actions** (`@DisabledIfSystemProperty(named = "ci.env.name")`) and require manual verification:
- `dsl/camel-jbang/camel-jbang-core`: 1 test(s) disabled on GitHub Actions
:bulb: **Manual integration tests recommended:**
> You modified `dsl/camel-jbang/camel-jbang-core`. The related integration tests in `dsl/camel-jbang/camel-jbang-it` are excluded from CI. Consider running them manually:
> ```
> mvn verify -f dsl/camel-jbang/camel-jbang-it -Djbang-it-test
> ```
<details><summary>Build reactor — dependencies compiled but only changed modules were tested (11 modules)</summary>
- Camel :: API
- Camel :: Base Engine
- Camel :: Catalog :: Camel Catalog
- Camel :: Console
- Camel :: Core Engine
- Camel :: Docs
- Camel :: JBang :: Core
- Camel :: Main
- Camel :: Management
- Camel :: Management API
- Camel :: Support
</details>
---
:gear: [View full build and test results](https://github.com/apache/camel/actions/runs/26467205409)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23617: Add option to capture message payload size for observation [camel]
Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on PR #23532:
URL: https://github.com/apache/camel/pull/23532#issuecomment-4545173566
1. The message size is not only per route, its also per endpoint and separated by IN and OUT direction.
2. The default code that calculates header size should be in a try .. catch to ignore any issues and return -1 if it fails to do so. The same for the message body.
3. For OUT then we need to reset stream caching afterwards if the body is stream caching, so when writing the OUT response it is re-readable
4. Update doc that streams (InputStream) is only support when using stream-caching
5. Also mention in docs that this is global feature if enabled, you cannot have fine grained control where to turn this on or off.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23617: Add option to capture message payload size for observation [camel]
Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus merged PR #23532:
URL: https://github.com/apache/camel/pull/23532
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23617: Add option to capture message payload size for observation [camel]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #23532:
URL: https://github.com/apache/camel/pull/23532#issuecomment-4545109522
:star2: Thank you for your contribution to the Apache Camel project! :star2:
:robot: CI automation will test this PR automatically.
:camel: 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 `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](https://camel.apache.org/community/team/#committers) have access to the summary.
:warning: Be careful when sharing logs. Review their contents before sharing them publicly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23617: Add option to capture message payload size for observation [camel]
Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on PR #23532:
URL: https://github.com/apache/camel/pull/23532#issuecomment-4545235450
Addressed all 5 items:
1. **Javadoc fix** — Updated `DefaultConfigurationProperties` javadoc from "per route" to "per endpoint (for both IN and OUT directions)"
2. **Try-catch** — Wrapped both `computeBodySize()` and `computeHeadersSize()` in try-catch, returning -1 on any exception
3. **Stream cache reset** — Added `StreamCache.reset()` after computing body size in all three event paths (IN, OUT sending, OUT reply)
4. **Streaming docs** — Added note that streaming bodies (`InputStream`) require stream caching to be enabled
5. **Global feature docs** — Added note that message size tracking is global, no per-route/per-endpoint control
Also added `ManagedMessageSizeStreamCachingTest` that sends a `ByteArrayInputStream` body through stream caching and verifies the body is still readable after size computation.
_Claude Code on behalf of Claus Ibsen_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org