Skip to content

Commit

Permalink
[exporter/newrelic] Remove usage of LogRecord Name field (open-teleme…
Browse files Browse the repository at this point in the history
  • Loading branch information
alanwest authored and tomsanbear committed Mar 2, 2022
1 parent 81ceef5 commit 7f7db49
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
4 changes: 1 addition & 3 deletions exporter/newrelicexporter/newrelic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,6 @@ func TestExportLogs(t *testing.T) {
rlog.Resource().Attributes().InsertString("resource", "R1")
rlog.Resource().Attributes().InsertString("service.name", "test-service")
l := rlog.InstrumentationLibraryLogs().AppendEmpty().LogRecords().AppendEmpty()
l.SetName("logname")
l.SetTimestamp(pdata.NewTimestampFromTime(timestamp))
l.Body().SetStringVal("log body")
l.Attributes().InsertString("foo", "bar")
Expand All @@ -672,8 +671,7 @@ func TestExportLogs(t *testing.T) {
Message: "log body",
Timestamp: timestamp.UnixNano() / (1000 * 1000),
Attributes: map[string]interface{}{
"foo": "bar",
"name": "logname",
"foo": "bar",
},
},
},
Expand Down
3 changes: 0 additions & 3 deletions exporter/newrelicexporter/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ func (t *transformer) Log(log pdata.LogRecord) (telemetry.Log, error) {

if bodyString := log.Body().StringVal(); bodyString != "" {
message = bodyString
} else {
message = log.Name()
}

logAttrs := log.Attributes()
Expand All @@ -139,7 +137,6 @@ func (t *transformer) Log(log pdata.LogRecord) (telemetry.Log, error) {
}
t.TrackAttributes(attributeLocationLog, logAttrs)

attrs["name"] = log.Name()
if !log.TraceID().IsEmpty() {
attrs[traceIDKey] = log.TraceID().HexString()
}
Expand Down
17 changes: 6 additions & 11 deletions exporter/newrelicexporter/transformer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -807,50 +807,49 @@ func TestTransformer_Log(t *testing.T) {
want: telemetry.Log{
Message: "",
Timestamp: time.Unix(0, 0).UTC(),
Attributes: map[string]interface{}{"name": ""},
Attributes: map[string]interface{}{},
},
},
{
name: "With Log attributes",
logFunc: func() pdata.LogRecord {
log := pdata.NewLogRecord()
log.SetName("bloopbleep")
log.Attributes().InsertString("foo", "bar")
log.Body().SetStringVal("Hello World")
return log
},
want: telemetry.Log{
Message: "Hello World",
Timestamp: time.Unix(0, 0).UTC(),
Attributes: map[string]interface{}{"foo": "bar", "name": "bloopbleep"},
Attributes: map[string]interface{}{"foo": "bar"},
},
},
{
name: "With severity number",
logFunc: func() pdata.LogRecord {
log := pdata.NewLogRecord()
log.SetName("bloopbleep")
log.SetSeverityNumber(pdata.SeverityNumberWARN)
log.Body().SetStringVal("bloopbleep")
return log
},
want: telemetry.Log{
Message: "bloopbleep",
Timestamp: time.Unix(0, 0).UTC(),
Attributes: map[string]interface{}{"name": "bloopbleep", "log.levelNum": int32(13)},
Attributes: map[string]interface{}{"log.levelNum": int32(13)},
},
},
{
name: "With severity text",
logFunc: func() pdata.LogRecord {
log := pdata.NewLogRecord()
log.SetName("bloopbleep")
log.SetSeverityText("SEVERE")
log.Body().SetStringVal("bloopbleep")
return log
},
want: telemetry.Log{
Message: "bloopbleep",
Timestamp: time.Unix(0, 0).UTC(),
Attributes: map[string]interface{}{"name": "bloopbleep", "log.level": "SEVERE"},
Attributes: map[string]interface{}{"log.level": "SEVERE"},
},
},
{
Expand All @@ -867,7 +866,6 @@ func TestTransformer_Log(t *testing.T) {
Message: "",
Timestamp: time.Unix(0, 0).UTC(),
Attributes: map[string]interface{}{
"name": "",
"trace.id": "01010101010101010101010101010101",
"span.id": "0000000000000001",
},
Expand All @@ -886,7 +884,6 @@ func TestTransformer_Log(t *testing.T) {
Message: "",
Timestamp: time.Unix(0, 0).UTC(),
Attributes: map[string]interface{}{
"name": "",
droppedAttributesCountKey: uint32(4),
},
},
Expand All @@ -904,7 +901,6 @@ func TestTransformer_Log(t *testing.T) {

func TestCaptureLogAttributeMetadata(t *testing.T) {
log := pdata.NewLogRecord()
log.SetName("bloopbleep")
log.Attributes().InsertString("foo", "bar")
log.Body().SetStringVal("Hello World")

Expand All @@ -919,7 +915,6 @@ func TestCaptureLogAttributeMetadata(t *testing.T) {

func TestDoesNotCaptureLogAttributeMetadata(t *testing.T) {
log := pdata.NewLogRecord()
log.SetName("bloopbleep")
log.Body().SetStringVal("Hello World")

details := newLogMetadata(context.TODO())
Expand Down

0 comments on commit 7f7db49

Please sign in to comment.