mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-11 21:09:09 +08:00
Fix: logs pipelines: ignore coalesce op when generating nil check for add value expressions (#4305)
* chore: panic if agent config recommendation can't be generated * chore: add case with coalesce op in field nil check generation tests * fix: ignore expr ast member nodes that contain coalesce op in them
This commit is contained in:
parent
e792c48f6d
commit
86ff865842
@ -352,6 +352,13 @@ type logFieldsInExprExtractor struct {
|
|||||||
func (v *logFieldsInExprExtractor) Visit(node *ast.Node) {
|
func (v *logFieldsInExprExtractor) Visit(node *ast.Node) {
|
||||||
if n, ok := (*node).(*ast.MemberNode); ok {
|
if n, ok := (*node).(*ast.MemberNode); ok {
|
||||||
memberRef := n.String()
|
memberRef := n.String()
|
||||||
|
|
||||||
|
// coalesce ops end up as MemberNode right now for some reason.
|
||||||
|
// ignore such member nodes.
|
||||||
|
if strings.Contains(memberRef, "??") {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(memberRef, "attributes") || strings.HasPrefix(memberRef, "resource") {
|
if strings.HasPrefix(memberRef, "attributes") || strings.HasPrefix(memberRef, "resource") {
|
||||||
v.referencedFields = append(v.referencedFields, memberRef)
|
v.referencedFields = append(v.referencedFields, memberRef)
|
||||||
}
|
}
|
||||||
|
@ -698,6 +698,13 @@ func TestMembershipOpInProcessorFieldExpressions(t *testing.T) {
|
|||||||
Name: "add3",
|
Name: "add3",
|
||||||
Field: `attributes["attrs.test.value"]`,
|
Field: `attributes["attrs.test.value"]`,
|
||||||
Value: `EXPR(attributes.test?.value)`,
|
Value: `EXPR(attributes.test?.value)`,
|
||||||
|
}, {
|
||||||
|
ID: "add4",
|
||||||
|
Type: "add",
|
||||||
|
Enabled: true,
|
||||||
|
Name: "add4",
|
||||||
|
Field: `attributes["attrs.test.value"]`,
|
||||||
|
Value: `EXPR((attributes.temp?.request_context?.scraper ?? [nil])[0])`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -276,8 +277,8 @@ func (agent *Agent) processStatusUpdate(
|
|||||||
func (agent *Agent) updateRemoteConfig(configProvider AgentConfigProvider) bool {
|
func (agent *Agent) updateRemoteConfig(configProvider AgentConfigProvider) bool {
|
||||||
recommendedConfig, confId, err := configProvider.RecommendAgentConfig([]byte(agent.EffectiveConfig))
|
recommendedConfig, confId, err := configProvider.RecommendAgentConfig([]byte(agent.EffectiveConfig))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
zap.S().Errorf("could not generate config recommendation for agent %d: %w", agent.ID, err)
|
// The server must always recommend a config.
|
||||||
return false
|
panic(fmt.Errorf("could not generate config recommendation for agent %s: %w", agent.ID, err))
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg := protobufs.AgentRemoteConfig{
|
cfg := protobufs.AgentRemoteConfig{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user