Skip to content

Commit fe16b1d

Browse files
committed
add resource attribute test
1 parent 6a6c453 commit fe16b1d

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

comp/otelcol/otlp/components/exporter/logsagentexporter/logs_exporter_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,40 @@ func TestLogsExporter(t *testing.T) {
9999
},
100100
expectedTags: [][]string{{"otel_source:datadog_agent"}},
101101
},
102+
{
103+
name: "resource-attribute-source",
104+
args: args{
105+
ld: func() plog.Logs {
106+
l := testutil.GenerateLogsOneLogRecord()
107+
rl := l.ResourceLogs().At(0)
108+
resourceAttrs := rl.Resource().Attributes()
109+
resourceAttrs.PutStr("datadog.log.source", "custom_source_rattr")
110+
return l
111+
}(),
112+
otelSource: otelSource,
113+
logSourceName: "custom_source_rattr",
114+
},
115+
116+
want: testutil.JSONLogs{
117+
{
118+
"message": "This is a log message",
119+
"app": "server",
120+
"instance_num": "1",
121+
"datadog.log.source": "custom_source_rattr",
122+
"@timestamp": testutil.TestLogTime.Format("2006-01-02T15:04:05.000Z07:00"),
123+
"status": "Info",
124+
"dd.span_id": fmt.Sprintf("%d", spanIDToUint64(ld.SpanID())),
125+
"dd.trace_id": fmt.Sprintf("%d", traceIDToUint64(ld.TraceID())),
126+
"otel.severity_text": "Info",
127+
"otel.severity_number": "9",
128+
"otel.span_id": spanIDToHexOrEmptyString(ld.SpanID()),
129+
"otel.trace_id": traceIDToHexOrEmptyString(ld.TraceID()),
130+
"otel.timestamp": fmt.Sprintf("%d", testutil.TestLogTime.UnixNano()),
131+
"resource-attr": "resource-attr-val-1",
132+
},
133+
},
134+
expectedTags: [][]string{{"otel_source:datadog_agent"}},
135+
},
102136
{
103137
name: "ddtags",
104138
args: args{

0 commit comments

Comments
 (0)