Skip to content

Commit

Permalink
Update timestamp marshal name
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel Rodriguez committed Nov 10, 2023
1 parent f6e64be commit d381570
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion exporter/chronicleexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
2 changes: 1 addition & 1 deletion exporter/chronicleexporter/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 6 additions & 6 deletions exporter/chronicleexporter/marshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand All @@ -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",
},
Expand All @@ -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",
},
Expand All @@ -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"]`,
},
Expand Down Expand Up @@ -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",
},
Expand All @@ -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"]`,
},
Expand Down

0 comments on commit d381570

Please sign in to comment.