Skip to content

Commit a5fc9af

Browse files
committed
review comments
1 parent 7bb497c commit a5fc9af

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

m3/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,6 @@ func (c Configuration) NewReporter() (Reporter, error) {
7070
MaxPacketSizeBytes: c.PacketSize,
7171
IncludeHost: c.IncludeHost,
7272
HistogramBucketTagPrecision: c.HistogramBucketTagPrecision,
73-
CommonTagsInternal: c.CommonTagsInternal,
73+
InternalTags: c.CommonTagsInternal,
7474
})
7575
}

m3/reporter.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ type Options struct {
149149
HistogramBucketIDName string
150150
HistogramBucketName string
151151
HistogramBucketTagPrecision uint
152-
CommonTagsInternal map[string]string
152+
InternalTags map[string]string
153153
}
154154

155155
// NewReporter creates a new M3 reporter.
@@ -290,7 +290,7 @@ func NewReporter(opts Options) (Reporter, error) {
290290
"version": tally.Version,
291291
}
292292

293-
for k, v := range opts.CommonTagsInternal {
293+
for k, v := range opts.InternalTags {
294294
internalTags[k] = v
295295
}
296296

m3/reporter_test.go

+14-8
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ func TestReporterCommmonTagsInternal(t *testing.T) {
567567
go server.Serve()
568568
defer server.Close()
569569

570-
commonTagsInternal := map[string]string{
570+
internalTags := map[string]string{
571571
"internal1": "test1",
572572
"internal2": "test2",
573573
}
@@ -577,8 +577,9 @@ func TestReporterCommmonTagsInternal(t *testing.T) {
577577
Service: "test-service",
578578
CommonTags: defaultCommonTags,
579579
MaxQueueSize: queueSize,
580+
IncludeHost: true,
580581
MaxPacketSizeBytes: maxPacketSize,
581-
CommonTagsInternal: commonTagsInternal,
582+
InternalTags: internalTags,
582583
})
583584
require.NoError(t, err)
584585
defer r.Close()
@@ -595,14 +596,19 @@ func TestReporterCommmonTagsInternal(t *testing.T) {
595596
for _, metric := range metrics {
596597
if strings.HasPrefix(metric.Name, "tally.internal") {
597598
numInternalMetricsActual++
598-
for k, v := range commonTagsInternal {
599+
for k, v := range internalTags {
599600
require.True(t, tagEquals(metric.Tags, k, v))
600601
}
601602
} else {
602603
require.Equal(t, "testCounter1", metric.Name)
603604
require.False(t, tagIncluded(metric.Tags, "internal1"))
604605
require.False(t, tagIncluded(metric.Tags, "internal2"))
605606
}
607+
// The following tags should not be present as part of the individual metrics
608+
// as they are common tags.
609+
require.False(t, tagIncluded(metric.Tags, "host"))
610+
require.False(t, tagIncluded(metric.Tags, "instance"))
611+
require.False(t, tagIncluded(metric.Tags, "service"))
606612
}
607613
require.Equal(t, internalMetrics, numInternalMetricsActual)
608614
}
@@ -636,12 +642,12 @@ type fakeM3ServerPackets struct {
636642
}
637643

638644
// newFakeM3Server creates a new fake M3 server that listens on a random port
639-
// and returns the address.
645+
// and returns the server.
640646
// The server will wait for the given wait group to be done before returning.
641-
// If countBatches is true, the server will wait for a batch to be received
642-
// before returning.
643-
// But if countBatches is false, the server will wait for a metric to be received
644-
// before returning.
647+
// If countBatches is true, the server will wait consider the wg.Add()s to be
648+
// representing batches and will do a eg.Done() for each encountered batch.
649+
// But if countBatches is false, the server will do the same thing but for individual
650+
// metrics instead of batches.
645651
func newFakeM3Server(t *testing.T, wg *sync.WaitGroup, countBatches bool, protocol Protocol) *fakeM3Server {
646652
service := newFakeM3Service(wg, countBatches)
647653
processor := m3thrift.NewM3Processor(service)

0 commit comments

Comments
 (0)