Skip to content

Commit 9f0baf6

Browse files
[connector/routing] Add feature gate to change default error_mode to ignore (#48433)
The `error_mode` in the routing connector determines how errors during OTTL condition processing are handled. The current default is `propagate`, which can drop valid data when a condition error occurs. This PR adds a feature gate `connector.routing.defaultErrorModeIgnore` that when enabled changes the default to `ignore`. In this mode, errors are logged for visibility but valid data is preserved and processing continues with the next condition. The feature gate allows gradual rollout of this breaking change. Fixes #48418 --------- Co-authored-by: Edmo Vamerlatti Costa <11836452+edmocosta@users.noreply.github.com>
1 parent 7d830a7 commit 9f0baf6

9 files changed

Lines changed: 110 additions & 4 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. receiver/filelog)
7+
component: connector/routing
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Add `connector.routing.defaultErrorModeIgnore` feature gate to change default `error_mode` from `propagate` to `ignore`
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [48418]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [user]

connector/routingconnector/config.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ type Config struct {
3838
// condition has an error then the payload will be routed to the default exporter. `propagate`
3939
// means the processor returns the error up the pipeline. This will result in the payload being
4040
// dropped from the collector.
41-
// The default value is `propagate`.
41+
// The default value is `propagate`, but when the `connector.routing.defaultErrorModeIgnore`
42+
// feature gate is enabled, the default changes to `ignore`.
4243
ErrorMode ottl.ErrorMode `mapstructure:"error_mode"`
4344
// DefaultPipelines contains the list of pipelines to use when a more specific record can't be
4445
// found in the routing table.

connector/routingconnector/config.schema.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ properties:
3131
items:
3232
$ref: go.opentelemetry.io/collector/pipeline.id
3333
error_mode:
34-
description: ErrorMode determines how the processor reacts to errors that occur while processing an OTTL condition. Valid values are `ignore` and `propagate`. `ignore` means the processor ignores errors returned by conditions and continues on to the next condition. This is the recommended mode. If `ignore` is used and a statement's condition has an error then the payload will be routed to the default exporter. `propagate` means the processor returns the error up the pipeline. This will result in the payload being dropped from the collector. The default value is `propagate`.
34+
description: ErrorMode determines how the processor reacts to errors that occur while processing an OTTL condition. Valid values are `ignore` and `propagate`. `ignore` means the processor ignores errors returned by conditions and continues on to the next condition. This is the recommended mode. If `ignore` is used and a statement's condition has an error then the payload will be routed to the default exporter. `propagate` means the processor returns the error up the pipeline. This will result in the payload being dropped from the collector. The default value is `propagate`, but when the `connector.routing.defaultErrorModeIgnore` feature gate is enabled, the default changes to `ignore`.
3535
$ref: /pkg/ottl.error_mode
3636
table:
3737
description: Table contains the routing table for this processor. Required.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[comment]: <> (Code generated by mdatagen. DO NOT EDIT.)
2+
3+
# routing
4+
5+
## Feature Gates
6+
7+
This component has the following feature gates:
8+
9+
| Feature Gate | Stage | Description | From Version | To Version | Reference |
10+
| ------------ | ----- | ----------- | ------------ | ---------- | --------- |
11+
| `connector.routing.defaultErrorModeIgnore` | alpha | When enabled, the default error_mode is `ignore` instead of `propagate`. | v0.155.0 | N/A | [Link](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/48418) |
12+
13+
For more information about feature gates, see the [Feature Gates](https://github.com/open-telemetry/opentelemetry-collector/blob/main/featuregate/README.md) documentation.

connector/routingconnector/factory.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ import (
1616
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl"
1717
)
1818

19+
func defaultErrorMode() ottl.ErrorMode {
20+
if metadata.ConnectorRoutingDefaultErrorModeIgnoreFeatureGate.IsEnabled() {
21+
return ottl.IgnoreError
22+
}
23+
return ottl.PropagateError
24+
}
25+
1926
// NewFactory returns a ConnectorFactory.
2027
func NewFactory() connector.Factory {
2128
return connector.NewFactory(
@@ -30,7 +37,7 @@ func NewFactory() connector.Factory {
3037
// createDefaultConfig creates the default configuration.
3138
func createDefaultConfig() component.Config {
3239
return &Config{
33-
ErrorMode: ottl.PropagateError,
40+
ErrorMode: defaultErrorMode(),
3441
}
3542
}
3643

connector/routingconnector/factory_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ import (
77
"testing"
88

99
"github.com/stretchr/testify/assert"
10+
"github.com/stretchr/testify/require"
1011
"go.opentelemetry.io/collector/connector"
1112
"go.opentelemetry.io/collector/connector/connectortest"
1213
"go.opentelemetry.io/collector/consumer"
1314
"go.opentelemetry.io/collector/consumer/consumertest"
15+
"go.opentelemetry.io/collector/featuregate"
1416
"go.opentelemetry.io/collector/pipeline"
1517

1618
"github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector/internal/metadata"
19+
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl"
1720
)
1821

1922
func TestConnectorCreatedWithValidConfiguration(t *testing.T) {
@@ -60,3 +63,36 @@ func TestCreationFailsWithIncorrectConsumer(t *testing.T) {
6063
assert.ErrorIs(t, err, errUnexpectedConsumer)
6164
assert.Nil(t, conn)
6265
}
66+
67+
func TestDefaultErrorModeWithFeatureGate(t *testing.T) {
68+
tests := []struct {
69+
name string
70+
featureGateEnabled bool
71+
expectedErrorMode ottl.ErrorMode
72+
}{
73+
{
74+
name: "feature gate disabled",
75+
featureGateEnabled: false,
76+
expectedErrorMode: ottl.PropagateError,
77+
},
78+
{
79+
name: "feature gate enabled",
80+
featureGateEnabled: true,
81+
expectedErrorMode: ottl.IgnoreError,
82+
},
83+
}
84+
85+
for _, tt := range tests {
86+
t.Run(tt.name, func(t *testing.T) {
87+
previousValue := metadata.ConnectorRoutingDefaultErrorModeIgnoreFeatureGate.IsEnabled()
88+
require.NoError(t, featuregate.GlobalRegistry().Set(metadata.ConnectorRoutingDefaultErrorModeIgnoreFeatureGate.ID(), tt.featureGateEnabled))
89+
defer func() {
90+
require.NoError(t, featuregate.GlobalRegistry().Set(metadata.ConnectorRoutingDefaultErrorModeIgnoreFeatureGate.ID(), previousValue))
91+
}()
92+
93+
factory := NewFactory()
94+
cfg := factory.CreateDefaultConfig().(*Config)
95+
assert.Equal(t, tt.expectedErrorMode, cfg.ErrorMode)
96+
})
97+
}
98+
}

connector/routingconnector/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ require (
1515
go.opentelemetry.io/collector/connector/connectortest v0.154.1-0.20260612191519-af182d232650
1616
go.opentelemetry.io/collector/consumer v1.60.1-0.20260612191519-af182d232650
1717
go.opentelemetry.io/collector/consumer/consumertest v0.154.1-0.20260612191519-af182d232650
18+
go.opentelemetry.io/collector/featuregate v1.60.1-0.20260612191519-af182d232650
1819
go.opentelemetry.io/collector/pdata v1.60.1-0.20260612191519-af182d232650
1920
go.opentelemetry.io/collector/pipeline v1.60.1-0.20260612191519-af182d232650
2021
go.uber.org/goleak v1.3.0
@@ -59,7 +60,6 @@ require (
5960
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
6061
go.opentelemetry.io/collector/connector/xconnector v0.154.1-0.20260612191519-af182d232650 // indirect
6162
go.opentelemetry.io/collector/consumer/xconsumer v0.154.1-0.20260612191519-af182d232650 // indirect
62-
go.opentelemetry.io/collector/featuregate v1.60.1-0.20260612191519-af182d232650 // indirect
6363
go.opentelemetry.io/collector/internal/componentalias v0.154.1-0.20260612191519-af182d232650 // indirect
6464
go.opentelemetry.io/collector/internal/fanoutconsumer v0.154.1-0.20260612191519-af182d232650 // indirect
6565
go.opentelemetry.io/collector/pdata/pprofile v0.154.1-0.20260612191519-af182d232650 // indirect

connector/routingconnector/internal/metadata/generated_feature_gates.go

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

connector/routingconnector/metadata.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ status:
1111
emeritus: [jpkrohling]
1212
seeking_new: true
1313

14+
feature_gates:
15+
- id: connector.routing.defaultErrorModeIgnore
16+
description: When enabled, the default error_mode is `ignore` instead of `propagate`.
17+
stage: alpha
18+
from_version: v0.155.0
19+
reference_url: https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/48418
20+
1421
tests:
1522
skip_lifecycle: true
1623
skip_shutdown: true

0 commit comments

Comments
 (0)