mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-15 15:35:59 +08:00
Fix: log pipelines generates bad config if first op is disabled (#6174)
* chore: add test reproducing bad config generation when first pipeline op is disabled * fix: logs pipelines: set router output to first enabled operator
This commit is contained in:
parent
5187ed58a0
commit
2728ddd255
@ -1,12 +1,14 @@
|
|||||||
package logparsingpipeline
|
package logparsingpipeline
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
. "github.com/smartystreets/goconvey/convey"
|
. "github.com/smartystreets/goconvey/convey"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"go.signoz.io/signoz/pkg/query-service/constants"
|
"go.signoz.io/signoz/pkg/query-service/constants"
|
||||||
|
"go.signoz.io/signoz/pkg/query-service/model"
|
||||||
v3 "go.signoz.io/signoz/pkg/query-service/model/v3"
|
v3 "go.signoz.io/signoz/pkg/query-service/model/v3"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
@ -293,3 +295,74 @@ func TestPipelineAliasCollisionsDontResultInDuplicateCollectorProcessors(t *test
|
|||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPipelineRouterWorksEvenIfFirstOpIsDisabled(t *testing.T) {
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
testPipelines := []Pipeline{
|
||||||
|
{
|
||||||
|
OrderId: 1,
|
||||||
|
Name: "pipeline1",
|
||||||
|
Alias: "pipeline1",
|
||||||
|
Enabled: true,
|
||||||
|
Filter: &v3.FilterSet{
|
||||||
|
Operator: "AND",
|
||||||
|
Items: []v3.FilterItem{
|
||||||
|
{
|
||||||
|
Key: v3.AttributeKey{
|
||||||
|
Key: "method",
|
||||||
|
DataType: v3.AttributeKeyDataTypeString,
|
||||||
|
Type: v3.AttributeKeyTypeTag,
|
||||||
|
},
|
||||||
|
Operator: "=",
|
||||||
|
Value: "GET",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Config: []PipelineOperator{
|
||||||
|
{
|
||||||
|
OrderId: 1,
|
||||||
|
ID: "add",
|
||||||
|
Type: "add",
|
||||||
|
Field: "attributes.test",
|
||||||
|
Value: "val",
|
||||||
|
Enabled: false,
|
||||||
|
Name: "test add",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
OrderId: 2,
|
||||||
|
ID: "add2",
|
||||||
|
Type: "add",
|
||||||
|
Field: "attributes.test2",
|
||||||
|
Value: "val2",
|
||||||
|
Enabled: true,
|
||||||
|
Name: "test add 2",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
result, collectorWarnAndErrorLogs, err := SimulatePipelinesProcessing(
|
||||||
|
context.Background(),
|
||||||
|
testPipelines,
|
||||||
|
[]model.SignozLog{
|
||||||
|
makeTestSignozLog(
|
||||||
|
"test log body",
|
||||||
|
map[string]any{
|
||||||
|
"method": "GET",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
require.Nil(err)
|
||||||
|
require.Equal(0, len(collectorWarnAndErrorLogs))
|
||||||
|
require.Equal(1, len(result))
|
||||||
|
|
||||||
|
require.Equal(
|
||||||
|
map[string]string{
|
||||||
|
"method": "GET",
|
||||||
|
"test2": "val2",
|
||||||
|
}, result[0].Attributes_string,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
@ -49,7 +49,7 @@ func PreparePipelineProcessor(pipelines []Pipeline) (map[string]interface{}, []s
|
|||||||
Type: "router",
|
Type: "router",
|
||||||
Routes: &[]Route{
|
Routes: &[]Route{
|
||||||
{
|
{
|
||||||
Output: v.Config[0].ID,
|
Output: operators[0].ID,
|
||||||
Expr: filterExpr,
|
Expr: filterExpr,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user