diff --git a/connector/routingconnector/metrics_test.go b/connector/routingconnector/metrics_test.go index ffd609abc9b1..47e7631f3337 100644 --- a/connector/routingconnector/metrics_test.go +++ b/connector/routingconnector/metrics_test.go @@ -5,17 +5,23 @@ package routingconnector // import "github.com/open-telemetry/opentelemetry-coll import ( "context" + "os" + "path/filepath" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/component/componenttest" + "go.opentelemetry.io/collector/confmap/confmaptest" "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/pdata/pmetric" "go.opentelemetry.io/collector/pipeline" + + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden" ) func TestMetricsRegisterConsumersForValidRoute(t *testing.T) { @@ -495,3 +501,64 @@ func TestMetricsConnectorCapabilities(t *testing.T) { require.NoError(t, err) assert.False(t, conn.Capabilities().MutatesData) } + +func TestMetricsConnectorDetailed(t *testing.T) { + testCases := []string{ + filepath.Join("testdata", "metrics", "resource_context", "all_match_first_only"), + filepath.Join("testdata", "metrics", "resource_context", "all_match_last_only"), + filepath.Join("testdata", "metrics", "resource_context", "all_match_once"), + filepath.Join("testdata", "metrics", "resource_context", "each_matches_one"), + filepath.Join("testdata", "metrics", "resource_context", "match_none_with_default"), + filepath.Join("testdata", "metrics", "resource_context", "match_none_without_default"), + } + + for _, tt := range testCases { + t.Run(tt, func(t *testing.T) { + + cm, err := confmaptest.LoadConf(filepath.Join(tt, "config.yaml")) + require.NoError(t, err) + factory := NewFactory() + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("routing") + require.NoError(t, err) + require.NoError(t, sub.Unmarshal(cfg)) + require.NoError(t, component.ValidateConfig(cfg)) + + var sinkDefault, sink0, sink1 consumertest.MetricsSink + router := connector.NewMetricsRouter(map[pipeline.ID]consumer.Metrics{ + pipeline.NewIDWithName(pipeline.SignalMetrics, "default"): &sinkDefault, + pipeline.NewIDWithName(pipeline.SignalMetrics, "0"): &sink0, + pipeline.NewIDWithName(pipeline.SignalMetrics, "1"): &sink1, + }) + + conn, err := factory.CreateMetricsToMetrics( + context.Background(), + connectortest.NewNopSettings(), + cfg, + router.(consumer.Metrics), + ) + require.NoError(t, err) + + input, readErr := golden.ReadMetrics(filepath.Join("testdata", "metrics", "input.yaml")) + require.NoError(t, readErr) + + require.NoError(t, conn.ConsumeMetrics(context.Background(), input)) + + assertExpected := func(actual []pmetric.Metrics, filePath string) { + expected, err := golden.ReadMetrics(filePath) + switch { + case err == nil: + require.Len(t, actual, 1) + assert.Equal(t, expected, actual[0]) + case os.IsNotExist(err): + assert.Empty(t, actual) + default: + t.Fatalf("Error reading %s: %v", filePath, err) + } + } + assertExpected(sink0.AllMetrics(), filepath.Join(tt, "sink_0.yaml")) + assertExpected(sink1.AllMetrics(), filepath.Join(tt, "sink_1.yaml")) + assertExpected(sinkDefault.AllMetrics(), filepath.Join(tt, "sink_default.yaml")) + }) + } +} diff --git a/connector/routingconnector/testdata/metrics/input.yaml b/connector/routingconnector/testdata/metrics/input.yaml new file mode 100644 index 000000000000..68145249e0bd --- /dev/null +++ b/connector/routingconnector/testdata/metrics/input.yaml @@ -0,0 +1,389 @@ +resourceMetrics: + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceA + - key: resourceNameAgain + value: + stringValue: resourceA + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeMetrics: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + metrics: + - name: sumMonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "101" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "102" + - name: sumNonmonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "102" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "101" + - name: sumMonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "1" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "2" + - name: sumNonmonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "2" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "1" + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + metrics: + - name: sumMonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "101" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "102" + - name: sumNonmonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "102" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "101" + - name: sumMonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "1" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "2" + - name: sumNonmonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "2" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "1" + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceB + - key: resourceNameAgain + value: + stringValue: resourceB + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeMetrics: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + metrics: + - name: sumMonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "101" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "102" + - name: sumNonmonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "102" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "101" + - name: sumMonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "1" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "2" + - name: sumNonmonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "2" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "1" + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + metrics: + - name: sumMonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "101" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "102" + - name: sumNonmonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "102" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "101" + - name: sumMonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "1" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "2" + - name: sumNonmonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "2" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "1" diff --git a/connector/routingconnector/testdata/metrics/resource_context/all_match_first_only/config.yaml b/connector/routingconnector/testdata/metrics/resource_context/all_match_first_only/config.yaml new file mode 100644 index 000000000000..069af45fa6cc --- /dev/null +++ b/connector/routingconnector/testdata/metrics/resource_context/all_match_first_only/config.yaml @@ -0,0 +1,10 @@ +routing: + default_pipelines: + - metrics/default + table: + - condition: attributes["resourceName"] != nil + pipelines: + - metrics/0 + - condition: attributes["resourceName"] == "resourceY" + pipelines: + - metrics/1 diff --git a/connector/routingconnector/testdata/metrics/resource_context/all_match_first_only/sink_0.yaml b/connector/routingconnector/testdata/metrics/resource_context/all_match_first_only/sink_0.yaml new file mode 100644 index 000000000000..68145249e0bd --- /dev/null +++ b/connector/routingconnector/testdata/metrics/resource_context/all_match_first_only/sink_0.yaml @@ -0,0 +1,389 @@ +resourceMetrics: + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceA + - key: resourceNameAgain + value: + stringValue: resourceA + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeMetrics: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + metrics: + - name: sumMonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "101" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "102" + - name: sumNonmonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "102" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "101" + - name: sumMonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "1" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "2" + - name: sumNonmonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "2" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "1" + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + metrics: + - name: sumMonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "101" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "102" + - name: sumNonmonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "102" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "101" + - name: sumMonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "1" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "2" + - name: sumNonmonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "2" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "1" + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceB + - key: resourceNameAgain + value: + stringValue: resourceB + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeMetrics: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + metrics: + - name: sumMonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "101" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "102" + - name: sumNonmonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "102" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "101" + - name: sumMonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "1" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "2" + - name: sumNonmonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "2" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "1" + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + metrics: + - name: sumMonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "101" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "102" + - name: sumNonmonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "102" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "101" + - name: sumMonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "1" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "2" + - name: sumNonmonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "2" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "1" diff --git a/connector/routingconnector/testdata/metrics/resource_context/all_match_last_only/config.yaml b/connector/routingconnector/testdata/metrics/resource_context/all_match_last_only/config.yaml new file mode 100644 index 000000000000..8fd8b583557e --- /dev/null +++ b/connector/routingconnector/testdata/metrics/resource_context/all_match_last_only/config.yaml @@ -0,0 +1,10 @@ +routing: + default_pipelines: + - metrics/default + table: + - condition: attributes["resourceName"] == "resourceX" + pipelines: + - metrics/0 + - condition: attributes["resourceName"] != nil + pipelines: + - metrics/1 diff --git a/connector/routingconnector/testdata/metrics/resource_context/all_match_last_only/sink_1.yaml b/connector/routingconnector/testdata/metrics/resource_context/all_match_last_only/sink_1.yaml new file mode 100644 index 000000000000..68145249e0bd --- /dev/null +++ b/connector/routingconnector/testdata/metrics/resource_context/all_match_last_only/sink_1.yaml @@ -0,0 +1,389 @@ +resourceMetrics: + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceA + - key: resourceNameAgain + value: + stringValue: resourceA + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeMetrics: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + metrics: + - name: sumMonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "101" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "102" + - name: sumNonmonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "102" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "101" + - name: sumMonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "1" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "2" + - name: sumNonmonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "2" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "1" + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + metrics: + - name: sumMonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "101" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "102" + - name: sumNonmonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "102" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "101" + - name: sumMonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "1" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "2" + - name: sumNonmonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "2" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "1" + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceB + - key: resourceNameAgain + value: + stringValue: resourceB + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeMetrics: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + metrics: + - name: sumMonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "101" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "102" + - name: sumNonmonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "102" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "101" + - name: sumMonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "1" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "2" + - name: sumNonmonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "2" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "1" + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + metrics: + - name: sumMonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "101" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "102" + - name: sumNonmonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "102" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "101" + - name: sumMonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "1" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "2" + - name: sumNonmonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "2" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "1" diff --git a/connector/routingconnector/testdata/metrics/resource_context/all_match_once/config.yaml b/connector/routingconnector/testdata/metrics/resource_context/all_match_once/config.yaml new file mode 100644 index 000000000000..0d843a7201ae --- /dev/null +++ b/connector/routingconnector/testdata/metrics/resource_context/all_match_once/config.yaml @@ -0,0 +1,11 @@ +routing: + match_once: true + default_pipelines: + - metrics/default + table: + - condition: attributes["resourceName"] != nil + pipelines: + - metrics/0 + - condition: attributes["resourceName"] == "resourceA" or attributes["resourceName"] == "resourceB" + pipelines: + - metrics/1 diff --git a/connector/routingconnector/testdata/metrics/resource_context/all_match_once/sink_0.yaml b/connector/routingconnector/testdata/metrics/resource_context/all_match_once/sink_0.yaml new file mode 100644 index 000000000000..68145249e0bd --- /dev/null +++ b/connector/routingconnector/testdata/metrics/resource_context/all_match_once/sink_0.yaml @@ -0,0 +1,389 @@ +resourceMetrics: + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceA + - key: resourceNameAgain + value: + stringValue: resourceA + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeMetrics: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + metrics: + - name: sumMonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "101" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "102" + - name: sumNonmonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "102" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "101" + - name: sumMonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "1" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "2" + - name: sumNonmonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "2" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "1" + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + metrics: + - name: sumMonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "101" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "102" + - name: sumNonmonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "102" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "101" + - name: sumMonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "1" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "2" + - name: sumNonmonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "2" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "1" + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceB + - key: resourceNameAgain + value: + stringValue: resourceB + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeMetrics: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + metrics: + - name: sumMonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "101" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "102" + - name: sumNonmonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "102" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "101" + - name: sumMonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "1" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "2" + - name: sumNonmonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "2" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "1" + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + metrics: + - name: sumMonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "101" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "102" + - name: sumNonmonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "102" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "101" + - name: sumMonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "1" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "2" + - name: sumNonmonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "2" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "1" diff --git a/connector/routingconnector/testdata/metrics/resource_context/each_matches_one/config.yaml b/connector/routingconnector/testdata/metrics/resource_context/each_matches_one/config.yaml new file mode 100644 index 000000000000..9c570e759a42 --- /dev/null +++ b/connector/routingconnector/testdata/metrics/resource_context/each_matches_one/config.yaml @@ -0,0 +1,10 @@ +routing: + default_pipelines: + - metrics/default + table: + - condition: attributes["resourceName"] == "resourceB" + pipelines: + - metrics/0 + - condition: attributes["resourceName"] == "resourceA" + pipelines: + - metrics/1 diff --git a/connector/routingconnector/testdata/metrics/resource_context/each_matches_one/sink_0.yaml b/connector/routingconnector/testdata/metrics/resource_context/each_matches_one/sink_0.yaml new file mode 100644 index 000000000000..b83427450811 --- /dev/null +++ b/connector/routingconnector/testdata/metrics/resource_context/each_matches_one/sink_0.yaml @@ -0,0 +1,195 @@ +resourceMetrics: + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceB + - key: resourceNameAgain + value: + stringValue: resourceB + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeMetrics: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + metrics: + - name: sumMonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "101" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "102" + - name: sumNonmonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "102" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "101" + - name: sumMonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "1" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "2" + - name: sumNonmonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "2" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "1" + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + metrics: + - name: sumMonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "101" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "102" + - name: sumNonmonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "102" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "101" + - name: sumMonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "1" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "2" + - name: sumNonmonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "2" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "1" diff --git a/connector/routingconnector/testdata/metrics/resource_context/each_matches_one/sink_1.yaml b/connector/routingconnector/testdata/metrics/resource_context/each_matches_one/sink_1.yaml new file mode 100644 index 000000000000..705311b4fd43 --- /dev/null +++ b/connector/routingconnector/testdata/metrics/resource_context/each_matches_one/sink_1.yaml @@ -0,0 +1,195 @@ +resourceMetrics: + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceA + - key: resourceNameAgain + value: + stringValue: resourceA + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeMetrics: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + metrics: + - name: sumMonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "101" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "102" + - name: sumNonmonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "102" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "101" + - name: sumMonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "1" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "2" + - name: sumNonmonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "2" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "1" + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + metrics: + - name: sumMonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "101" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "102" + - name: sumNonmonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "102" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "101" + - name: sumMonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "1" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "2" + - name: sumNonmonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "2" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "1" diff --git a/connector/routingconnector/testdata/metrics/resource_context/match_none_with_default/config.yaml b/connector/routingconnector/testdata/metrics/resource_context/match_none_with_default/config.yaml new file mode 100644 index 000000000000..33b8e511ea80 --- /dev/null +++ b/connector/routingconnector/testdata/metrics/resource_context/match_none_with_default/config.yaml @@ -0,0 +1,10 @@ +routing: + default_pipelines: + - metrics/default + table: + - condition: attributes["resourceName"] == "resourceX" + pipelines: + - metrics/0 + - condition: attributes["resourceName"] == "resourceY" + pipelines: + - metrics/1 diff --git a/connector/routingconnector/testdata/metrics/resource_context/match_none_with_default/sink_default.yaml b/connector/routingconnector/testdata/metrics/resource_context/match_none_with_default/sink_default.yaml new file mode 100644 index 000000000000..68145249e0bd --- /dev/null +++ b/connector/routingconnector/testdata/metrics/resource_context/match_none_with_default/sink_default.yaml @@ -0,0 +1,389 @@ +resourceMetrics: + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceA + - key: resourceNameAgain + value: + stringValue: resourceA + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeMetrics: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + metrics: + - name: sumMonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "101" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "102" + - name: sumNonmonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "102" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "101" + - name: sumMonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "1" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "2" + - name: sumNonmonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "2" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "1" + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + metrics: + - name: sumMonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "101" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "102" + - name: sumNonmonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "102" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "101" + - name: sumMonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "1" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "2" + - name: sumNonmonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "2" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "1" + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceB + - key: resourceNameAgain + value: + stringValue: resourceB + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeMetrics: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + metrics: + - name: sumMonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "101" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "102" + - name: sumNonmonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "102" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "101" + - name: sumMonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "1" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "2" + - name: sumNonmonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "2" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "1" + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + metrics: + - name: sumMonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "101" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "102" + - name: sumNonmonotonicCumulative + sum: + aggregationTemporality: 2 # AGGREGATION_TEMPORALITY_CUMULATIVE + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "102" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "101" + - name: sumMonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: true + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "1" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "2" + - name: sumNonmonotonicDelta + sum: + aggregationTemporality: 1 # AGGREGATION_TEMPORALITY_DELTA + isMonotonic: false + dataPoints: + - attributes: + - key: dataPointName + value: + stringValue: dataPointA + - key: dataPointNameAgain + value: + stringValue: dataPointA + asInt: "2" + - attributes: + - key: dataPointName + value: + stringValue: dataPointB + - key: dataPointNameAgain + value: + stringValue: dataPointB + asInt: "1" diff --git a/connector/routingconnector/testdata/metrics/resource_context/match_none_without_default/config.yaml b/connector/routingconnector/testdata/metrics/resource_context/match_none_without_default/config.yaml new file mode 100644 index 000000000000..fabaa8a1b5c8 --- /dev/null +++ b/connector/routingconnector/testdata/metrics/resource_context/match_none_without_default/config.yaml @@ -0,0 +1,10 @@ +routing: + match_once: true + # no default pipelines + table: + - condition: attributes["resourceName"] == "resourceX" + pipelines: + - metrics/0 + - condition: attributes["resourceName"] == "resourceY" + pipelines: + - metrics/1 diff --git a/connector/routingconnector/testdata/traces/resource_context/all_match_first_only/config.yaml b/connector/routingconnector/testdata/traces/resource_context/all_match_first_only/config.yaml new file mode 100644 index 000000000000..beded866152d --- /dev/null +++ b/connector/routingconnector/testdata/traces/resource_context/all_match_first_only/config.yaml @@ -0,0 +1,10 @@ +routing: + default_pipelines: + - traces/default + table: + - condition: attributes["resourceName"] != nil + pipelines: + - traces/0 + - condition: attributes["resourceName"] == "resourceY" + pipelines: + - traces/1 diff --git a/connector/routingconnector/testdata/traces/resource_context/all_match_first_only/input.yaml b/connector/routingconnector/testdata/traces/resource_context/all_match_first_only/input.yaml new file mode 100644 index 000000000000..914758ed6510 --- /dev/null +++ b/connector/routingconnector/testdata/traces/resource_context/all_match_first_only/input.yaml @@ -0,0 +1,117 @@ +resourceSpans: + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceA + - key: resourceNameAgain + value: + stringValue: resourceA + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeSpans: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceB + - key: resourceNameAgain + value: + stringValue: resourceB + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeSpans: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB diff --git a/connector/routingconnector/testdata/traces/resource_context/all_match_first_only/sink_0.yaml b/connector/routingconnector/testdata/traces/resource_context/all_match_first_only/sink_0.yaml new file mode 100644 index 000000000000..914758ed6510 --- /dev/null +++ b/connector/routingconnector/testdata/traces/resource_context/all_match_first_only/sink_0.yaml @@ -0,0 +1,117 @@ +resourceSpans: + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceA + - key: resourceNameAgain + value: + stringValue: resourceA + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeSpans: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceB + - key: resourceNameAgain + value: + stringValue: resourceB + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeSpans: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB diff --git a/connector/routingconnector/testdata/traces/resource_context/all_match_last_only/config.yaml b/connector/routingconnector/testdata/traces/resource_context/all_match_last_only/config.yaml new file mode 100644 index 000000000000..a8e0472a0dea --- /dev/null +++ b/connector/routingconnector/testdata/traces/resource_context/all_match_last_only/config.yaml @@ -0,0 +1,10 @@ +routing: + default_pipelines: + - traces/default + table: + - condition: attributes["resourceName"] == "resourceX" + pipelines: + - traces/0 + - condition: attributes["resourceName"] != nil + pipelines: + - traces/1 diff --git a/connector/routingconnector/testdata/traces/resource_context/all_match_last_only/input.yaml b/connector/routingconnector/testdata/traces/resource_context/all_match_last_only/input.yaml new file mode 100644 index 000000000000..914758ed6510 --- /dev/null +++ b/connector/routingconnector/testdata/traces/resource_context/all_match_last_only/input.yaml @@ -0,0 +1,117 @@ +resourceSpans: + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceA + - key: resourceNameAgain + value: + stringValue: resourceA + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeSpans: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceB + - key: resourceNameAgain + value: + stringValue: resourceB + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeSpans: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB diff --git a/connector/routingconnector/testdata/traces/resource_context/all_match_last_only/sink_1.yaml b/connector/routingconnector/testdata/traces/resource_context/all_match_last_only/sink_1.yaml new file mode 100644 index 000000000000..914758ed6510 --- /dev/null +++ b/connector/routingconnector/testdata/traces/resource_context/all_match_last_only/sink_1.yaml @@ -0,0 +1,117 @@ +resourceSpans: + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceA + - key: resourceNameAgain + value: + stringValue: resourceA + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeSpans: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceB + - key: resourceNameAgain + value: + stringValue: resourceB + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeSpans: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB diff --git a/connector/routingconnector/testdata/traces/resource_context/all_match_once/config.yaml b/connector/routingconnector/testdata/traces/resource_context/all_match_once/config.yaml new file mode 100644 index 000000000000..412189b1ce3c --- /dev/null +++ b/connector/routingconnector/testdata/traces/resource_context/all_match_once/config.yaml @@ -0,0 +1,11 @@ +routing: + match_once: true + default_pipelines: + - traces/default + table: + - condition: attributes["resourceName"] != nil + pipelines: + - traces/0 + - condition: attributes["resourceName"] == "resourceA" or attributes["resourceName"] == "resourceB" + pipelines: + - traces/1 diff --git a/connector/routingconnector/testdata/traces/resource_context/all_match_once/input.yaml b/connector/routingconnector/testdata/traces/resource_context/all_match_once/input.yaml new file mode 100644 index 000000000000..914758ed6510 --- /dev/null +++ b/connector/routingconnector/testdata/traces/resource_context/all_match_once/input.yaml @@ -0,0 +1,117 @@ +resourceSpans: + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceA + - key: resourceNameAgain + value: + stringValue: resourceA + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeSpans: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceB + - key: resourceNameAgain + value: + stringValue: resourceB + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeSpans: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB diff --git a/connector/routingconnector/testdata/traces/resource_context/all_match_once/sink_0.yaml b/connector/routingconnector/testdata/traces/resource_context/all_match_once/sink_0.yaml new file mode 100644 index 000000000000..914758ed6510 --- /dev/null +++ b/connector/routingconnector/testdata/traces/resource_context/all_match_once/sink_0.yaml @@ -0,0 +1,117 @@ +resourceSpans: + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceA + - key: resourceNameAgain + value: + stringValue: resourceA + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeSpans: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceB + - key: resourceNameAgain + value: + stringValue: resourceB + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeSpans: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB diff --git a/connector/routingconnector/testdata/traces/resource_context/each_matches_one/config.yaml b/connector/routingconnector/testdata/traces/resource_context/each_matches_one/config.yaml new file mode 100644 index 000000000000..87d8044ed135 --- /dev/null +++ b/connector/routingconnector/testdata/traces/resource_context/each_matches_one/config.yaml @@ -0,0 +1,10 @@ +routing: + default_pipelines: + - traces/default + table: + - condition: attributes["resourceName"] == "resourceB" + pipelines: + - traces/0 + - condition: attributes["resourceName"] == "resourceA" + pipelines: + - traces/1 diff --git a/connector/routingconnector/testdata/traces/resource_context/each_matches_one/input.yaml b/connector/routingconnector/testdata/traces/resource_context/each_matches_one/input.yaml new file mode 100644 index 000000000000..914758ed6510 --- /dev/null +++ b/connector/routingconnector/testdata/traces/resource_context/each_matches_one/input.yaml @@ -0,0 +1,117 @@ +resourceSpans: + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceA + - key: resourceNameAgain + value: + stringValue: resourceA + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeSpans: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceB + - key: resourceNameAgain + value: + stringValue: resourceB + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeSpans: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB diff --git a/connector/routingconnector/testdata/traces/resource_context/each_matches_one/sink_0.yaml b/connector/routingconnector/testdata/traces/resource_context/each_matches_one/sink_0.yaml new file mode 100644 index 000000000000..638861efcf92 --- /dev/null +++ b/connector/routingconnector/testdata/traces/resource_context/each_matches_one/sink_0.yaml @@ -0,0 +1,59 @@ +resourceSpans: + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceB + - key: resourceNameAgain + value: + stringValue: resourceB + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeSpans: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB diff --git a/connector/routingconnector/testdata/traces/resource_context/each_matches_one/sink_1.yaml b/connector/routingconnector/testdata/traces/resource_context/each_matches_one/sink_1.yaml new file mode 100644 index 000000000000..5c862eb1178f --- /dev/null +++ b/connector/routingconnector/testdata/traces/resource_context/each_matches_one/sink_1.yaml @@ -0,0 +1,59 @@ +resourceSpans: + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceA + - key: resourceNameAgain + value: + stringValue: resourceA + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeSpans: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB diff --git a/connector/routingconnector/testdata/traces/resource_context/match_none_with_default/config.yaml b/connector/routingconnector/testdata/traces/resource_context/match_none_with_default/config.yaml new file mode 100644 index 000000000000..f8f8b30a5aec --- /dev/null +++ b/connector/routingconnector/testdata/traces/resource_context/match_none_with_default/config.yaml @@ -0,0 +1,10 @@ +routing: + default_pipelines: + - traces/default + table: + - condition: attributes["resourceName"] == "resourceX" + pipelines: + - traces/0 + - condition: attributes["resourceName"] == "resourceY" + pipelines: + - traces/1 diff --git a/connector/routingconnector/testdata/traces/resource_context/match_none_with_default/input.yaml b/connector/routingconnector/testdata/traces/resource_context/match_none_with_default/input.yaml new file mode 100644 index 000000000000..914758ed6510 --- /dev/null +++ b/connector/routingconnector/testdata/traces/resource_context/match_none_with_default/input.yaml @@ -0,0 +1,117 @@ +resourceSpans: + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceA + - key: resourceNameAgain + value: + stringValue: resourceA + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeSpans: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceB + - key: resourceNameAgain + value: + stringValue: resourceB + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeSpans: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB diff --git a/connector/routingconnector/testdata/traces/resource_context/match_none_with_default/sink_default.yaml b/connector/routingconnector/testdata/traces/resource_context/match_none_with_default/sink_default.yaml new file mode 100644 index 000000000000..914758ed6510 --- /dev/null +++ b/connector/routingconnector/testdata/traces/resource_context/match_none_with_default/sink_default.yaml @@ -0,0 +1,117 @@ +resourceSpans: + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceA + - key: resourceNameAgain + value: + stringValue: resourceA + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeSpans: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceB + - key: resourceNameAgain + value: + stringValue: resourceB + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeSpans: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB diff --git a/connector/routingconnector/testdata/traces/resource_context/match_none_without_default/config.yaml b/connector/routingconnector/testdata/traces/resource_context/match_none_without_default/config.yaml new file mode 100644 index 000000000000..919ff44ef1cf --- /dev/null +++ b/connector/routingconnector/testdata/traces/resource_context/match_none_without_default/config.yaml @@ -0,0 +1,10 @@ +routing: + match_once: true + # no default pipelines + table: + - condition: attributes["resourceName"] == "resourceX" + pipelines: + - traces/0 + - condition: attributes["resourceName"] == "resourceY" + pipelines: + - traces/1 diff --git a/connector/routingconnector/testdata/traces/resource_context/match_none_without_default/input.yaml b/connector/routingconnector/testdata/traces/resource_context/match_none_without_default/input.yaml new file mode 100644 index 000000000000..914758ed6510 --- /dev/null +++ b/connector/routingconnector/testdata/traces/resource_context/match_none_without_default/input.yaml @@ -0,0 +1,117 @@ +resourceSpans: + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceA + - key: resourceNameAgain + value: + stringValue: resourceA + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeSpans: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - resource: + attributes: + - key: resourceName + value: + stringValue: resourceB + - key: resourceNameAgain + value: + stringValue: resourceB + schemaUrl: https://opentelemetry.io/schemas/1.6.1 + scopeSpans: + - attributes: + - key: scopeName + value: + stringValue: scopeA + - key: scopeNameAgain + value: + stringValue: scopeA + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB + - attributes: + - key: scopeName + value: + stringValue: scopeB + - key: scopeNameAgain + value: + stringValue: scopeB + spans: + - attributes: + - key: spanName + value: + stringValue: spanA + - key: spanNameAgain + value: + stringValue: spanA + name: spanA + - attributes: + - key: spanName + value: + stringValue: spanB + - key: spanNameAgain + value: + stringValue: spanB + name: spanB diff --git a/connector/routingconnector/traces_test.go b/connector/routingconnector/traces_test.go index fb42892ae00e..d479334e70a8 100644 --- a/connector/routingconnector/traces_test.go +++ b/connector/routingconnector/traces_test.go @@ -5,17 +5,24 @@ package routingconnector // import "github.com/open-telemetry/opentelemetry-coll import ( "context" + "os" + "path/filepath" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/component/componenttest" + "go.opentelemetry.io/collector/confmap/confmaptest" "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/pdata/ptrace" "go.opentelemetry.io/collector/pipeline" + + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest/ptracetest" ) func TestTracesRegisterConsumersForValidRoute(t *testing.T) { @@ -419,3 +426,95 @@ func TestTraceConnectorCapabilities(t *testing.T) { require.NoError(t, err) assert.False(t, conn.Capabilities().MutatesData) } + +func TestTracesConnectorDetailed(t *testing.T) { + testCases := []string{ + filepath.Join("testdata", "traces", "resource_context", "all_match_first_only"), + filepath.Join("testdata", "traces", "resource_context", "all_match_last_only"), + filepath.Join("testdata", "traces", "resource_context", "all_match_once"), + filepath.Join("testdata", "traces", "resource_context", "each_matches_one"), + filepath.Join("testdata", "traces", "resource_context", "match_none_with_default"), + filepath.Join("testdata", "traces", "resource_context", "match_none_without_default"), + } + + for _, tt := range testCases { + t.Run(tt, func(t *testing.T) { + + cm, err := confmaptest.LoadConf(filepath.Join(tt, "config.yaml")) + require.NoError(t, err) + factory := NewFactory() + cfg := factory.CreateDefaultConfig() + sub, err := cm.Sub("routing") + require.NoError(t, err) + require.NoError(t, sub.Unmarshal(cfg)) + require.NoError(t, component.ValidateConfig(cfg)) + + var sinkDefault, sink0, sink1 consumertest.TracesSink + router := connector.NewTracesRouter(map[pipeline.ID]consumer.Traces{ + pipeline.NewIDWithName(pipeline.SignalTraces, "default"): &sinkDefault, + pipeline.NewIDWithName(pipeline.SignalTraces, "0"): &sink0, + pipeline.NewIDWithName(pipeline.SignalTraces, "1"): &sink1, + }) + + conn, err := factory.CreateTracesToTraces( + context.Background(), + connectortest.NewNopSettings(), + cfg, + router.(consumer.Traces), + ) + require.NoError(t, err) + + var expected0, expected1, expectedDefault *ptrace.Traces + if expected, readErr := golden.ReadTraces(filepath.Join(tt, "sink_0.yaml")); readErr == nil { + expected0 = &expected + } else if !os.IsNotExist(readErr) { + t.Fatalf("Error reading sink_0.yaml: %v", readErr) + } + + if expected, readErr := golden.ReadTraces(filepath.Join(tt, "sink_1.yaml")); readErr == nil { + expected1 = &expected + } else if !os.IsNotExist(readErr) { + t.Fatalf("Error reading sink_1.yaml: %v", readErr) + } + + if expected, readErr := golden.ReadTraces(filepath.Join(tt, "sink_default.yaml")); readErr == nil { + expectedDefault = &expected + } else if !os.IsNotExist(readErr) { + t.Fatalf("Error reading sink_default.yaml: %v", readErr) + } + + ctx := context.Background() + if ctxFromFile, readErr := createContextFromFile(t, filepath.Join(tt, "request.yaml")); readErr == nil { + ctx = ctxFromFile + } else if !os.IsNotExist(readErr) { + t.Fatalf("Error reading request.yaml: %v", readErr) + } + + input, readErr := golden.ReadTraces(filepath.Join(tt, "input.yaml")) + require.NoError(t, readErr) + + require.NoError(t, conn.ConsumeTraces(ctx, input)) + + if expected0 == nil { + assert.Empty(t, sink0.AllTraces(), "sink0 should be empty") + } else { + require.Len(t, sink0.AllTraces(), 1, "sink0 should have one ptrace.Traces") + assert.NoError(t, ptracetest.CompareTraces(*expected0, sink0.AllTraces()[0]), "sink0 has unexpected result") + } + + if expected1 == nil { + assert.Empty(t, sink1.AllTraces(), "sink1 should be empty") + } else { + require.Len(t, sink1.AllTraces(), 1, "sink1 should have one ptrace.Traces") + assert.NoError(t, ptracetest.CompareTraces(*expected1, sink1.AllTraces()[0]), "sink1 has unexpected result") + } + + if expectedDefault == nil { + assert.Empty(t, sinkDefault.AllTraces(), "sinkDefault should be empty") + } else { + require.Len(t, sinkDefault.AllTraces(), 1, "sinkDefault should have one ptrace.Traces") + assert.NoError(t, ptracetest.CompareTraces(*expectedDefault, sinkDefault.AllTraces()[0]), "sinkDefault has unexpected result") + } + }) + } +}