Reports avaje-metrics data to Graphite and also provides a lower-level GraphiteSender
API for manual sending.
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-metrics-graphite</artifactId>
<version>${version}</version>
</dependency>If the application uses module-info.java, also add:
requires io.avaje.metrics.graphite;import io.avaje.metrics.graphite.GraphiteReporter;
GraphiteReporter reporter = GraphiteReporter.builder()
.prefix("dev.my-app.")
.hostname("graphite.example.com")
.port(2003)
.build();
reporter.report();prefix(...)— prepend a common metric path prefix such asdev.my-app.hostname(...)/port(...)— destination Graphite host and portsocketFactory(...)— custom socket factorybatchSize(...)— tune batchingtimedThresholdMicros(...)— suppress low-value timer metricsregistry(...)— include a non-default registry or customMetricSupplierdatabase(...)— include Ebean database metrics directlyexcludeDefaultRegistry()— report only explicitly added registries/suppliers
Graphite metric paths do not carry tags. When a metric has a label:<value> tag,
the reporter appends the label value to the Graphite metric path. For example,
web.api with label:MyController.myMethod is reported as
web.api.MyController.myMethod.count, web.api.MyController.myMethod.total,
and related timer series. The app.component base name is reported using the
legacy app.<label> path, such as app.MyClass.myMethod.count. Non-label tags
are ignored by this reporter.
If you need low-level manual sending rather than reporter composition, use
GraphiteSender directly:
GraphiteSender sender = GraphiteSender.builder()
.hostname("graphite.example.com")
.port(2003)
.prefix("dev.my-app.")
.build();
sender.connect();
sender.send("10", System.currentTimeMillis() / 1000, "test-metric", ".count");
sender.flush();
sender.close();