Skip to content
Draft
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
2 changes: 1 addition & 1 deletion connector/signaltometricsconnector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ signal_to_metrics:
The `error_mode` configuration option determines how the connector handles errors that occur while processing OTTL expressions:

- `error_mode` (optional): Determines how errors returned from OTTL expressions are handled. Valid values are `propagate`, `ignore`, and `silent`.
- `propagate` (default): Errors cause the entire batch to fail and be returned up the pipeline. This will result in the payload being dropped from the collector.
- `propagate` (default): Errors cause the entire batch to fail and be returned up the pipeline. This will result in the payload being dropped from the collector. The default will change to `ignore` when the `connector.signaltometrics.defaultErrorModeIgnore` feature gate is stable.
- `ignore`: Errors are logged and the specific record that caused the error is skipped, but processing continues for the rest of the batch.
- `silent`: Errors are not logged and the specific record that caused the error is skipped, but processing continues for the rest of the batch.

Expand Down
3 changes: 2 additions & 1 deletion connector/signaltometricsconnector/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ type Config struct {
// If an error occurs, the record is skipped and the error is logged.
// `silent` means the connector ignores errors returned by conditions and continues processing.
// If an error occurs, the record is skipped and the error is not logged.
// The default value is `propagate`.
// The current default value is `propagate`, which will change to `ignore` when the
// `connector.signaltometrics.defaultErrorModeIgnore` feature gate is stable.
ErrorMode ottl.ErrorMode `mapstructure:"error_mode"`
// prevent unkeyed literal initialization
_ struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $defs:
items:
$ref: metric_info
error_mode:
description: ErrorMode determines how the connector reacts to errors that occur while processing an OTTL condition or statement during runtime data consumption. This setting does NOT affect errors during OTTL statement parsing at configuration time - those will always cause startup failures. Valid values are `propagate`, `ignore`, and `silent`. `propagate` means the connector returns the error up the pipeline. This will result in the payload being dropped from the collector. `ignore` means the connector ignores errors returned by conditions and continues processing. If an error occurs, the record is skipped and the error is logged. `silent` means the connector ignores errors returned by conditions and continues processing. If an error occurs, the record is skipped and the error is not logged. The default value is `propagate`.
description: ErrorMode determines how the connector reacts to errors that occur while processing an OTTL condition or statement during runtime data consumption. This setting does NOT affect errors during OTTL statement parsing at configuration time - those will always cause startup failures. Valid values are `propagate`, `ignore`, and `silent`. `propagate` means the connector returns the error up the pipeline. This will result in the payload being dropped from the collector. `ignore` means the connector ignores errors returned by conditions and continues processing. If an error occurs, the record is skipped and the error is logged. `silent` means the connector ignores errors returned by conditions and continues processing. If an error occurs, the record is skipped and the error is not logged. The current default value is `propagate`, which will change to `ignore` when the `connector.signaltometrics.defaultErrorModeIgnore` feature gate is stable.
$ref: /pkg/ottl.error_mode
logs:
type: array
Expand Down
6 changes: 5 additions & 1 deletion connector/signaltometricsconnector/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ func NewFactory() connector.Factory {
}

func createDefaultConfig() component.Config {
defaultErrorMode := ottl.PropagateError
if metadata.ConnectorSignaltometricsDefaultErrorModeIgnoreFeatureGate.IsEnabled() {
defaultErrorMode = ottl.IgnoreError
}
return &config.Config{
ErrorMode: ottl.PropagateError,
ErrorMode: defaultErrorMode,
}
}

Expand Down
18 changes: 18 additions & 0 deletions connector/signaltometricsconnector/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,29 @@ import (
"go.opentelemetry.io/collector/connector/connectortest"
"go.opentelemetry.io/collector/connector/xconnector"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/featuregate"
"go.opentelemetry.io/collector/pdata/pmetric"

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

func TestFactoryCreateDefaultConfig(t *testing.T) {
t.Cleanup(func() {
_ = featuregate.GlobalRegistry().Set(metadata.ConnectorSignaltometricsDefaultErrorModeIgnoreFeatureGate.ID(), false)
})

factory := NewFactory()
cfg := factory.CreateDefaultConfig()
require.Equal(t, ottl.PropagateError, cfg.(*config.Config).ErrorMode)

require.NoError(t, featuregate.GlobalRegistry().Set(metadata.ConnectorSignaltometricsDefaultErrorModeIgnoreFeatureGate.ID(), true))

cfg = factory.CreateDefaultConfig()
require.Equal(t, ottl.IgnoreError, cfg.(*config.Config).ErrorMode)
}

func TestNewFactoryWithLogs(t *testing.T) {
for _, tc := range []struct {
name string
Expand Down

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

7 changes: 7 additions & 0 deletions connector/signaltometricsconnector/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,10 @@ tests:
description: "Count of datapoint"
sum:
value: Int(1) # Count each data point as 1, can also use the Int converter

feature_gates:
- id: "connector.signaltometrics.defaultErrorModeIgnore"
description: Changes the default error_mode of the signaltometrics connector from propagate to ignore
stage: alpha
from_version: v0.153.0
reference_url: https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/48419
Loading