Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .chloggen/routing-default-error-mode-ignore.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. receiver/filelog)
component: connector/routing

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add `connector.routing.defaultErrorModeIgnore` feature gate to change default `error_mode` to `ignore`

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [48418]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext: |
When the feature gate is enabled, the connector defaults to `ignore` mode which preserves
valid data when an OTTL condition error occurs, improving resiliency. This is a breaking
change rolled out via feature gate to allow gradual adoption.

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
3 changes: 2 additions & 1 deletion connector/routingconnector/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ type Config struct {
// 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`.
// The default value is `propagate`, but when the `connector.routing.defaultErrorModeIgnore`
// feature gate is enabled, the default changes to `ignore`.
ErrorMode ottl.ErrorMode `mapstructure:"error_mode"`
// DefaultPipelines contains the list of pipelines to use when a more specific record can't be
// found in the routing table.
Expand Down
9 changes: 8 additions & 1 deletion connector/routingconnector/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl"
)

func defaultErrorMode() ottl.ErrorMode {
if metadata.ConnectorRoutingDefaultErrorModeIgnoreFeatureGate.IsEnabled() {
return ottl.IgnoreError
}
return ottl.PropagateError
}

// NewFactory returns a ConnectorFactory.
func NewFactory() connector.Factory {
return connector.NewFactory(
Expand All @@ -30,7 +37,7 @@ func NewFactory() connector.Factory {
// createDefaultConfig creates the default configuration.
func createDefaultConfig() component.Config {
return &Config{
ErrorMode: ottl.PropagateError,
ErrorMode: defaultErrorMode(),
}
}

Expand Down
36 changes: 36 additions & 0 deletions connector/routingconnector/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/connector"
"go.opentelemetry.io/collector/connector/connectortest"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/consumer/consumertest"
"go.opentelemetry.io/collector/featuregate"
"go.opentelemetry.io/collector/pipeline"

"github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector/internal/metadata"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl"
)

func TestConnectorCreatedWithValidConfiguration(t *testing.T) {
Expand Down Expand Up @@ -60,3 +63,36 @@ func TestCreationFailsWithIncorrectConsumer(t *testing.T) {
assert.ErrorIs(t, err, errUnexpectedConsumer)
assert.Nil(t, conn)
}

func TestDefaultErrorModeWithFeatureGate(t *testing.T) {
tests := []struct {
name string
featureGateEnabled bool
expectedErrorMode ottl.ErrorMode
}{
{
name: "feature gate disabled",
featureGateEnabled: false,
expectedErrorMode: ottl.PropagateError,
},
{
name: "feature gate enabled",
featureGateEnabled: true,
expectedErrorMode: ottl.IgnoreError,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
previousValue := metadata.ConnectorRoutingDefaultErrorModeIgnoreFeatureGate.IsEnabled()
require.NoError(t, featuregate.GlobalRegistry().Set(metadata.ConnectorRoutingDefaultErrorModeIgnoreFeatureGate.ID(), tt.featureGateEnabled))
defer func() {
require.NoError(t, featuregate.GlobalRegistry().Set(metadata.ConnectorRoutingDefaultErrorModeIgnoreFeatureGate.ID(), previousValue))
}()

factory := NewFactory()
cfg := factory.CreateDefaultConfig().(*Config)
assert.Equal(t, tt.expectedErrorMode, cfg.ErrorMode)
})
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions connector/routingconnector/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ status:
emeritus: [jpkrohling, mwear]
seeking_new: true

feature_gates:
- id: connector.routing.defaultErrorModeIgnore
description: When enabled, the default error_mode is `ignore` instead of `propagate`.
stage: alpha
reference_url: https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/48418

tests:
skip_lifecycle: true
skip_shutdown: true
Loading