diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f798c4e59fb..f300464c1798 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,12 +11,13 @@ ### 🛑 Breaking changes 🛑 - `windowsperfcountersreceiver`: Added metrics configuration (#8376) +- `lokiexporter`: Remove deprecated LogRecord.name field (#8951) +- `splunkhecexporter`: Remove deprecated LogRecord.name field (#8951) ### 🚩 Deprecations 🚩 - `datadogexporter`: Deprecate `OnlyMetadata` method from `Config` struct (#8359) - `datadogexporter`: Deprecate `GetCensoredKey` method from `APIConfig` struct (#8830) - - `resourcedetectionprocessor`: Add attribute allowlist (#8547) ### 💡 Enhancements 💡 diff --git a/exporter/lokiexporter/encode_json.go b/exporter/lokiexporter/encode_json.go index 7351228071ce..c829847c1386 100644 --- a/exporter/lokiexporter/encode_json.go +++ b/exporter/lokiexporter/encode_json.go @@ -78,7 +78,6 @@ func encodeJSON(lr pdata.LogRecord, res pdata.Resource) (string, error) { return "", err } logRecord = lokiEntry{ - Name: lr.Name(), Body: body, TraceID: lr.TraceID().HexString(), SpanID: lr.SpanID().HexString(), diff --git a/exporter/splunkhecexporter/client_test.go b/exporter/splunkhecexporter/client_test.go index a8bd8468d0a3..79ac925c0b1c 100644 --- a/exporter/splunkhecexporter/client_test.go +++ b/exporter/splunkhecexporter/client_test.go @@ -147,8 +147,8 @@ func createLogDataWithCustomLibraries(numResources int, libraries []string, numR for k := 0; k < numRecords[j]; k++ { ts := pdata.Timestamp(int64(k) * time.Millisecond.Nanoseconds()) logRecord := ill.LogRecords().AppendEmpty() - logRecord.SetName(fmt.Sprintf("%d_%d_%d", i, j, k)) logRecord.Body().SetStringVal("mylog") + logRecord.Attributes().InsertString(splunk.DefaultNameLabel, fmt.Sprintf("%d_%d_%d", i, j, k)) logRecord.Attributes().InsertString(splunk.DefaultSourceLabel, "myapp") logRecord.Attributes().InsertString(splunk.DefaultSourceTypeLabel, "myapp-type") logRecord.Attributes().InsertString(splunk.DefaultIndexLabel, "myindex") @@ -1044,9 +1044,11 @@ func TestSubLogs(t *testing.T) { assert.Equal(t, logs.LogRecordCount(), got.LogRecordCount()) // The name of the leftmost log record should be 0_0_0. - assert.Equal(t, "0_0_0", got.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords().At(0).Name()) + val, _ := got.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords().At(0).Attributes().Get(splunk.DefaultNameLabel) + assert.Equal(t, "0_0_0", val.AsString()) // The name of the rightmost log record should be 1_1_2. - assert.Equal(t, "1_1_2", got.ResourceLogs().At(1).InstrumentationLibraryLogs().At(1).LogRecords().At(2).Name()) + val, _ = got.ResourceLogs().At(1).InstrumentationLibraryLogs().At(1).LogRecords().At(2).Attributes().Get(splunk.DefaultNameLabel) + assert.Equal(t, "1_1_2", val.AsString()) // Logs subset from some mid index (resource 0, library 1, log 2). _0_1_2 := &index{resource: 0, library: 1, record: 2} //revive:disable-line:var-naming @@ -1055,9 +1057,11 @@ func TestSubLogs(t *testing.T) { assert.Equal(t, 7, got.LogRecordCount()) // The name of the leftmost log record should be 0_1_2. - assert.Equal(t, "0_1_2", got.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords().At(0).Name()) + val, _ = got.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords().At(0).Attributes().Get(splunk.DefaultNameLabel) + assert.Equal(t, "0_1_2", val.AsString()) // The name of the rightmost log record should be 1_1_2. - assert.Equal(t, "1_1_2", got.ResourceLogs().At(1).InstrumentationLibraryLogs().At(1).LogRecords().At(2).Name()) + val, _ = got.ResourceLogs().At(1).InstrumentationLibraryLogs().At(1).LogRecords().At(2).Attributes().Get(splunk.DefaultNameLabel) + assert.Equal(t, "1_1_2", val.AsString()) // Logs subset from rightmost index (resource 1, library 1, log 2). _1_1_2 := &index{resource: 1, library: 1, record: 2} //revive:disable-line:var-naming @@ -1067,7 +1071,8 @@ func TestSubLogs(t *testing.T) { assert.Equal(t, 1, got.LogRecordCount()) // The name of the sole log record should be 1_1_2. - assert.Equal(t, "1_1_2", got.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords().At(0).Name()) + val, _ = got.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords().At(0).Attributes().Get(splunk.DefaultNameLabel) + assert.Equal(t, "1_1_2", val.AsString()) // Now see how profiling and log data are merged logs = createLogDataWithCustomLibraries(2, []string{"otel.logs", "otel.profiling"}, []int{10, 10}) @@ -1078,15 +1083,21 @@ func TestSubLogs(t *testing.T) { assert.Equal(t, 5+2+10, got.LogRecordCount()) assert.Equal(t, "otel.logs", got.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).InstrumentationLibrary().Name()) - assert.Equal(t, "1_0_5", got.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords().At(0).Name()) - assert.Equal(t, "1_0_9", got.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords().At(4).Name()) + val, _ = got.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords().At(0).Attributes().Get(splunk.DefaultNameLabel) + assert.Equal(t, "1_0_5", val.AsString()) + val, _ = got.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords().At(4).Attributes().Get(splunk.DefaultNameLabel) + assert.Equal(t, "1_0_9", val.AsString()) assert.Equal(t, "otel.profiling", got.ResourceLogs().At(1).InstrumentationLibraryLogs().At(0).InstrumentationLibrary().Name()) - assert.Equal(t, "0_1_8", got.ResourceLogs().At(1).InstrumentationLibraryLogs().At(0).LogRecords().At(0).Name()) - assert.Equal(t, "0_1_9", got.ResourceLogs().At(1).InstrumentationLibraryLogs().At(0).LogRecords().At(1).Name()) + val, _ = got.ResourceLogs().At(1).InstrumentationLibraryLogs().At(0).LogRecords().At(0).Attributes().Get(splunk.DefaultNameLabel) + assert.Equal(t, "0_1_8", val.AsString()) + val, _ = got.ResourceLogs().At(1).InstrumentationLibraryLogs().At(0).LogRecords().At(1).Attributes().Get(splunk.DefaultNameLabel) + assert.Equal(t, "0_1_9", val.AsString()) assert.Equal(t, "otel.profiling", got.ResourceLogs().At(2).InstrumentationLibraryLogs().At(0).InstrumentationLibrary().Name()) - assert.Equal(t, "1_1_0", got.ResourceLogs().At(2).InstrumentationLibraryLogs().At(0).LogRecords().At(0).Name()) - assert.Equal(t, "1_1_9", got.ResourceLogs().At(2).InstrumentationLibraryLogs().At(0).LogRecords().At(9).Name()) + val, _ = got.ResourceLogs().At(2).InstrumentationLibraryLogs().At(0).LogRecords().At(0).Attributes().Get(splunk.DefaultNameLabel) + assert.Equal(t, "1_1_0", val.AsString()) + val, _ = got.ResourceLogs().At(2).InstrumentationLibraryLogs().At(0).LogRecords().At(9).Attributes().Get(splunk.DefaultNameLabel) + assert.Equal(t, "1_1_9", val.AsString()) } // validateCompressedEqual validates that GZipped `got` contains `expected` strings diff --git a/exporter/splunkhecexporter/logdata_to_splunk.go b/exporter/splunkhecexporter/logdata_to_splunk.go index cd7a90567cdf..81777fe89a5a 100644 --- a/exporter/splunkhecexporter/logdata_to_splunk.go +++ b/exporter/splunkhecexporter/logdata_to_splunk.go @@ -41,12 +41,8 @@ func mapLogRecordToSplunkEvent(res pdata.Resource, lr pdata.LogRecord, config *C sourceTypeKey := config.HecToOtelAttrs.SourceType indexKey := config.HecToOtelAttrs.Index hostKey := config.HecToOtelAttrs.Host - nameKey := config.HecFields.Name severityTextKey := config.HecFields.SeverityText severityNumberKey := config.HecFields.SeverityNumber - if lr.Name() != "" { - fields[nameKey] = lr.Name() - } if spanID := lr.SpanID().HexString(); spanID != "" { fields[spanIDFieldKey] = spanID } diff --git a/exporter/splunkhecexporter/logdata_to_splunk_test.go b/exporter/splunkhecexporter/logdata_to_splunk_test.go index af4bfcf724ac..7143d9e40113 100644 --- a/exporter/splunkhecexporter/logdata_to_splunk_test.go +++ b/exporter/splunkhecexporter/logdata_to_splunk_test.go @@ -64,7 +64,6 @@ func Test_mapLogRecordToSplunkEvent(t *testing.T) { name: "with_name", logRecordFn: func() pdata.LogRecord { logRecord := pdata.NewLogRecord() - logRecord.SetName("my very own name") logRecord.Body().SetStringVal("mylog") logRecord.Attributes().InsertString(splunk.DefaultSourceLabel, "myapp") logRecord.Attributes().InsertString(splunk.DefaultSourceTypeLabel, "myapp-type") @@ -81,7 +80,7 @@ func Test_mapLogRecordToSplunkEvent(t *testing.T) { return config }, wantSplunkEvents: []*splunk.Event{ - commonLogSplunkEvent("mylog", ts, map[string]interface{}{"custom": "custom", "otel.log.name": "my very own name"}, + commonLogSplunkEvent("mylog", ts, map[string]interface{}{"custom": "custom"}, "myhost", "myapp", "myapp-type"), }, }, diff --git a/internal/coreinternal/processor/filterlog/filterlog.go b/internal/coreinternal/processor/filterlog/filterlog.go index 6216163e53c6..76870496c951 100644 --- a/internal/coreinternal/processor/filterlog/filterlog.go +++ b/internal/coreinternal/processor/filterlog/filterlog.go @@ -77,9 +77,5 @@ func NewMatcher(mp *filterconfig.MatchProperties) (Matcher, error) { // supported to have more than one of these specified, and all specified must // evaluate to true for a match to occur. func (mp *propertiesMatcher) MatchLogRecord(lr pdata.LogRecord, resource pdata.Resource, library pdata.InstrumentationLibrary) bool { - if mp.nameFilters != nil && !mp.nameFilters.Matches(lr.Name()) { - return false - } - return mp.PropertiesMatcher.Match(lr.Attributes(), resource, library) } diff --git a/testbed/datasenders/syslog.go b/testbed/datasenders/syslog.go index 85674c719cb1..be3290d5d1c5 100644 --- a/testbed/datasenders/syslog.go +++ b/testbed/datasenders/syslog.go @@ -108,7 +108,7 @@ func (f *SyslogWriter) Send(lr pdata.LogRecord) error { sdid.WriteString(fmt.Sprintf("%s=\"%s\" ", k, v.StringVal())) return true }) - msg := fmt.Sprintf("<166> %s localhost %s - - [%s] %s\n", ts, lr.Name(), sdid.String(), lr.Body().StringVal()) + msg := fmt.Sprintf("<166> %s localhost - - - [%s] %s\n", ts, sdid.String(), lr.Body().StringVal()) f.buf = append(f.buf, msg) return f.SendCheck() diff --git a/testbed/datasenders/tcpudp.go b/testbed/datasenders/tcpudp.go index 153c7b1dfe5f..317e9548d166 100644 --- a/testbed/datasenders/tcpudp.go +++ b/testbed/datasenders/tcpudp.go @@ -106,7 +106,7 @@ func (f *TCPUDPWriter) Send(lr pdata.LogRecord) error { sdid.WriteString(fmt.Sprintf("%s=\"%s\" ", k, v.StringVal())) return true }) - msg := fmt.Sprintf("<166> %s localhost %s - - [%s] %s\n", ts, lr.Name(), sdid.String(), lr.Body().StringVal()) + msg := fmt.Sprintf("<166> %s localhost - - - [%s] %s\n", ts, sdid.String(), lr.Body().StringVal()) f.buf = append(f.buf, msg) return f.SendCheck()