Skip to content

Commit 4e9d667

Browse files
committed
Statsd - change metric keys to datasource and ebean and "label" tag name
1 parent 4ea71bf commit 4e9d667

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

metrics-statsd/src/main/java/io/avaje/metrics/statsd/DatabaseReporter.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,27 +60,27 @@ private void poolMetrics(boolean verbose, DataSourcePool pool, String tag) {
6060
if (verbose) {
6161
poolMetrics(pool, tag);
6262
} else {
63-
reporter.gaugeWithTimestamp("db.pool.size", pool.size(), epochSecs, dbTag, tag);
63+
reporter.gaugeWithTimestamp("datasource.pool.size", pool.size(), epochSecs, dbTag, tag);
6464
}
6565
}
6666

6767
private void poolMetrics(DataSourcePool pool, String tag) {
6868
PoolStatus status = pool.status(true);
6969
int size = status.busy() + status.free();
70-
reporter.gaugeWithTimestamp("db.pool.size", size, epochSecs, dbTag, tag);
70+
reporter.gaugeWithTimestamp("datasource.pool.size", size, epochSecs, dbTag, tag);
7171

7272
long meanAcquireMicros = status.meanAcquireNanos() / 1000;
73-
reporter.gaugeWithTimestamp("db.pool.meanAcquireMicros", meanAcquireMicros, epochSecs, dbTag, tag);
73+
reporter.gaugeWithTimestamp("datasource.pool.meanAcquireMicros", meanAcquireMicros, epochSecs, dbTag, tag);
7474

75-
reporter.gaugeWithTimestamp("db.pool.usageCount", status.hitCount(), epochSecs, dbTag, tag);
76-
reporter.gaugeWithTimestamp("db.pool.acquireMicros", status.totalAcquireMicros(), epochSecs, dbTag, tag);
75+
reporter.gaugeWithTimestamp("datasource.pool.usageCount", status.hitCount(), epochSecs, dbTag, tag);
76+
reporter.gaugeWithTimestamp("datasource.pool.acquireMicros", status.totalAcquireMicros(), epochSecs, dbTag, tag);
7777
int waitCount = status.waitCount();
7878
if (waitCount > 0) {
79-
reporter.gaugeWithTimestamp("db.pool.waitCount", waitCount, epochSecs, dbTag, tag);
79+
reporter.gaugeWithTimestamp("datasource.pool.waitCount", waitCount, epochSecs, dbTag, tag);
8080
}
8181
long waitMicros = status.totalWaitMicros();
8282
if (waitMicros > 0) {
83-
reporter.gaugeWithTimestamp("db.pool.waitMicros", waitMicros, epochSecs, dbTag, tag);
83+
reporter.gaugeWithTimestamp("datasource.pool.waitMicros", waitMicros, epochSecs, dbTag, tag);
8484
}
8585
}
8686

@@ -97,27 +97,27 @@ private void report() {
9797
}
9898

9999
private void reportCountMetric(MetaCountMetric countMetric) {
100-
reporter.count(nm("db.count.", countMetric.name()), countMetric.count(), dbTag);
100+
reporter.count(nm("ebean.count.", countMetric.name()), countMetric.count(), dbTag);
101101
}
102102

103103
private void reportTimedMetric(MetaTimedMetric metric) {
104104
final String name = metric.name();
105105
if (name.startsWith("txn.")) {
106-
reportMetric(metric, "db.txn", dbTag, "name:" + qry(name));
106+
reportMetric(metric, "ebean.txn", dbTag, "label:" + qry(name));
107107
} else {
108-
reportMetric(metric, nm("db.timed.", name), dbTag);
108+
reportMetric(metric, nm("ebean.timed.", name), dbTag);
109109
}
110110
}
111111

112112
private void reportQueryMetric(MetaQueryMetric metric) {
113113
final var name = metric.name();
114-
final var queryTag = "name:" + qry(name);
114+
final var queryTag = "label:" + qry(name);
115115
if (name.startsWith("orm")) {
116-
reportMetric(metric, "db.query", dbTag, "type:orm", queryTag);
116+
reportMetric(metric, "ebean.query", dbTag, "type:orm", queryTag);
117117
} else if (name.startsWith("sql")) {
118-
reportMetric(metric, "db.query", dbTag, "type:sql", queryTag);
118+
reportMetric(metric, "ebean.query", dbTag, "type:sql", queryTag);
119119
} else {
120-
reportMetric(metric, "db.query", dbTag, "type:other", queryTag);
120+
reportMetric(metric, "ebean.query", dbTag, "type:other", queryTag);
121121
}
122122
}
123123

metrics-statsd/src/main/java/io/avaje/metrics/statsd/Reporter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ private void sendValues(Meter.Stats stats, String name, String... tags) {
7373
public void visit(Timer.Stats timed) {
7474
if (timedThreshold == 0 || timedThreshold < timed.total()) {
7575
if (timed.name().startsWith("web.api.")) {
76-
String nameTag = "name:" + trim(timed.name(), 8);
77-
sendValues(timed, "web.api", timed.id().tags().append(nameTag));
76+
String labelTag = "label:" + trim(timed.name(), 8);
77+
sendValues(timed, "web.api", timed.id().tags().append(labelTag));
7878
} else if (timed.name().startsWith("app.")) {
79-
String nameTag = "name:" + trim(timed.name(),4);
80-
sendValues(timed, "app.component", timed.id().tags().append(nameTag));
79+
String labelTag = "label:" + trim(timed.name(),4);
80+
sendValues(timed, "app.component", timed.id().tags().append(labelTag));
8181
} else {
8282
sendValues(timed, timed.name(), timed.tags());
8383
}

0 commit comments

Comments
 (0)