Skip to content

Commit

Permalink
fix: always write detected_level when enabled, even if unknown (#14464)
Browse files Browse the repository at this point in the history
Co-authored-by: shantanualshi <[email protected]>
  • Loading branch information
trevorwhitney and shantanualsi authored Oct 15, 2024
1 parent e2a209c commit 41c6b6c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/distributor/distributor.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ func (d *Distributor) Push(ctx context.Context, req *logproto.PushRequest) (*log
} else {
logLevel = detectLogLevelFromLogEntry(entry, structuredMetadata)
}
if logLevel != constants.LogLevelUnknown && logLevel != "" {
if logLevel != "" {
entry.StructuredMetadata = append(entry.StructuredMetadata, logproto.LabelAdapter{
Name: constants.LevelLabel,
Value: logLevel,
Expand Down
2 changes: 1 addition & 1 deletion pkg/distributor/distributor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1640,7 +1640,7 @@ func Test_DetectLogLevels(t *testing.T) {
require.NoError(t, err)
topVal := ingester.Peek()
require.Equal(t, `{foo="bar"}`, topVal.Streams[0].Labels)
require.Len(t, topVal.Streams[0].Entries[0].StructuredMetadata, 0)
require.Len(t, topVal.Streams[0].Entries[0].StructuredMetadata, 1)
})

t.Run("log level detection enabled and warn logs", func(t *testing.T) {
Expand Down

0 comments on commit 41c6b6c

Please sign in to comment.