davsclaus opened a new pull request, #29318: URL: https://github.com/apache/camel/pull/29318
[CAMEL-26678](https://issues.apache.org/jira/browse/CAMEL-26678): the live state of the camel-chaos rules. It is the data for the chaos screen (CAMEL-26608), and also shows in the dev console, the JSON report, `camel get chaos` and the MCP tools. It is part of CAMEL-26667, the findings of the hands-on round. ## What Per rule (the report as text and JSON, and the `chaos` dev console): - **the observed rate next to the rate of the rule**: `rate 23.1% of 30%`, or `rate 20% of 1 in 5` for `rate=every:5`. An `every:N` rule also has `nextFireIn`, the matches until it fires again. - **when it last fired** (`lastFiredAgo`), plus its faults per second over the last minute (`faultsLastMinute`, and `faultsPerSecond`: 60 counts, oldest second first). - **the effect of its faults on the exchanges**: `faulted`, `completed`, `recovered` (by a redelivery of the error handler), `handled` (by the error handler, e.g. the DLC), `failed` and `inFlight`. Each exchange counts once, when its unit of work is done. A lifecycle or stall rule counts the exchanges sent to the endpoint of its route while the route is down (e.g. `direct:x`, `seda:x`), which ties a stop of a route to the orders that then reach the DLQ. Report: - **the last 20 faults**, latest first: timestamp, rule, fault (`error status 503`, `delay 50ms`, ...), hook, route, endpoint without its query (or the step), exchange id. `chaos-clear --reset` clears them. Exchange: - **`CamelChaosRule`**: an exchange property (not a header) with the id of the rule that faulted the exchange, so the tracer, the message history and a DLQ route can tell why the exchange is there. CLI: `camel get chaos` gets `RATE`, `LAST` and `EFFECT` columns, and `--json` gets the new fields. `--report` adds `EFFECT` and a recent faults table. The MCP and `camel ask` tool descriptions mention the live state. ``` PID NAME ID VER STATE MATCHES FIRED SKIPPED RATE LAST ENDS IN EFFECT RULE 80247 chaosdemo r1 1 active 26 6 0 23.1% of 30% 2s ago 49s 5 recovered endpoint=http://localhost:8765/stock* error status=503 rate=0.3 until=1m 80247 chaosdemo r2 1 active 20 5 0 25% of 25% 0s ago 9m49s 5 completed endpoint=http://localhost:8765/stock* delay duration=50ms rate=every:4 ``` ## Notes for review - The effect is a `Synchronization` on the exchange. It is added only when a rule faults the exchange, so an exchange chaos did not touch costs nothing. It refuses handover: a `seda:dlq` dead letter channel would otherwise hand it to the copy in the queue, whose route completes, and a DLQ'd exchange would count as completed. `theEffectIsTheOneOfTheExchangeNotOfTheCopyOfASedaDeadLetterChannel` fails without that. - "Recovered" means the exchange completed with a redelivery after the fault. An exchange without a unit of work (for example a producer template sent straight to an endpoint) gets the property, but no effect. - The lifecycle tie matches by endpoint base URI, so it works for in-process endpoints. An HTTP call to a `platform-http` route is another endpoint and is not tied; the docs say so. - The dev console response schema now also documents `skippedReasons` and `lostAtDlq`, which earlier PRs returned without documenting. ## Tests - New `ChaosLiveStateTest` (9 tests): rate and every:N, the per-second window on the virtual clock, recovered/handled/failed/completed/in-flight, the seda DLC handover, recent faults (ring of 20, step, entry, reset). - Lifecycle effect test in `ChaosLifecycleTest`, a poll fault in the recent faults (`ChaosPollFaultsTest`), `faultText` in `ChaosRuleTest`, and 4 tests in `ListChaosTest`. - camel-chaos: 579 tests green. camel-jbang-core chaos tests and the CLI help golden test are green too. - Live: the hands-on script against `camel run --chaos` with the branch jars passes 43/43. That is the 33 checks from before plus 10 new ones: observed rate, 4 recovered, recent faults, 2 handled by a `seda:dlq` DLC whose route logs `${exchangeProperty.CamelChaosRule}`, and a stall of a seda route. _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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
