From d381570400621eee7361a143cabd525b2e542d6c Mon Sep 17 00:00:00 2001 From: Miguel Rodriguez Date: Fri, 10 Nov 2023 10:18:23 -0500 Subject: [PATCH] Update timestamp marshal name --- exporter/chronicleexporter/factory.go | 2 +- exporter/chronicleexporter/marshal.go | 2 +- exporter/chronicleexporter/marshal_test.go | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/exporter/chronicleexporter/factory.go b/exporter/chronicleexporter/factory.go index 41aa09eec..01f8c4700 100644 --- a/exporter/chronicleexporter/factory.go +++ b/exporter/chronicleexporter/factory.go @@ -35,7 +35,7 @@ type Factory struct { // NewFactory creates a new Chronicle exporter factory. func NewFactory() exporter.Factory { return exporter.NewFactory( - TypeStr, + metadata.Type, createDefaultConfig, exporter.WithLogs(createLogsExporter, metadata.LogsStability)) } diff --git a/exporter/chronicleexporter/marshal.go b/exporter/chronicleexporter/marshal.go index 8d7be0fee..bea4e3fd6 100644 --- a/exporter/chronicleexporter/marshal.go +++ b/exporter/chronicleexporter/marshal.go @@ -68,7 +68,7 @@ func (ce *marshaler) MarshalRawLogs(ld plog.Logs) ([]byte, error) { type entry struct { LogText string `json:"log_text"` - Timestamp string `json:"timestamp"` + Timestamp string `json:"ts_rfc3339"` } func (ce *marshaler) extractRawLogs(ld plog.Logs) ([]entry, error) { diff --git a/exporter/chronicleexporter/marshal_test.go b/exporter/chronicleexporter/marshal_test.go index 7b82a85dd..740a4a4a3 100644 --- a/exporter/chronicleexporter/marshal_test.go +++ b/exporter/chronicleexporter/marshal_test.go @@ -81,7 +81,7 @@ func TestMarshalRawLogs(t *testing.T) { logRecords: []plog.LogRecord{ mockLogRecord(t, "Test body", map[string]any{"key1": "value1"}), }, - expectedJSON: `{"custumer_id":"test_customer_id","entries":[{"log_text":"Test body","timestamp":"2023-01-02T03:04:05.000000006Z"}],"log_type":"test_log_type"}`, + expectedJSON: `{"custumer_id":"test_customer_id","entries":[{"log_text":"Test body","ts_rfc3339":"2023-01-02T03:04:05.000000006Z"}],"log_type":"test_log_type"}`, logType: "test_log_type", rawLogField: "body", }, @@ -91,7 +91,7 @@ func TestMarshalRawLogs(t *testing.T) { mockLogRecord(t, "First log", map[string]any{"key1": "value1"}), mockLogRecord(t, "Second log", map[string]any{"key2": "value2"}), }, - expectedJSON: `{"custumer_id":"test_customer_id","entries":[{"log_text":"First log","timestamp":"2023-01-02T03:04:05.000000006Z"},{"log_text":"Second log","timestamp":"2023-01-02T03:04:05.000000006Z"}],"log_type":"test_log_type"}`, + expectedJSON: `{"custumer_id":"test_customer_id","entries":[{"log_text":"First log","ts_rfc3339":"2023-01-02T03:04:05.000000006Z"},{"log_text":"Second log","ts_rfc3339":"2023-01-02T03:04:05.000000006Z"}],"log_type":"test_log_type"}`, logType: "test_log_type", rawLogField: "body", }, @@ -100,7 +100,7 @@ func TestMarshalRawLogs(t *testing.T) { logRecords: []plog.LogRecord{ mockLogRecord(t, "Test body", map[string]any{"key1": "value1", "key2": "value2"}), }, - expectedJSON: `{"custumer_id":"test_customer_id","entries":[{"log_text":"{\"key1\":\"value1\",\"key2\":\"value2\"}","timestamp":"2023-01-02T03:04:05.000000006Z"}],"log_type":"test_log_type"}`, + expectedJSON: `{"custumer_id":"test_customer_id","entries":[{"log_text":"{\"key1\":\"value1\",\"key2\":\"value2\"}","ts_rfc3339":"2023-01-02T03:04:05.000000006Z"}],"log_type":"test_log_type"}`, logType: "test_log_type", rawLogField: "attributes", }, @@ -109,7 +109,7 @@ func TestMarshalRawLogs(t *testing.T) { logRecords: []plog.LogRecord{ mockLogRecord(t, "Test body", map[string]any{"nested": map[string]any{"key": "value"}}), }, - expectedJSON: `{"custumer_id":"test_customer_id","entries":[{"log_text":"value","timestamp":"2023-01-02T03:04:05.000000006Z"}],"log_type":"test_log_type"}`, + expectedJSON: `{"custumer_id":"test_customer_id","entries":[{"log_text":"value","ts_rfc3339":"2023-01-02T03:04:05.000000006Z"}],"log_type":"test_log_type"}`, logType: "test_log_type", rawLogField: `attributes["nested"]["key"]`, }, @@ -143,7 +143,7 @@ func TestMarshalRawLogs(t *testing.T) { }, }), }, - expectedJSON: `{"custumer_id":"test_customer_id","entries":[{"log_text":"{\"event\":{\"details\":{\"ip\":\"192.168.1.1\",\"username\":\"user123\"},\"type\":\"login_attempt\"}}","timestamp":"1970-01-01T00:00:00Z"}],"log_type":"test_log_type"}`, + expectedJSON: `{"custumer_id":"test_customer_id","entries":[{"log_text":"{\"event\":{\"details\":{\"ip\":\"192.168.1.1\",\"username\":\"user123\"},\"type\":\"login_attempt\"}}","ts_rfc3339":"1970-01-01T00:00:00Z"}],"log_type":"test_log_type"}`, logType: "test_log_type", rawLogField: "body", }, @@ -160,7 +160,7 @@ func TestMarshalRawLogs(t *testing.T) { }, }), }, - expectedJSON: `{"custumer_id":"test_customer_id","entries":[{"log_text":"user123","timestamp":"1970-01-01T00:00:00Z"}],"log_type":"test_log_type"}`, + expectedJSON: `{"custumer_id":"test_customer_id","entries":[{"log_text":"user123","ts_rfc3339":"1970-01-01T00:00:00Z"}],"log_type":"test_log_type"}`, logType: "test_log_type", rawLogField: `body["event"]["details"]["username"]`, },