Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Count received batches from conforming clients #2030

Merged
merged 1 commit into from
Jan 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cmd/agent/app/reporter/client_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const (

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

Expand Down Expand Up @@ -189,6 +190,8 @@ func (s *lastReceivedClientStats) update(
s.lock.Lock()
defer s.lock.Unlock()

metrics.BatchesReceived.Inc(1)

if s.batchSeqNo >= batchSeqNo {
// Ignore out of order batches. Once we receive a batch with a larger-than-seen number,
// it will contain new cumulative counts, which we will use to update the metrics.
Expand Down
4 changes: 4 additions & 0 deletions cmd/agent/app/reporter/client_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func TestClientMetricsReporter_Jaeger(t *testing.T) {
runExpire: true,
// first batch cannot increment counters, only capture the baseline
expCounters: []metricstest.ExpectedMetric{
{Name: prefix + "batches_received", Value: 1},
{Name: prefix + "batches_sent", Value: 0},
{Name: prefix + "spans_dropped", Tags: tag("cause", "full-queue"), Value: 0},
{Name: prefix + "spans_dropped", Tags: tag("cause", "too-large"), Value: 0},
Expand All @@ -130,6 +131,7 @@ func TestClientMetricsReporter_Jaeger(t *testing.T) {
FailedToEmitSpans: 15,
},
expCounters: []metricstest.ExpectedMetric{
{Name: prefix + "batches_received", Value: 2},
{Name: prefix + "batches_sent", Value: 5},
{Name: prefix + "spans_dropped", Tags: tag("cause", "full-queue"), Value: 5},
{Name: prefix + "spans_dropped", Tags: tag("cause", "too-large"), Value: 5},
Expand All @@ -140,6 +142,7 @@ func TestClientMetricsReporter_Jaeger(t *testing.T) {
clientUUID: &clientUUID,
seqNo: nPtr(90), // out of order batch will be ignored
expCounters: []metricstest.ExpectedMetric{
{Name: prefix + "batches_received", Value: 3},
{Name: prefix + "batches_sent", Value: 5}, // unchanged!
},
},
Expand All @@ -152,6 +155,7 @@ func TestClientMetricsReporter_Jaeger(t *testing.T) {
TooLargeDroppedSpans: 18,
FailedToEmitSpans: 19,
}, expCounters: []metricstest.ExpectedMetric{
{Name: prefix + "batches_received", Value: 4},
{Name: prefix + "batches_sent", Value: 10},
{Name: prefix + "spans_dropped", Tags: tag("cause", "full-queue"), Value: 7},
{Name: prefix + "spans_dropped", Tags: tag("cause", "too-large"), Value: 8},
Expand Down