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
1 change: 1 addition & 0 deletions processor/tailsamplingprocessor/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,5 +169,6 @@ This component has the following feature gates:
| `processor.tailsamplingprocessor.metricstatcountspanssampled` | alpha | When enabled, a new metric stat_count_spans_sampled will be available in the tail sampling processor. Differently from stat_count_traces_sampled, this metric will count the number of spans sampled or not per sampling policy, where the original counts traces. | v0.95.0 | N/A | [Link](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/30482) |
| `processor.tailsamplingprocessor.recordpolicy` | alpha | When enabled, attaches the name of the policy (and if applicable, composite policy) responsible for sampling a trace in the 'tailsampling.policy', 'tailsampling.composite_policy', and `tailsampling.cached_decision` attributes. | v0.120.0 | N/A | [Link](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/35180) |
| `processor.tailsamplingprocessor.tailstorageextension` | alpha | When enabled, allows configuring tail_storage to use a tail storage extension implementation. | v0.150.0 | N/A | [Link](https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/47331) |
| `processor.tailsamplingprocessor.defaultottlconditionerrormodeignore` | alpha | When enabled, OTTL condition policies without an explicit error_mode use ignore instead of propagate. | v0.152.0 | N/A | [Link](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/48420) |

For more information about feature gates, see the [Feature Gates](https://github.com/open-telemetry/opentelemetry-collector/blob/main/featuregate/README.md) documentation.

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

6 changes: 6 additions & 0 deletions processor/tailsamplingprocessor/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ feature_gates:
from_version: v0.150.0
reference_url: https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/47331

- id: "processor.tailsamplingprocessor.defaultottlconditionerrormodeignore"
description: "When enabled, OTTL condition policies without an explicit error_mode use ignore instead of propagate."
stage: alpha
from_version: v0.152.0
reference_url: https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/48420

tests:
config:

Expand Down
13 changes: 12 additions & 1 deletion processor/tailsamplingprocessor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"go.opentelemetry.io/otel/trace"
"go.uber.org/zap"

"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor/cache"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor/internal/idbatcher"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor/internal/metadata"
Expand Down Expand Up @@ -450,7 +451,7 @@ func getSharedPolicyEvaluator(settings component.TelemetrySettings, cfg *sharedP
return sampling.NewBooleanAttributeFilter(settings, bafCfg.Key, bafCfg.Value, bafCfg.InvertMatch), nil
case OTTLCondition:
ottlfCfg := cfg.OTTLConditionCfg
return sampling.NewOTTLConditionFilter(settings, ottlfCfg.SpanConditions, ottlfCfg.SpanEventConditions, ottlfCfg.ErrorMode)
return sampling.NewOTTLConditionFilter(settings, ottlfCfg.SpanConditions, ottlfCfg.SpanEventConditions, defaultOTTLConditionErrorMode(ottlfCfg.ErrorMode))
case TraceFlags:
return sampling.NewTraceFlags(settings), nil
default:
Expand All @@ -468,6 +469,16 @@ func getSharedPolicyEvaluator(settings component.TelemetrySettings, cfg *sharedP
}
}

func defaultOTTLConditionErrorMode(configured ottl.ErrorMode) ottl.ErrorMode {
if configured != "" {
return configured
}
if metadata.ProcessorTailsamplingprocessorDefaultottlconditionerrormodeignoreFeatureGate.IsEnabled() {
return ottl.IgnoreError
}
return ottl.PropagateError
}

type policyDecisionMetrics struct {
tracesSampled int
spansSampled int64
Expand Down
18 changes: 18 additions & 0 deletions processor/tailsamplingprocessor/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"go.uber.org/zap"
"go.uber.org/zap/zaptest/observer"

"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor/internal/idbatcher"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor/internal/metadata"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor/internal/tailstorageextension"
Expand Down Expand Up @@ -71,6 +72,23 @@ func (t *TestPolicyEvaluator) IsStateful() bool {
return t.pe.IsStateful()
}

func TestDefaultOTTLConditionErrorMode(t *testing.T) {
gate := metadata.ProcessorTailsamplingprocessorDefaultottlconditionerrormodeignoreFeatureGate
originalValue := gate.IsEnabled()
require.NoError(t, featuregate.GlobalRegistry().Set(gate.ID(), false))
t.Cleanup(func() {
require.NoError(t, featuregate.GlobalRegistry().Set(gate.ID(), originalValue))
})

require.Equal(t, ottl.PropagateError, defaultOTTLConditionErrorMode(""))
require.Equal(t, ottl.IgnoreError, defaultOTTLConditionErrorMode(ottl.IgnoreError))
require.Equal(t, ottl.PropagateError, defaultOTTLConditionErrorMode(ottl.PropagateError))

require.NoError(t, featuregate.GlobalRegistry().Set(gate.ID(), true))
require.Equal(t, ottl.IgnoreError, defaultOTTLConditionErrorMode(""))
require.Equal(t, ottl.PropagateError, defaultOTTLConditionErrorMode(ottl.PropagateError))
}

// testTSPController is a set of mechanisms to make the TSP do predictable
// things in tests.
type testTSPController struct {
Expand Down
Loading