Skip to content

Commit d47d51d

Browse files
authored
fix(go-forwarder): delete service tag in ddtags (#1117)
1 parent b14650c commit d47d51d

4 files changed

Lines changed: 15 additions & 16 deletions

File tree

aws/logs_monitoring_go/internal/handling/cloudwatch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func (h CloudwatchHandler) newCloudwatchBaseEntry(data events.CloudwatchLogsData
130130
func (h CloudwatchHandler) newCloudwatchLogEntry(event events.CloudwatchLogsLogEvent, entry model.LogEntry) model.LogEntry {
131131
tags, service, message := extractFromMessage(event.Message)
132132
entry.Service = cmp.Or(h.cfg.Service, service, entry.Source)
133-
entry.Tags = slices.Concat(tags, model.Tags{"service:" + entry.Service}, h.cfg.Tags)
133+
entry.Tags = slices.Concat(tags, h.cfg.Tags)
134134
entry.Message = message
135135
entry.ID = event.ID
136136
entry.Timestamp = event.Timestamp

aws/logs_monitoring_go/internal/handling/cloudwatch_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ func TestCloudwatchHandler_Handle(t *testing.T) {
7070
Source: "lambda",
7171
SourceCategory: "aws",
7272
Service: "lambda",
73-
Tags: model.Tags{"service:lambda"},
7473
Host: "/aws/lambda/testing-datadog",
7574
ID: "ev1",
7675
Timestamp: 1583425836114,
@@ -101,7 +100,7 @@ func TestCloudwatchHandler_Handle(t *testing.T) {
101100
want: []model.LogEntry{
102101
{
103102
Message: "first", Source: "lambda", SourceCategory: "aws",
104-
Service: "lambda", Tags: model.Tags{"service:lambda"},
103+
Service: "lambda",
105104
Host: "/aws/lambda/fn", ID: "a1", Timestamp: 1000,
106105
Metadata: model.CloudwatchMetadata{
107106
LambdaOrigin: model.LambdaOrigin{ARN: "arn:aws:lambda:us-east-1:123456789012:function:forwarder"},
@@ -110,7 +109,7 @@ func TestCloudwatchHandler_Handle(t *testing.T) {
110109
},
111110
{
112111
Message: "second", Source: "lambda", SourceCategory: "aws",
113-
Service: "lambda", Tags: model.Tags{"service:lambda"},
112+
Service: "lambda",
114113
Host: "/aws/lambda/fn", ID: "a2", Timestamp: 2000,
115114
Metadata: model.CloudwatchMetadata{
116115
LambdaOrigin: model.LambdaOrigin{ARN: "arn:aws:lambda:us-east-1:123456789012:function:forwarder"},
@@ -140,7 +139,7 @@ func TestCloudwatchHandler_Handle(t *testing.T) {
140139
{
141140
Message: "hello", Source: "custom-source", SourceCategory: "aws",
142141
Service: "custom-service",
143-
Tags: model.Tags{"service:custom-service", "env:prod", "team:infra"},
142+
Tags: model.Tags{"env:prod", "team:infra"},
144143
Host: "custom-host", ID: "ev1", Timestamp: 1000,
145144
Metadata: model.CloudwatchMetadata{
146145
LambdaOrigin: model.LambdaOrigin{ARN: "arn:aws:lambda:us-east-1:123456789012:function:forwarder"},

aws/logs_monitoring_go/internal/handling/s3.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func (h S3Handler) newS3LogEntry(record events.S3EventRecord, message string, la
111111
entry.Metadata = metadata
112112
entry.Source = cmp.Or(h.cfg.Source, S3Source(key))
113113
entry.Service = cmp.Or(h.cfg.Service, service, entry.Source)
114-
entry.Tags = slices.Concat(tags, model.Tags{"service:" + entry.Service}, h.cfg.Tags)
114+
entry.Tags = slices.Concat(tags, h.cfg.Tags)
115115
return entry
116116
}
117117

aws/logs_monitoring_go/internal/handling/s3_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func TestProcessS3Record(t *testing.T) {
4747
},
4848
cfg: testutil.EmptyConfig(),
4949
chanSize: 1,
50-
want: []model.LogEntry{wantS3Entry("line1", "s3", "s3", model.Tags{"service:s3"})},
50+
want: []model.LogEntry{wantS3Entry("line1", "s3", "s3", nil)},
5151
},
5252
"multiple lines": {
5353
mockSetup: func(m *MockS3APIClient) {
@@ -59,9 +59,9 @@ func TestProcessS3Record(t *testing.T) {
5959
cfg: testutil.EmptyConfig(),
6060
chanSize: 3,
6161
want: []model.LogEntry{
62-
wantS3Entry("line1", "s3", "s3", model.Tags{"service:s3"}),
63-
wantS3Entry("line2", "s3", "s3", model.Tags{"service:s3"}),
64-
wantS3Entry("line3", "s3", "s3", model.Tags{"service:s3"}),
62+
wantS3Entry("line1", "s3", "s3", nil),
63+
wantS3Entry("line2", "s3", "s3", nil),
64+
wantS3Entry("line3", "s3", "s3", nil),
6565
},
6666
},
6767
"empty file": {
@@ -91,7 +91,7 @@ func TestProcessS3Record(t *testing.T) {
9191
},
9292
cfg: testutil.EmptyConfig(),
9393
chanSize: 1,
94-
want: []model.LogEntry{wantS3Entry(`{"msg":"hello"}`, "s3", "myapp", model.Tags{"env:prod", "service:myapp"})},
94+
want: []model.LogEntry{wantS3Entry(`{"msg":"hello"}`, "s3", "myapp", model.Tags{"env:prod"})},
9595
},
9696
"invalid utf8 stripped": {
9797
mockSetup: func(m *MockS3APIClient) {
@@ -102,7 +102,7 @@ func TestProcessS3Record(t *testing.T) {
102102
},
103103
cfg: testutil.EmptyConfig(),
104104
chanSize: 1,
105-
want: []model.LogEntry{wantS3Entry("helloworld", "s3", "s3", model.Tags{"service:s3"})},
105+
want: []model.LogEntry{wantS3Entry("helloworld", "s3", "s3", nil)},
106106
},
107107
"multiline groups continuation lines": {
108108
mockSetup: func(m *MockS3APIClient) {
@@ -114,8 +114,8 @@ func TestProcessS3Record(t *testing.T) {
114114
cfg: &config.Config{S3MultilineLogRegex: regexp.MustCompile(`\d{4}-\d{2}-\d{2}`)},
115115
chanSize: 2,
116116
want: []model.LogEntry{
117-
wantS3Entry("2024-01-15 ERROR NullPointer\n at com.foo.Bar\n", "s3", "s3", model.Tags{"service:s3"}),
118-
wantS3Entry("2024-01-15 INFO started", "s3", "s3", model.Tags{"service:s3"}),
117+
wantS3Entry("2024-01-15 ERROR NullPointer\n at com.foo.Bar\n", "s3", "s3", nil),
118+
wantS3Entry("2024-01-15 INFO started", "s3", "s3", nil),
119119
},
120120
},
121121
"multiline flushes at eof": {
@@ -127,7 +127,7 @@ func TestProcessS3Record(t *testing.T) {
127127
},
128128
cfg: &config.Config{S3MultilineLogRegex: regexp.MustCompile(`\d{4}-\d{2}-\d{2}`)},
129129
chanSize: 1,
130-
want: []model.LogEntry{wantS3Entry("2024-01-15 ERROR\n stacktrace", "s3", "s3", model.Tags{"service:s3"})},
130+
want: []model.LogEntry{wantS3Entry("2024-01-15 ERROR\n stacktrace", "s3", "s3", nil)},
131131
},
132132
"custom tags passed through": {
133133
mockSetup: func(m *MockS3APIClient) {
@@ -138,7 +138,7 @@ func TestProcessS3Record(t *testing.T) {
138138
},
139139
cfg: &config.Config{Tags: model.Tags{"env:prod", "team:aws"}},
140140
chanSize: 1,
141-
want: []model.LogEntry{wantS3Entry("line1", "s3", "s3", model.Tags{"service:s3", "env:prod", "team:aws"})},
141+
want: []model.LogEntry{wantS3Entry("line1", "s3", "s3", model.Tags{"env:prod", "team:aws"})},
142142
},
143143
}
144144

0 commit comments

Comments
 (0)