Skip to content

Commit 233dcc0

Browse files
committed
Simplify and add a comment
1 parent 02e8d02 commit 233dcc0

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

  • integration-tests/docker/common

integration-tests/docker/common/log.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ func (e *LogEntry) UnmarshalJSON(data []byte) error {
5353
return nil
5454
}
5555

56+
// Query responses use a object in the third array element, for example:
57+
// ["<ts>", "<line>", {"structuredMetadata": {...}}]
58+
// See https://github.com/grafana/loki/blob/5f06abe88d1a5cb7df12cfd2e07808c9d3238312/pkg/loghttp/entry.go#L63-L73
59+
// Because we always use this to unmashal query response we don't have to handle the flat map case.
5660
var metadata struct {
5761
StructuredMetadata map[string]string `json:"structuredMetadata"`
5862
}
@@ -62,10 +66,8 @@ func (e *LogEntry) UnmarshalJSON(data []byte) error {
6266

6367
if len(metadata.StructuredMetadata) > 0 {
6468
e.Metadata.StructuredMetadata = metadata.StructuredMetadata
65-
return nil
6669
}
67-
68-
return json.Unmarshal(raw[2], &e.Metadata.StructuredMetadata)
70+
return nil
6971
}
7072

7173
func (m *LogResponse) Unmarshal(data []byte) error {

0 commit comments

Comments
 (0)