Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shaan420 committed Oct 3, 2023
1 parent 7bb497c commit a5fc9af
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion m3/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ func (c Configuration) NewReporter() (Reporter, error) {
MaxPacketSizeBytes: c.PacketSize,
IncludeHost: c.IncludeHost,
HistogramBucketTagPrecision: c.HistogramBucketTagPrecision,
CommonTagsInternal: c.CommonTagsInternal,
InternalTags: c.CommonTagsInternal,
})
}
4 changes: 2 additions & 2 deletions m3/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ type Options struct {
HistogramBucketIDName string
HistogramBucketName string
HistogramBucketTagPrecision uint
CommonTagsInternal map[string]string
InternalTags map[string]string
}

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

for k, v := range opts.CommonTagsInternal {
for k, v := range opts.InternalTags {
internalTags[k] = v
}

Expand Down
22 changes: 14 additions & 8 deletions m3/reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ func TestReporterCommmonTagsInternal(t *testing.T) {
go server.Serve()
defer server.Close()

commonTagsInternal := map[string]string{
internalTags := map[string]string{
"internal1": "test1",
"internal2": "test2",
}
Expand All @@ -577,8 +577,9 @@ func TestReporterCommmonTagsInternal(t *testing.T) {
Service: "test-service",
CommonTags: defaultCommonTags,
MaxQueueSize: queueSize,
IncludeHost: true,
MaxPacketSizeBytes: maxPacketSize,
CommonTagsInternal: commonTagsInternal,
InternalTags: internalTags,
})
require.NoError(t, err)
defer r.Close()
Expand All @@ -595,14 +596,19 @@ func TestReporterCommmonTagsInternal(t *testing.T) {
for _, metric := range metrics {
if strings.HasPrefix(metric.Name, "tally.internal") {
numInternalMetricsActual++
for k, v := range commonTagsInternal {
for k, v := range internalTags {
require.True(t, tagEquals(metric.Tags, k, v))
}
} else {
require.Equal(t, "testCounter1", metric.Name)
require.False(t, tagIncluded(metric.Tags, "internal1"))
require.False(t, tagIncluded(metric.Tags, "internal2"))
}
// The following tags should not be present as part of the individual metrics
// as they are common tags.
require.False(t, tagIncluded(metric.Tags, "host"))
require.False(t, tagIncluded(metric.Tags, "instance"))
require.False(t, tagIncluded(metric.Tags, "service"))
}
require.Equal(t, internalMetrics, numInternalMetricsActual)
}
Expand Down Expand Up @@ -636,12 +642,12 @@ type fakeM3ServerPackets struct {
}

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

0 comments on commit a5fc9af

Please sign in to comment.