Skip to content

Commit ba7d9b8

Browse files
eundoosongyurishkuro
authored andcommitted
Change to tagged metrics in agent (#950)
Use tags in agent metrics
1 parent df4a5e0 commit ba7d9b8

File tree

3 files changed

+9
-20
lines changed

3 files changed

+9
-20
lines changed

cmd/agent/app/processors/thrift_processor_test.go

+3-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package processors
1616

1717
import (
1818
"errors"
19-
"fmt"
2019
"testing"
2120
"time"
2221

@@ -196,7 +195,7 @@ func assertProcessorCorrectness(
196195
metricsFactory *metrics.LocalFactory,
197196
sizeF func() int,
198197
nameF func() string,
199-
counterType string,
198+
format string,
200199
) {
201200
// wait for server to receive
202201
for i := 0; i < 1000; i++ {
@@ -219,11 +218,9 @@ func assertProcessorCorrectness(
219218
}
220219

221220
// agentReporter must emit metrics
222-
batchesSubmittedCounter := fmt.Sprintf("tc-reporter.%s.batches.submitted", counterType)
223-
spansSubmittedCounter := fmt.Sprintf("tc-reporter.%s.spans.submitted", counterType)
224221
mTestutils.AssertCounterMetrics(t, metricsFactory, []mTestutils.ExpectedMetric{
225-
{Name: batchesSubmittedCounter, Value: 1},
226-
{Name: spansSubmittedCounter, Value: 1},
222+
{Name: "tchannel-reporter.batches.submitted", Tags: map[string]string{"format": format}, Value: 1},
223+
{Name: "tchannel-reporter.spans.submitted", Tags: map[string]string{"format": format}, Value: 1},
227224
{Name: "thrift.udp.server.packets.processed", Value: 1},
228225
}...)
229226
}

cmd/agent/app/reporter/tchannel/reporter.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,9 @@ func New(
7171
zClient := zipkincore.NewTChanZipkinCollectorClient(thriftClient)
7272
jClient := jaeger.NewTChanCollectorClient(thriftClient)
7373
batchesMetrics := map[string]batchMetrics{}
74-
tcReporterNS := mFactory.Namespace("tc-reporter", nil)
7574
for _, s := range []string{zipkinBatches, jaegerBatches} {
76-
nsByType := tcReporterNS.Namespace(s, nil)
7775
bm := batchMetrics{}
78-
metrics.Init(&bm, nsByType, nil)
76+
metrics.Init(&bm, mFactory.Namespace("tchannel-reporter", map[string]string{"format": s}), nil)
7977
batchesMetrics[s] = bm
8078
}
8179
return &Reporter{

cmd/agent/app/reporter/tchannel/reporter_test.go

+5-11
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package tchannel
1616

1717
import (
18-
"fmt"
1918
"testing"
2019
"time"
2120

@@ -105,16 +104,11 @@ func submitTestJaegerBatch(reporter *Reporter) error {
105104
return reporter.EmitBatch(batch)
106105
}
107106

108-
func checkCounters(t *testing.T, mf *metrics.LocalFactory, batchesSubmitted, spansSubmitted, batchesFailures, spansFailures int, prefix string) {
109-
batchesCounter := fmt.Sprintf("tc-reporter.%s.batches.submitted", prefix)
110-
batchesFailureCounter := fmt.Sprintf("tc-reporter.%s.batches.failures", prefix)
111-
spansCounter := fmt.Sprintf("tc-reporter.%s.spans.submitted", prefix)
112-
spansFailureCounter := fmt.Sprintf("tc-reporter.%s.spans.failures", prefix)
113-
107+
func checkCounters(t *testing.T, mf *metrics.LocalFactory, batchesSubmitted, spansSubmitted, batchesFailures, spansFailures int, format string) {
114108
mTestutils.AssertCounterMetrics(t, mf, []mTestutils.ExpectedMetric{
115-
{Name: batchesCounter, Value: batchesSubmitted},
116-
{Name: spansCounter, Value: spansSubmitted},
117-
{Name: batchesFailureCounter, Value: batchesFailures},
118-
{Name: spansFailureCounter, Value: spansFailures},
109+
{Name: "tchannel-reporter.batches.submitted", Tags: map[string]string{"format": format}, Value: batchesSubmitted},
110+
{Name: "tchannel-reporter.spans.submitted", Tags: map[string]string{"format": format}, Value: spansSubmitted},
111+
{Name: "tchannel-reporter.batches.failures", Tags: map[string]string{"format": format}, Value: batchesFailures},
112+
{Name: "tchannel-reporter.spans.failures", Tags: map[string]string{"format": format}, Value: spansFailures},
119113
}...)
120114
}

0 commit comments

Comments
 (0)