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