gnodet opened a new pull request, #31365:
URL: https://github.com/apache/camel/pull/31365

   ## Summary
   Fixed two issues in camel-opentelemetry-metrics component as described in 
[CAMEL-27959](https://issues.apache.org/jira/browse/CAMEL-27959):
   
   ### 1. Headers leak on expression error
   When an expression (metric name, description, or attributes) fails in 
`AbstractOpenTelemetryProducer.process()`, the `clearMetricsHeaders()` in the 
finally block was skipped, leaving `CamelMetrics*` headers on the message.
   
   **Fix:** Moved all expression evaluations inside the try block so that the 
finally block with `clearMetricsHeaders()` is always executed, even when an 
expression throws an exception.
   
   ### 2. Distribution summary silently skips null values  
   When a configured value expression evaluates to null in 
`DistributionSummaryProducer.doProcess()`, it silently recorded nothing, while 
`CounterProducer` throws `IllegalArgumentException` in the same case 
(inconsistent behavior).
   
   **Fix:** Added null check to throw `IllegalArgumentException` when the 
configured value expression evaluates to null, making it consistent with 
`CounterProducer`.
   
   ## Test plan
   - Added test `testHeadersAreClearedEvenWhenExpressionFails` to verify 
headers are cleared even on expression failure
   - Added tests `testValueFromBodyNotNumber`, `testValueFromBodyNull`, and 
`testValueFromHeaderMissing` to verify distribution summary throws exception 
for null values
   
   🤖 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]

Reply via email to