Repository: camel Updated Branches: refs/heads/master 461ecd52f -> 8300779a6
Reformat Camel Metrics CDI example README Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f52a464a Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f52a464a Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f52a464a Branch: refs/heads/master Commit: f52a464ac362099d6766f5b583568e4f8d35e74f Parents: 3cc3172 Author: Antonin Stefanutti <anto...@stefanutti.fr> Authored: Thu Jan 28 15:23:59 2016 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Thu Jan 28 18:56:19 2016 +0100 ---------------------------------------------------------------------- examples/camel-example-cdi-metrics/README.md | 58 +++++++++++++---------- 1 file changed, 34 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/f52a464a/examples/camel-example-cdi-metrics/README.md ---------------------------------------------------------------------- diff --git a/examples/camel-example-cdi-metrics/README.md b/examples/camel-example-cdi-metrics/README.md index 8802c35..ee5dd43 100644 --- a/examples/camel-example-cdi-metrics/README.md +++ b/examples/camel-example-cdi-metrics/README.md @@ -4,11 +4,21 @@ This example illustrates the integration between Camel, Dropwizard Metrics and CDI. -The example emulates an unreliable service that processes a continuous stream of events. The unreliable service fails randomly and metrics get collected to report the number of generated events as well as the total number of attempted, redelivered, failed and successful calls to the service. A SLF4J reporter is configured so that these metrics details get logged every 10 seconds in the console. - -The example is implemented in Java with CDI dependency injection. It uses JBoss Weld as the minimal CDI container to run the application, though you can run the application in any CDI compliant container. - -The `camel-core` and `camel-metrics` components are used in this example. Besides, the Metrics CDI extension is used so that metrics can be injected and custom metrics registered via CDI. For instance, a ratio gauge is registered to monitor the success rate, that is the ratio of success calls on the number of generated events. +The example emulates an unreliable service that processes a continuous stream of events. +The unreliable service fails randomly and metrics get collected to report +the number of generated events as well as the total number of attempted, redelivered, +failed and successful calls to the service. A SLF4J reporter is configured so that +these metrics details get logged every 10 seconds in the console. + +The example is implemented in Java with CDI dependency injection. It uses JBoss Weld +as the minimal CDI container to run the application, though you can run the application +in any CDI compliant container. + +The `camel-core` and `camel-metrics` components are used in this example. +Besides, the Metrics CDI extension is used so that metrics can be injected +and custom metrics registered via CDI. For instance, a ratio gauge is registered +to monitor the success rate, that is the ratio of success calls on the number +of generated events. ### Build @@ -24,29 +34,29 @@ You can run this example using: When the Camel application runs, you should see the calls to the 'unreliable-service' being logged to the console, e.g.: ``` -2016-01-18 15:19:04,390 [ timer://stream] INFO unreliable-service - Processing event #8... -2016-01-18 15:19:06,399 [ timer://stream] ERROR unreliable-service - Failed processing event #8 -2016-01-18 15:19:06,400 [ timer://stream] INFO unreliable-service - Processing event #9... -2016-01-18 15:19:08,410 [ timer://stream] ERROR unreliable-service - Failed processing event #9 -2016-01-18 15:19:08,411 [ timer://stream] INFO unreliable-service - Processing event #10... -2016-01-18 15:19:08,412 [ timer://stream] INFO unreliable-service - Successfully processed event #10 -2016-01-18 15:19:09,415 [ timer://stream] INFO unreliable-service - Processing event #11... -2016-01-18 15:19:09,416 [ timer://stream] INFO unreliable-service - Successfully processed event #11 -2016-01-18 15:19:10,420 [ timer://stream] INFO unreliable-service - Processing event #12... -2016-01-18 15:19:10,421 [ timer://stream] INFO unreliable-service - Successfully processed event #12 -2016-01-18 15:19:11,424 [ timer://stream] INFO unreliable-service - Processing event #13... -2016-01-18 15:19:12,428 [ timer://stream] WARN unreliable-service - Processed event #13 after 1 retries -2016-01-18 15:19:12,430 [ timer://stream] INFO unreliable-service - Successfully processed event #13 +2016-01-18 15:19:04,390 [ timer://stream] INFO unreliable-service - Processing event #8... +2016-01-18 15:19:06,399 [ timer://stream] ERROR unreliable-service - Failed processing event #8 +2016-01-18 15:19:06,400 [ timer://stream] INFO unreliable-service - Processing event #9... +2016-01-18 15:19:08,410 [ timer://stream] ERROR unreliable-service - Failed processing event #9 +2016-01-18 15:19:08,411 [ timer://stream] INFO unreliable-service - Processing event #10... +2016-01-18 15:19:08,412 [ timer://stream] INFO unreliable-service - Successfully processed event #10 +2016-01-18 15:19:09,415 [ timer://stream] INFO unreliable-service - Processing event #11... +2016-01-18 15:19:09,416 [ timer://stream] INFO unreliable-service - Successfully processed event #11 +2016-01-18 15:19:10,420 [ timer://stream] INFO unreliable-service - Processing event #12... +2016-01-18 15:19:10,421 [ timer://stream] INFO unreliable-service - Successfully processed event #12 +2016-01-18 15:19:11,424 [ timer://stream] INFO unreliable-service - Processing event #13... +2016-01-18 15:19:12,428 [ timer://stream] WARN unreliable-service - Processed event #13 after 1 retries +2016-01-18 15:19:12,430 [ timer://stream] INFO unreliable-service - Successfully processed event #13 ``` And every 10 seconds, the metrics report, e.g.: ``` -2016-01-18 15:19:14,360 [rter-1-thread-1] INFO metrics - type=GAUGE, name=success-ratio, value=0.9314661799835947 -2016-01-18 15:19:14,361 [rter-1-thread-1] INFO metrics - type=METER, name=attempt, count=26, mean_rate=1.3682531895692165, m1=1.245416192969619, m5=1.209807850571521, m15=1.2033118138834105, rate_unit=events/second -2016-01-18 15:19:14,361 [rter-1-thread-1] INFO metrics - type=METER, name=error, count=2, mean_rate=0.25121358141009453, m1=0.4, m5=0.4, m15=0.4, rate_unit=events/second -2016-01-18 15:19:14,361 [rter-1-thread-1] INFO metrics - type=METER, name=generated, count=15, mean_rate=0.7210025396112787, m1=0.6455184225121126, m5=0.6098087536676114, m15=0.6033118478925024, rate_unit=events/second -2016-01-18 15:19:14,361 [rter-1-thread-1] INFO metrics - type=METER, name=redelivery, count=11, mean_rate=0.6872842357052532, m1=0.9385926899562456, m5=0.9868864401928024, m15=0.995580155717569, rate_unit=events/second -2016-01-18 15:19:14,361 [rter-1-thread-1] INFO metrics - type=METER, name=success, count=12, mean_rate=0.5768131773739456, m1=0.6012785791263936, m5=0.6000546385677541, m15=0.6000061386568257, rate_unit=events/second +2016-01-18 15:19:14,360 [rter-1-thread-1] INFO metrics - type=GAUGE, name=success-ratio, value=0.9314661799835947 +2016-01-18 15:19:14,361 [rter-1-thread-1] INFO metrics - type=METER, name=attempt, count=26, mean_rate=1.3682531895692165, m1=1.245416192969619, m5=1.209807850571521, m15=1.2033118138834105, rate_unit=events/second +2016-01-18 15:19:14,361 [rter-1-thread-1] INFO metrics - type=METER, name=error, count=2, mean_rate=0.25121358141009453, m1=0.4, m5=0.4, m15=0.4, rate_unit=events/second +2016-01-18 15:19:14,361 [rter-1-thread-1] INFO metrics - type=METER, name=generated, count=15, mean_rate=0.7210025396112787, m1=0.6455184225121126, m5=0.6098087536676114, m15=0.6033118478925024, rate_unit=events/second +2016-01-18 15:19:14,361 [rter-1-thread-1] INFO metrics - type=METER, name=redelivery, count=11, mean_rate=0.6872842357052532, m1=0.9385926899562456, m5=0.9868864401928024, m15=0.995580155717569, rate_unit=events/second +2016-01-18 15:19:14,361 [rter-1-thread-1] INFO metrics - type=METER, name=success, count=12, mean_rate=0.5768131773739456, m1=0.6012785791263936, m5=0.6000546385677541, m15=0.6000061386568257, rate_unit=events/second ``` The Camel application can be stopped pressing `ctrl + c` in the shell.