mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-12 22:49:03 +08:00
chore: empty out trace parser fields if parseFrom is empty (#3850)
This commit is contained in:
parent
991e39aad3
commit
9c21449239
@ -72,6 +72,11 @@ func getOperators(ops []PipelineOperator) []PipelineOperator {
|
||||
if len(filteredOp) > 0 {
|
||||
filteredOp[len(filteredOp)-1].Output = operator.ID
|
||||
}
|
||||
|
||||
if operator.Type == "trace_parser" {
|
||||
cleanTraceParser(&operator)
|
||||
}
|
||||
|
||||
filteredOp = append(filteredOp, operator)
|
||||
} else if i == len(ops)-1 && len(filteredOp) != 0 {
|
||||
filteredOp[len(filteredOp)-1].Output = ""
|
||||
@ -79,3 +84,15 @@ func getOperators(ops []PipelineOperator) []PipelineOperator {
|
||||
}
|
||||
return filteredOp
|
||||
}
|
||||
|
||||
func cleanTraceParser(operator *PipelineOperator) {
|
||||
if operator.TraceId != nil && len(operator.TraceId.ParseFrom) < 1 {
|
||||
operator.TraceId = nil
|
||||
}
|
||||
if operator.SpanId != nil && len(operator.SpanId.ParseFrom) < 1 {
|
||||
operator.SpanId = nil
|
||||
}
|
||||
if operator.TraceFlags != nil && len(operator.TraceFlags.ParseFrom) < 1 {
|
||||
operator.TraceFlags = nil
|
||||
}
|
||||
}
|
||||
|
@ -295,6 +295,19 @@ func TestTraceParsingPreview(t *testing.T) {
|
||||
expectedTraceFlags, err := strconv.ParseUint(testTraceFlags, 16, 16)
|
||||
require.Nil(err)
|
||||
require.Equal(uint32(expectedTraceFlags), processed.TraceFlags)
|
||||
|
||||
// trace parser should work even if parse_from value is empty
|
||||
testPipelines[0].Config[0].SpanId.ParseFrom = ""
|
||||
result, err = SimulatePipelinesProcessing(
|
||||
context.Background(),
|
||||
testPipelines,
|
||||
[]model.SignozLog{
|
||||
testLog,
|
||||
},
|
||||
)
|
||||
require.Nil(err)
|
||||
require.Equal(1, len(result))
|
||||
require.Equal("", result[0].SpanID)
|
||||
}
|
||||
|
||||
func makeTestLogEntry(
|
||||
|
Loading…
x
Reference in New Issue
Block a user