Skip to content

Commit f899363

Browse files
authored
Count received batches from conforming clients (#2030)
Signed-off-by: Yuri Shkuro <ys@uber.com>
1 parent eea26e9 commit f899363

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

cmd/agent/app/reporter/client_metrics.go

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const (
3333

3434
// clientMetrics are maintained only for data submitted in Jaeger Thrift format.
3535
type clientMetrics struct {
36+
BatchesReceived metrics.Counter `metric:"batches_received" help:"Total count of batches received from conforming clients"`
3637
BatchesSent metrics.Counter `metric:"batches_sent" help:"Total count of batches sent by clients"`
3738
ConnectedClients metrics.Gauge `metric:"connected_clients" help:"Total count of unique clients sending data to the agent"`
3839

@@ -189,6 +190,8 @@ func (s *lastReceivedClientStats) update(
189190
s.lock.Lock()
190191
defer s.lock.Unlock()
191192

193+
metrics.BatchesReceived.Inc(1)
194+
192195
if s.batchSeqNo >= batchSeqNo {
193196
// Ignore out of order batches. Once we receive a batch with a larger-than-seen number,
194197
// it will contain new cumulative counts, which we will use to update the metrics.

cmd/agent/app/reporter/client_metrics_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ func TestClientMetricsReporter_Jaeger(t *testing.T) {
112112
runExpire: true,
113113
// first batch cannot increment counters, only capture the baseline
114114
expCounters: []metricstest.ExpectedMetric{
115+
{Name: prefix + "batches_received", Value: 1},
115116
{Name: prefix + "batches_sent", Value: 0},
116117
{Name: prefix + "spans_dropped", Tags: tag("cause", "full-queue"), Value: 0},
117118
{Name: prefix + "spans_dropped", Tags: tag("cause", "too-large"), Value: 0},
@@ -130,6 +131,7 @@ func TestClientMetricsReporter_Jaeger(t *testing.T) {
130131
FailedToEmitSpans: 15,
131132
},
132133
expCounters: []metricstest.ExpectedMetric{
134+
{Name: prefix + "batches_received", Value: 2},
133135
{Name: prefix + "batches_sent", Value: 5},
134136
{Name: prefix + "spans_dropped", Tags: tag("cause", "full-queue"), Value: 5},
135137
{Name: prefix + "spans_dropped", Tags: tag("cause", "too-large"), Value: 5},
@@ -140,6 +142,7 @@ func TestClientMetricsReporter_Jaeger(t *testing.T) {
140142
clientUUID: &clientUUID,
141143
seqNo: nPtr(90), // out of order batch will be ignored
142144
expCounters: []metricstest.ExpectedMetric{
145+
{Name: prefix + "batches_received", Value: 3},
143146
{Name: prefix + "batches_sent", Value: 5}, // unchanged!
144147
},
145148
},
@@ -152,6 +155,7 @@ func TestClientMetricsReporter_Jaeger(t *testing.T) {
152155
TooLargeDroppedSpans: 18,
153156
FailedToEmitSpans: 19,
154157
}, expCounters: []metricstest.ExpectedMetric{
158+
{Name: prefix + "batches_received", Value: 4},
155159
{Name: prefix + "batches_sent", Value: 10},
156160
{Name: prefix + "spans_dropped", Tags: tag("cause", "full-queue"), Value: 7},
157161
{Name: prefix + "spans_dropped", Tags: tag("cause", "too-large"), Value: 8},

0 commit comments

Comments
 (0)