Skip to content

Commit 090a6b7

Browse files
committed
add a requests counter metric for http sources
1 parent 696a6e3 commit 090a6b7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/java/com/arpnetworking/metrics/common/sources/HttpSource.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,12 @@ private void requestReply(final RequestReply requestReply) {
150150
// only created when pipelines are reloaded. To avoid recording values
151151
// for dead pipelines this explicitly avoids recording zeroes.
152152
final long samples = _receivedSamples.getAndSet(0);
153+
final long requests = _receivedRequests.getAndSet(0);
153154
if (samples > 0) {
154-
m.recordGauge(String.format("sources/http/%s/metric_samples", _metricSafeName), samples);
155+
m.recordCounter(String.format("sources/http/%s/metric_samples", _metricSafeName), samples);
156+
}
157+
if (requests > 0) {
158+
m.recordCounter(String.format("sources/http/%s/requests", _metricSafeName), requests);
155159
}
156160
});
157161

@@ -245,6 +249,7 @@ private List<Record> parseRecords(final com.arpnetworking.metrics.mad.model.Http
245249
private final Materializer _materializer;
246250
private final Graph<FlowShape<HttpRequest, Record>, NotUsed> _processGraph;
247251
private final AtomicLong _receivedSamples = new AtomicLong(0);
252+
private final AtomicLong _receivedRequests = new AtomicLong(0);
248253

249254
private static final StatisticFactory STATISTIC_FACTORY = new StatisticFactory();
250255
private static final Logger BAD_REQUEST_LOGGER =

0 commit comments

Comments
 (0)