0

I have configured a basic sl4j reporter for a dropwizard (codehale) metrics registry. This is the reporter configuration:

Slf4jReporter.forRegistry(metricRegistry)
                .outputTo(slf4jLogger)
                .convertRatesTo(TimeUnit.SECONDS)
                .convertDurationsTo(TimeUnit.MILLISECONDS)
                .build();
        reporter.start(30, TimeUnit.SECONDS);

The logs I am receiving are not what I expected (expected a parseable output of the timers, counters registered wtih metricRegistry). This is what I am actually seeing every 30 seconds (which matches the reporter configuration):

.... java:55) org.slf4j.helpers.FormattingTuple@39fda09e

Is there anyway to get a useful representation of the codehale metrics (timers, counters etc) in the logs?

kstream
  • 11
  • 4

1 Answers1

0

My answer is not related to the question asked. See the comments below.

Dropwizard has integrated functionality for reporting metrics data. They are called reporters. You need to add additional configuration directives. Example for the SLF4J reporter:

metrics:
  reporters:
    - type: log
      logger: metrics
      markerName: <marker name>

Check the manual here: https://www.dropwizard.io/1.3.8/docs/manual/configuration.html#metrics

zloster
  • 1,149
  • 11
  • 26
  • I apologize if my question was confusing - to clarify: I am using the java codehale metrics as a library into my Java application. I am configuring the sl4j reporter as per docs (https://metrics.dropwizard.io/4.0.0/manual/core.html#man-core-reporters-slf4j) but the output is the data structure name instead of a useful representation of the statistics. "org.slf4j.helpers.FormattingTuple@39fda09e". – kstream Feb 01 '19 at 19:43
  • OK, now I understand. I've added `dropwizard-metrics` 4.0.5 to a simple project. Then I've added the simple steps from the manual (create MetricsRegistry, create Meter instance, mark the Meter in a method, call the method, wait for the output of the reporter). Everything is working fine. My suggestion is to create a clean and very simple project with the Metrics library. Then see if the problem still exists. If there is no problem, than you have something strange going on in your project. You will have to check for dependencies conflicts, library versions and so on. – zloster Feb 03 '19 at 18:22