diff --git a/exporter/splunkhecexporter/client_test.go b/exporter/splunkhecexporter/client_test.go index c0da8d9059bd..69f43cf498f2 100644 --- a/exporter/splunkhecexporter/client_test.go +++ b/exporter/splunkhecexporter/client_test.go @@ -344,10 +344,10 @@ func TestReceiveLogs(t *testing.T) { }(), want: wantType{ batches: []string{ - `{"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_0"}}` + "\n" + - `{"time":0.001,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_1"}}` + "\n" + - `{"time":0.002,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_2"}}` + "\n" + - `{"time":0.003,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_3"}}` + "\n", + `{"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_0"}}` + "\n" + + `{"time":0.001,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_1"}}` + "\n" + + `{"time":0.002,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_2"}}` + "\n" + + `{"time":0.003,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_3"}}` + "\n", }, numBatches: 1, }, @@ -362,10 +362,10 @@ func TestReceiveLogs(t *testing.T) { }(), want: wantType{ batches: []string{ - `{"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_0"}}` + "\n", - `{"time":0.001,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_1"}}` + "\n", - `{"time":0.002,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_2"}}` + "\n", - `{"time":0.003,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_3"}}` + "\n", + `{"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_0"}}` + "\n", + `{"time":0.001,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_1"}}` + "\n", + `{"time":0.002,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_2"}}` + "\n", + `{"time":0.003,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_3"}}` + "\n", }, numBatches: 4, }, @@ -380,10 +380,10 @@ func TestReceiveLogs(t *testing.T) { }(), want: wantType{ batches: []string{ - `{"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_0"}}` + "\n" + - `{"time":0.001,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_1"}}` + "\n", - `{"time":0.002,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_2"}}` + "\n" + - `{"time":0.003,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_3"}}` + "\n", + `{"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_0"}}` + "\n" + + `{"time":0.001,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_1"}}` + "\n", + `{"time":0.002,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_2"}}` + "\n" + + `{"time":0.003,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_3"}}` + "\n", }, numBatches: 2, }, @@ -396,16 +396,16 @@ func TestReceiveLogs(t *testing.T) { }(), want: wantType{ batches: []string{ - `{"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_0"}}` + "\n" + - `{"time":0.001,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_1"}}` + "\n" + - `{"time":0.002,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_2"}}` + "\n" + - `{"time":0.003,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_3"}}` + "\n" + - `{"time":0.004,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_4"}}` + "\n" + - `{"time":0.005,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_5"}}` + "\n" + - `{"time":0.006,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_6"}}` + "\n" + - `{"time":0.007,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_7"}}` + "\n" + - `{"time":0.008,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_8"}}` + "\n" + - `{"time":0.009,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_9"}}` + "\n", + `{"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_0"}}` + "\n" + + `{"time":0.001,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_1"}}` + "\n" + + `{"time":0.002,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_2"}}` + "\n" + + `{"time":0.003,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_3"}}` + "\n" + + `{"time":0.004,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_4"}}` + "\n" + + `{"time":0.005,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_5"}}` + "\n" + + `{"time":0.006,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_6"}}` + "\n" + + `{"time":0.007,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_7"}}` + "\n" + + `{"time":0.008,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_8"}}` + "\n" + + `{"time":0.009,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_9"}}` + "\n", }, numBatches: 1, compressed: true, @@ -413,7 +413,7 @@ func TestReceiveLogs(t *testing.T) { }, { name: "2 compressed batches - 1832 bytes each, make sure the log size is more than minCompressionLen=1500 to trigger compression", - logs: createLogData(1, 1, 20), + logs: createLogData(1, 1, 22), conf: func() *Config { cfg := NewFactory().CreateDefaultConfig().(*Config) cfg.MaxContentLengthLogs = 1916 @@ -421,26 +421,28 @@ func TestReceiveLogs(t *testing.T) { }(), want: wantType{ batches: []string{ - `{"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_0"}}` + "\n" + - `{"time":0.001,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_1"}}` + "\n" + - `{"time":0.002,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_2"}}` + "\n" + - `{"time":0.003,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_3"}}` + "\n" + - `{"time":0.004,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_4"}}` + "\n" + - `{"time":0.005,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_5"}}` + "\n" + - `{"time":0.006,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_6"}}` + "\n" + - `{"time":0.007,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_7"}}` + "\n" + - `{"time":0.008,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_8"}}` + "\n" + - `{"time":0.009,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_9"}}` + "\n", - `{"time":0.01,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_10"}}` + "\n" + - `{"time":0.011,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_11"}}` + "\n" + - `{"time":0.012,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_12"}}` + "\n" + - `{"time":0.013,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_13"}}` + "\n" + - `{"time":0.014,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_14"}}` + "\n" + - `{"time":0.015,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_15"}}` + "\n" + - `{"time":0.016,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_16"}}` + "\n" + - `{"time":0.017,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_17"}}` + "\n" + - `{"time":0.018,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_18"}}` + "\n" + - `{"time":0.019,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","host.name":"myhost","otel.log.name":"0_0_19"}}` + "\n", + `{"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_0"}}` + "\n" + + `{"time":0.001,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_1"}}` + "\n" + + `{"time":0.002,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_2"}}` + "\n" + + `{"time":0.003,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_3"}}` + "\n" + + `{"time":0.004,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_4"}}` + "\n" + + `{"time":0.005,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_5"}}` + "\n" + + `{"time":0.006,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_6"}}` + "\n" + + `{"time":0.007,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_7"}}` + "\n" + + `{"time":0.008,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_8"}}` + "\n" + + `{"time":0.009,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_9"}}` + "\n" + + `{"time":0.01,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_10"}}` + "\n", + `{"time":0.011,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_11"}}` + "\n" + + `{"time":0.012,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_12"}}` + "\n" + + `{"time":0.013,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_13"}}` + "\n" + + `{"time":0.014,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_14"}}` + "\n" + + `{"time":0.015,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_15"}}` + "\n" + + `{"time":0.016,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_16"}}` + "\n" + + `{"time":0.017,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_17"}}` + "\n" + + `{"time":0.018,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_18"}}` + "\n" + + `{"time":0.019,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_19"}}` + "\n" + + `{"time":0.02,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_20"}}` + "\n" + + `{"time":0.021,"host":"myhost","source":"myapp","sourcetype":"myapp-type","index":"myindex","event":"mylog","fields":{"custom":"custom","otel.log.name":"0_0_21"}}` + "\n", }, numBatches: 2, compressed: true, diff --git a/exporter/splunkhecexporter/logdata_to_splunk.go b/exporter/splunkhecexporter/logdata_to_splunk.go index a036c03e94e8..ee955cdfae06 100644 --- a/exporter/splunkhecexporter/logdata_to_splunk.go +++ b/exporter/splunkhecexporter/logdata_to_splunk.go @@ -18,7 +18,6 @@ import ( "time" "go.opentelemetry.io/collector/model/pdata" - conventions "go.opentelemetry.io/collector/model/semconv/v1.5.0" "go.uber.org/zap" "github.com/open-telemetry/opentelemetry-collector-contrib/internal/splunk" @@ -75,7 +74,6 @@ func mapLogRecordToSplunkEvent(res pdata.Resource, lr pdata.LogRecord, config *C switch k { case hostKey: host = v.StringVal() - fields[conventions.AttributeHostName] = v.StringVal() case sourceKey: source = v.StringVal() case sourceTypeKey: @@ -93,7 +91,6 @@ func mapLogRecordToSplunkEvent(res pdata.Resource, lr pdata.LogRecord, config *C switch k { case hostKey: host = v.StringVal() - fields[conventions.AttributeHostName] = v.StringVal() case sourceKey: source = v.StringVal() case sourceTypeKey: diff --git a/exporter/splunkhecexporter/logdata_to_splunk_test.go b/exporter/splunkhecexporter/logdata_to_splunk_test.go index 4c4d6a21dd26..6459f592126a 100644 --- a/exporter/splunkhecexporter/logdata_to_splunk_test.go +++ b/exporter/splunkhecexporter/logdata_to_splunk_test.go @@ -56,7 +56,7 @@ func Test_mapLogRecordToSplunkEvent(t *testing.T) { return config }, wantSplunkEvents: []*splunk.Event{ - commonLogSplunkEvent("mylog", ts, map[string]interface{}{"custom": "custom", "host.name": "myhost"}, + commonLogSplunkEvent("mylog", ts, map[string]interface{}{"custom": "custom"}, "myhost", "myapp", "myapp-type"), }, }, @@ -81,7 +81,7 @@ func Test_mapLogRecordToSplunkEvent(t *testing.T) { return config }, wantSplunkEvents: []*splunk.Event{ - commonLogSplunkEvent("mylog", ts, map[string]interface{}{"custom": "custom", "host.name": "myhost", "otel.log.name": "my very own name"}, + commonLogSplunkEvent("mylog", ts, map[string]interface{}{"custom": "custom", "otel.log.name": "my very own name"}, "myhost", "myapp", "myapp-type"), }, }, @@ -126,7 +126,7 @@ func Test_mapLogRecordToSplunkEvent(t *testing.T) { return config }, wantSplunkEvents: []*splunk.Event{ - commonLogSplunkEvent("mylog", ts, map[string]interface{}{"foo": float64(123), "host.name": "myhost"}, "myhost", "myapp", "myapp-type"), + commonLogSplunkEvent("mylog", ts, map[string]interface{}{"foo": float64(123)}, "myhost", "myapp", "myapp-type"), }, }, { @@ -181,7 +181,7 @@ func Test_mapLogRecordToSplunkEvent(t *testing.T) { }, wantSplunkEvents: []*splunk.Event{ func() *splunk.Event { - event := commonLogSplunkEvent("mylog", ts, map[string]interface{}{"custom": "custom", "host.name": "myhost", "myseverity": "DEBUG", "myseveritynum": pdata.SeverityNumber(5)}, "myhost", "mysource", "mysourcetype") + event := commonLogSplunkEvent("mylog", ts, map[string]interface{}{"custom": "custom", "myseverity": "DEBUG", "myseveritynum": pdata.SeverityNumber(5)}, "myhost", "mysource", "mysourcetype") event.Index = "myindex" return event }(), @@ -246,7 +246,7 @@ func Test_mapLogRecordToSplunkEvent(t *testing.T) { return config }, wantSplunkEvents: []*splunk.Event{ - commonLogSplunkEvent(float64(42), ts, map[string]interface{}{"custom": "custom", "host.name": "myhost"}, "myhost", "myapp", "myapp-type"), + commonLogSplunkEvent(float64(42), ts, map[string]interface{}{"custom": "custom"}, "myhost", "myapp", "myapp-type"), }, }, { @@ -269,7 +269,7 @@ func Test_mapLogRecordToSplunkEvent(t *testing.T) { return config }, wantSplunkEvents: []*splunk.Event{ - commonLogSplunkEvent(int64(42), ts, map[string]interface{}{"custom": "custom", "host.name": "myhost"}, "myhost", "myapp", "myapp-type"), + commonLogSplunkEvent(int64(42), ts, map[string]interface{}{"custom": "custom"}, "myhost", "myapp", "myapp-type"), }, }, { @@ -292,7 +292,7 @@ func Test_mapLogRecordToSplunkEvent(t *testing.T) { return config }, wantSplunkEvents: []*splunk.Event{ - commonLogSplunkEvent(true, ts, map[string]interface{}{"custom": "custom", "host.name": "myhost"}, "myhost", "myapp", "myapp-type"), + commonLogSplunkEvent(true, ts, map[string]interface{}{"custom": "custom"}, "myhost", "myapp", "myapp-type"), }, }, { @@ -320,7 +320,7 @@ func Test_mapLogRecordToSplunkEvent(t *testing.T) { }, wantSplunkEvents: []*splunk.Event{ commonLogSplunkEvent(map[string]interface{}{"23": float64(45), "foo": "bar"}, ts, - map[string]interface{}{"custom": "custom", "host.name": "myhost"}, + map[string]interface{}{"custom": "custom"}, "myhost", "myapp", "myapp-type"), }, }, @@ -343,7 +343,7 @@ func Test_mapLogRecordToSplunkEvent(t *testing.T) { return config }, wantSplunkEvents: []*splunk.Event{ - commonLogSplunkEvent(nil, ts, map[string]interface{}{"custom": "custom", "host.name": "myhost"}, + commonLogSplunkEvent(nil, ts, map[string]interface{}{"custom": "custom"}, "myhost", "myapp", "myapp-type"), }, }, @@ -370,7 +370,7 @@ func Test_mapLogRecordToSplunkEvent(t *testing.T) { return config }, wantSplunkEvents: []*splunk.Event{ - commonLogSplunkEvent([]interface{}{"foo"}, ts, map[string]interface{}{"custom": "custom", "host.name": "myhost"}, + commonLogSplunkEvent([]interface{}{"foo"}, ts, map[string]interface{}{"custom": "custom"}, "myhost", "myapp", "myapp-type"), }, }, @@ -396,7 +396,7 @@ func Test_mapLogRecordToSplunkEvent(t *testing.T) { }, wantSplunkEvents: func() []*splunk.Event { event := commonLogSplunkEvent("mylog", ts, map[string]interface{}{ - "host.name": "myhost-resource", "resourceAttr1": "some_string", + "resourceAttr1": "some_string", }, "myhost-resource", "myapp-resource", "myapp-type-from-resource-attr") event.Index = "index-resource" return []*splunk.Event{ @@ -426,7 +426,7 @@ func Test_mapLogRecordToSplunkEvent(t *testing.T) { return config }, wantSplunkEvents: []*splunk.Event{ - commonLogSplunkEvent("mylog", ts, map[string]interface{}{"custom": "custom", "host.name": "myhost", "otel.log.severity.number": pdata.SeverityNumberDEBUG, "otel.log.severity.text": "DEBUG"}, + commonLogSplunkEvent("mylog", ts, map[string]interface{}{"custom": "custom", "otel.log.severity.number": pdata.SeverityNumberDEBUG, "otel.log.severity.text": "DEBUG"}, "myhost", "myapp", "myapp-type"), }, }, diff --git a/exporter/splunkhecexporter/metricdata_to_splunk.go b/exporter/splunkhecexporter/metricdata_to_splunk.go index a7944fa41f94..91d8a7ab4475 100644 --- a/exporter/splunkhecexporter/metricdata_to_splunk.go +++ b/exporter/splunkhecexporter/metricdata_to_splunk.go @@ -19,7 +19,6 @@ import ( "strconv" "go.opentelemetry.io/collector/model/pdata" - conventions "go.opentelemetry.io/collector/model/semconv/v1.5.0" "go.uber.org/zap" "github.com/open-telemetry/opentelemetry-collector-contrib/internal/splunk" @@ -79,7 +78,6 @@ func metricDataToSplunk(logger *zap.Logger, data pdata.Metrics, config *Config) switch k { case hostKey: host = v.StringVal() - commonFields[conventions.AttributeHostName] = host case sourceKey: source = v.StringVal() case sourceTypeKey: diff --git a/exporter/splunkhecexporter/metricdata_to_splunk_test.go b/exporter/splunkhecexporter/metricdata_to_splunk_test.go index 243dcf88e6ff..fa3fcaf7f739 100644 --- a/exporter/splunkhecexporter/metricdata_to_splunk_test.go +++ b/exporter/splunkhecexporter/metricdata_to_splunk_test.go @@ -263,8 +263,8 @@ func Test_metricDataToSplunk(t *testing.T) { return metrics }, wantSplunkMetrics: []*splunk.Event{ - commonSplunkMetric("gauge_double_with_dims", tsMSecs, []string{"host.name", "k0", "k1", "metric_type"}, []interface{}{"myhost", "v0", "v1", "Gauge"}, doubleVal, "mysource", "mysourcetype", "myindex", "myhost"), - commonSplunkMetric("gauge_int_with_dims", tsMSecs, []string{"host.name", "k0", "k1", "metric_type"}, []interface{}{"myhost", "v0", "v1", "Gauge"}, int64Val, "mysource", "mysourcetype", "myindex", "myhost"), + commonSplunkMetric("gauge_double_with_dims", tsMSecs, []string{"k0", "k1", "metric_type"}, []interface{}{"v0", "v1", "Gauge"}, doubleVal, "mysource", "mysourcetype", "myindex", "myhost"), + commonSplunkMetric("gauge_int_with_dims", tsMSecs, []string{"k0", "k1", "metric_type"}, []interface{}{"v0", "v1", "Gauge"}, int64Val, "mysource", "mysourcetype", "myindex", "myhost"), }, configFn: func() *Config { return createDefaultConfig().(*Config) @@ -589,8 +589,8 @@ func Test_metricDataToSplunk(t *testing.T) { return metrics }, wantSplunkMetrics: []*splunk.Event{ - commonSplunkMetric("gauge_double_with_dims", tsMSecs, []string{"host.name", "k0", "k1", "metric_type"}, []interface{}{"myhost2", "v0", "v1", "Gauge"}, doubleVal, "mysource2", "mysourcetype2", "myindex2", "myhost2"), - commonSplunkMetric("gauge_int_with_dims", tsMSecs, []string{"host.name", "k0", "k1", "metric_type"}, []interface{}{"myhost2", "v0", "v1", "Gauge"}, int64Val, "mysource2", "mysourcetype2", "myindex2", "myhost2"), + commonSplunkMetric("gauge_double_with_dims", tsMSecs, []string{"k0", "k1", "metric_type"}, []interface{}{"v0", "v1", "Gauge"}, doubleVal, "mysource2", "mysourcetype2", "myindex2", "myhost2"), + commonSplunkMetric("gauge_int_with_dims", tsMSecs, []string{"k0", "k1", "metric_type"}, []interface{}{"v0", "v1", "Gauge"}, int64Val, "mysource2", "mysourcetype2", "myindex2", "myhost2"), }, configFn: func() *Config { cfg := createDefaultConfig().(*Config) diff --git a/exporter/splunkhecexporter/tracedata_to_splunk.go b/exporter/splunkhecexporter/tracedata_to_splunk.go index 6d16142e6a57..6a7647bf47a3 100644 --- a/exporter/splunkhecexporter/tracedata_to_splunk.go +++ b/exporter/splunkhecexporter/tracedata_to_splunk.go @@ -16,7 +16,6 @@ package splunkhecexporter // import "github.com/open-telemetry/opentelemetry-col import ( "go.opentelemetry.io/collector/model/pdata" - conventions "go.opentelemetry.io/collector/model/semconv/v1.5.0" "go.uber.org/zap" "github.com/open-telemetry/opentelemetry-collector-contrib/internal/splunk" @@ -78,7 +77,6 @@ func traceDataToSplunk(logger *zap.Logger, data pdata.Traces, config *Config) ([ switch k { case hostKey: host = v.StringVal() - commonFields[conventions.AttributeHostName] = host case sourceKey: source = v.StringVal() case sourceTypeKey: diff --git a/exporter/splunkhecexporter/tracedata_to_splunk_test.go b/exporter/splunkhecexporter/tracedata_to_splunk_test.go index 16ccb0643f7b..7504d282150a 100644 --- a/exporter/splunkhecexporter/tracedata_to_splunk_test.go +++ b/exporter/splunkhecexporter/tracedata_to_splunk_test.go @@ -198,8 +198,6 @@ func commonSplunkEvent( }, }, }, - Fields: map[string]interface{}{ - "host.name": "myhost", - }, + Fields: map[string]interface{}{}, } }