From 1c609c8f827cb743e771be02b088afc7477bca32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Ma=C5=82ek?= <69143962+pmalek-sumo@users.noreply.github.com> Date: Mon, 12 Apr 2021 15:07:39 +0200 Subject: [PATCH] Make entry.Entry smaller by reordeing fields (#96) --- entry/entry.go | 8 ++++---- operator/builtin/output/stdout/stdout_test.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/entry/entry.go b/entry/entry.go index 7c53656a716f..c41f726c5ee8 100644 --- a/entry/entry.go +++ b/entry/entry.go @@ -43,14 +43,14 @@ var now = getNow() // Entry is a flexible representation of log data associated with a timestamp. type Entry struct { Timestamp time.Time `json:"timestamp" yaml:"timestamp"` - Severity Severity `json:"severity" yaml:"severity"` - SeverityText string `json:"severity_text,omitempty" yaml:"severity_text,omitempty"` + Body interface{} `json:"body" yaml:"body"` Attributes map[string]string `json:"attributes,omitempty" yaml:"attributes,omitempty"` Resource map[string]string `json:"resource,omitempty" yaml:"resource,omitempty"` - Body interface{} `json:"body" yaml:"body"` - TraceId []byte `json:"trace_id,omitempty" yaml:"trace_id,omitempty"` + SeverityText string `json:"severity_text,omitempty" yaml:"severity_text,omitempty"` SpanId []byte `json:"span_id,omitempty" yaml:"span_id,omitempty"` + TraceId []byte `json:"trace_id,omitempty" yaml:"trace_id,omitempty"` TraceFlags []byte `json:"trace_flags,omitempty" yaml:"trace_flags,omitempty"` + Severity Severity `json:"severity" yaml:"severity"` } // New will create a new log entry with current timestamp and an empty body. diff --git a/operator/builtin/output/stdout/stdout_test.go b/operator/builtin/output/stdout/stdout_test.go index 9648298c324d..b66527ce2407 100644 --- a/operator/builtin/output/stdout/stdout_test.go +++ b/operator/builtin/output/stdout/stdout_test.go @@ -56,6 +56,6 @@ func TestStdoutOperator(t *testing.T) { marshalledTimestamp, err := json.Marshal(ts) require.NoError(t, err) - expected := `{"timestamp":` + string(marshalledTimestamp) + `,"severity":0,"body":"test body"}` + "\n" + expected := `{"timestamp":` + string(marshalledTimestamp) + `,"body":"test body","severity":0}` + "\n" require.Equal(t, expected, buf.String()) }