camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <>
Subject Re: camel-metrics Question
Date Thu, 13 Nov 2014 05:32:10 GMT

See this FAQ

On Thu, Nov 13, 2014 at 5:19 AM, James L Greene <> wrote:
> Just out of curiosity, is there a particular design reason that you can't use variable
substitution/dynamic expressions in the defintion of URI's for the camel-metrics component?
> Consider the following example.  I'm reading files from a source directory, and want
to keep track of the number of records contained in each file.  To pull this off, I need to
set header values to override the metric name:
> from("file://source").
>    to("metrics:counter:source.document.count").
>    split(body().tokenize("\r\n|\n").
>    to("direct:process");
> from("direct:process").
>    setHeater(MetricsConstants.HEADER_METRIC_NAME, simple("source[${header.CamelFileName}].count")).
>    to("metrics:counter:source[].count").
>    ...
> If you have a fairly complicated integration route with several metrics to track, this
really clutters up the route.  It would be much more desireable to do variable substitution
in the URI itself, like this:
> from("direct:process").
>    to("metrics:counter:source[${header.CamelFileName}].count").
>    ...
> I'm just curious as to whether a future rev of the component might be able to eliminate
the use of Headers to override the name portion of the URI.  From a design perspective, would
moving the metric name to a parameter make this any easier to accomplish?  For example:
> from("direct:process").
>    to("metrics:counter?name=source[${header.CamelFileName}].count").
>    ...
> Either way, this component is really helping out with a requirement for my current project!

Claus Ibsen
Red Hat, Inc.
Twitter: davsclaus
Author of Camel in Action:

View raw message