Skip to content
Prev Previous commit
Next Next commit
check if SM is valid in the correct place
Signed-off-by: Callum Styan <callumstyan@gmail.com>
  • Loading branch information
cstyan committed Nov 28, 2024
commit 20fccbd7f33f2b325f0d9b2e1707b8920eee298f
6 changes: 4 additions & 2 deletions pkg/distributor/distributor.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,14 +528,16 @@ func (d *Distributor) Push(ctx context.Context, req *logproto.PushRequest) (*log
}

structuredMetadata := logproto.FromLabelAdaptersToLabels(entry.StructuredMetadata)
if shouldDiscoverLevels {
logLevel, ok := levelDetector.extractLogLevel(lbs, structuredMetadata, entry)
if len(entry.StructuredMetadata) > 0 {
for i := range entry.StructuredMetadata {
structuredMetadata[i].Name = otlptranslate.NormalizeLabel(structuredMetadata[i].Name)
if strings.ContainsRune(structuredMetadata[i].Value, utf8.RuneError) {
structuredMetadata[i].Value = strings.Map(removeInvalidUtf, structuredMetadata[i].Value)
}
}
}
if shouldDiscoverLevels {
logLevel, ok := levelDetector.extractLogLevel(lbs, structuredMetadata, entry)
if ok {
entry.StructuredMetadata = append(entry.StructuredMetadata, logLevel)
}
Expand Down