Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit 15d66c2

Browse files
committed
Add an example Dropwizard application (#2)
* Add example Dropwizard application * Link to example/ in main README
1 parent db33e3b commit 15d66c2

File tree

7 files changed

+725
-21
lines changed

7 files changed

+725
-21
lines changed

README.md

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,29 +40,16 @@ metric.reporters=com.simple.metrics.kafka.DropwizardReporter
4040

4141
That client will now automatically register all of its built-in
4242
metrics with a Dropwizard `MetricRegistry` when it's initialized.
43+
The registry is discovered by calling
44+
`SharedMetricRegistries.getOrCreate("default")`,
45+
so to direct `DropwizardReporter` to a particular registry, make
46+
sure to call `SharedMetricRegistries.add("default", myRegistry)`
47+
before instantiating Kafka clients if you want metrics to belong
48+
to `myRegistry`.
4349

44-
## Integration with Dropwizard Applications
45-
46-
The reporter calls `SharedMetricRegistries.getOrCreate("default")`
47-
to discover a registry. To make sure `DropwizardReporter` instances report
48-
to the main metrics registry of a Dropwizard application, call
49-
the following in your `run` method before defining any Kafka clients
50-
([this will be done by default in Dropwizard 1.0+](https://github.com/dropwizard/dropwizard/pull/1513)):
51-
```java
52-
public class MyApplication extends Application<MyConfiguration> {
53-
// [...]
54-
@Override
55-
public void run(MyConfiguration configuration, environment: Environment) {
56-
SharedMetricRegistries.add("default", environment.metrics());
57-
// [...]
58-
}
59-
}
60-
```
50+
For a full example of integrating Kafka client metrics in a Dropwizard
51+
application, see [example/](example/).
6152

62-
Metrics will be published with a prefix of
63-
`<metrics-prefix>.org.apache.kafka.common.metrics`
64-
where `metric-prefix` is the global prefix
65-
you've configured for a given reporter.
6653

6754
## Configuration (Optional)
6855

0 commit comments

Comments
 (0)