Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

fix: dont enrich if non empty keys are not same (#4930)

Nityananda Gohain5326f2d23b7d
diff --git a/pkg/query-service/app/logs/v3/enrich_query.go b/pkg/query-service/app/logs/v3/enrich_query.go
index 465919360f..8a7bc85970 100644
--- a/pkg/query-service/app/logs/v3/enrich_query.go
+++ b/pkg/query-service/app/logs/v3/enrich_query.go
@@ -145,12 +145,13 @@ func enrichFieldWithMetadata(field v3.AttributeKey, fields map[string]v3.Attribu
// check if the field is present in the fields map
if existingField, ok := fields[field.Key]; ok {
- if existingField.IsColumn {
+ // don't update if type is not the same
+ if (field.Type == "" && field.DataType == "") ||
+ (field.Type == existingField.Type && field.DataType == existingField.DataType) ||
+ (field.Type == "" && field.DataType == existingField.DataType) ||
+ (field.DataType == "" && field.Type == existingField.Type) {
return existingField
}
- field.Type = existingField.Type
- field.DataType = existingField.DataType
- return field
}
// enrich with default values if metadata is not found
diff --git a/pkg/query-service/app/logs/v3/enrich_query_test.go b/pkg/query-service/app/logs/v3/enrich_query_test.go
index 3605fa5408..32d714925c 100644
--- a/pkg/query-service/app/logs/v3/enrich_query_test.go
+++ b/pkg/query-service/app/logs/v3/enrich_query_test.go
@@ -342,6 +342,57 @@ var testEnrichParamsData = []struct {
},
},
},
+ {
+ Name: "Don't enrich if other keys are non empty and not same",
+ Params: v3.QueryRangeParamsV3{
+ CompositeQuery: &v3.CompositeQuery{
+ BuilderQueries: map[string]*v3.BuilderQuery{
+ "test": {
+ QueryName: "test",
+ Expression: "test",
+ DataSource: v3.DataSourceLogs,
+ AggregateAttribute: v3.AttributeKey{
+ Key: "test",
+ Type: v3.AttributeKeyTypeResource,
+ DataType: v3.AttributeKeyDataTypeInt64,
+ },
+ Filters: &v3.FilterSet{Operator: "AND", Items: []v3.FilterItem{
+ {Key: v3.AttributeKey{Key: "test", Type: v3.AttributeKeyTypeTag}, Value: "test", Operator: "="},
+ {Key: v3.AttributeKey{Key: "test", DataType: v3.AttributeKeyDataTypeString}, Value: "test1", Operator: "="},
+ }},
+ },
+ },
+ },
+ },
+ Fields: map[string]v3.AttributeKey{
+ "test": {
+ Key: "test",
+ Type: v3.AttributeKeyTypeTag,
+ DataType: v3.AttributeKeyDataTypeString,
+ IsColumn: true,
+ },
+ },
+ Result: v3.QueryRangeParamsV3{
+ CompositeQuery: &v3.CompositeQuery{
+ BuilderQueries: map[string]*v3.BuilderQuery{
+ "test": {
+ QueryName: "test",
+ Expression: "test",
+ DataSource: v3.DataSourceLogs,
+ AggregateAttribute: v3.AttributeKey{
+ Key: "test",
+ Type: v3.AttributeKeyTypeResource,
+ DataType: v3.AttributeKeyDataTypeInt64,
+ },
+ Filters: &v3.FilterSet{Operator: "AND", Items: []v3.FilterItem{
+ {Key: v3.AttributeKey{Key: "test", Type: v3.AttributeKeyTypeTag, DataType: v3.AttributeKeyDataTypeString, IsColumn: true}, Value: "test", Operator: "="},
+ {Key: v3.AttributeKey{Key: "test", Type: v3.AttributeKeyTypeTag, DataType: v3.AttributeKeyDataTypeString, IsColumn: true}, Value: "test1", Operator: "="},
+ }},
+ },
+ },
+ },
+ },
+ },
}
func TestEnrichParams(t *testing.T) {