From 17f945beb33f5165f78a7966cb4c08af056063a6 Mon Sep 17 00:00:00 2001 From: jeremyh Date: Thu, 26 Sep 2024 09:27:11 -0400 Subject: [PATCH 1/3] add log and metric tests --- connector/sumconnector/connector_test.go | 356 +++++++++++++++++++++++ 1 file changed, 356 insertions(+) diff --git a/connector/sumconnector/connector_test.go b/connector/sumconnector/connector_test.go index 4c2d4438c692..7f1e2ecf190d 100644 --- a/connector/sumconnector/connector_test.go +++ b/connector/sumconnector/connector_test.go @@ -269,3 +269,359 @@ func TestTracesToMetrics(t *testing.T) { }) } } + +// The test input file has a repetitive structure: +// - There are four resources, each with six metrics, each with four data point. +// - The four resources have the following sets of attributes: +// - resource.required: foo, resource.optional: bar +// - resource.required: foo, resource.optional: notbar +// - resource.required: notfoo +// - (no attributes) +// +// - The size metrics have the following sets of types: +// - int gauge, double gauge, int sum, double sum, historgram, summary +// +// - The four data points on each metric have the following sets of attributes: +// - datapoint.required: foo, datapoint.optional: bar +// - datapoint.required: foo, datapoint.optional: notbar +// - datapoint.required: notfoo +// - (no attributes) +func TestMetricsToMetrics(t *testing.T) { + testCases := []struct { + name string + cfg *Config + }{ + { + name: "one_attribute", + cfg: &Config{ + DataPoints: map[string]MetricInfo{ + "datapoint.sum.by_attr": { + Description: "Data point sum by attribute", + SourceAttribute: "beep", + Attributes: []AttributeConfig{ + { + Key: "datapoint.required", + }, + }, + }, + }, + }, + }, + { + name: "one_condition", + cfg: &Config{ + DataPoints: map[string]MetricInfo{ + "datapoint.sum.if": { + Description: "Data point sum if ...", + SourceAttribute: "beep", + Conditions: []string{ + `resource.attributes["resource.optional"] != nil`, + }, + }, + }, + }, + }, + { + name: "multiple_conditions", + cfg: &Config{ + DataPoints: map[string]MetricInfo{ + "datapoint.sum.if": { + Description: "Data point sum if ...", + SourceAttribute: "beep", + Conditions: []string{ + `resource.attributes["resource.optional"] != nil`, + `attributes["datapoint.optional"] != nil`, + }, + }, + }, + }, + }, + { + name: "multiple_metrics", + cfg: &Config{ + DataPoints: map[string]MetricInfo{ + "datapoint.sum.all": { + Description: "All data points sum", + SourceAttribute: "beep", + }, + "datapoint.sum.if": { + Description: "Data point sum if ...", + SourceAttribute: "beep", + Conditions: []string{ + `resource.attributes["resource.optional"] != nil`, + `attributes["datapoint.optional"] != nil`, + }, + }, + }, + }, + }, + { + name: "multiple_attributes", + cfg: &Config{ + DataPoints: map[string]MetricInfo{ + "datapoint.sum.by_attr": { + Description: "Data point sum by attributes", + SourceAttribute: "beep", + Attributes: []AttributeConfig{ + { + Key: "datapoint.required", + }, + { + Key: "datapoint.optional", + }, + }, + }, + }, + }, + }, + { + name: "default_attribute_value", + cfg: &Config{ + DataPoints: map[string]MetricInfo{ + "datapoint.sum.by_attr": { + Description: "Data point sum by attribute with default", + SourceAttribute: "beep", + Attributes: []AttributeConfig{ + { + Key: "datapoint.required", + }, + { + Key: "datapoint.optional", + DefaultValue: "other", + }, + }, + }, + }, + }, + }, + { + name: "condition_and_attribute", + cfg: &Config{ + DataPoints: map[string]MetricInfo{ + "datapoint.sum.if.by_attr": { + Description: "Data point sum by attribute if ...", + SourceAttribute: "beep", + Conditions: []string{ + `resource.attributes["resource.optional"] != nil`, + }, + Attributes: []AttributeConfig{ + { + Key: "datapoint.required", + }, + }, + }, + }, + }, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + require.NoError(t, tc.cfg.Validate()) + factory := NewFactory() + sink := &consumertest.MetricsSink{} + conn, err := factory.CreateMetricsToMetrics(context.Background(), + connectortest.NewNopSettings(), tc.cfg, sink) + require.NoError(t, err) + require.NotNil(t, conn) + assert.False(t, conn.Capabilities().MutatesData) + + require.NoError(t, conn.Start(context.Background(), componenttest.NewNopHost())) + defer func() { + assert.NoError(t, conn.Shutdown(context.Background())) + }() + + testMetrics, err := golden.ReadMetrics(filepath.Join("testdata", "metrics", "input.yaml")) + assert.NoError(t, err) + assert.NoError(t, conn.ConsumeMetrics(context.Background(), testMetrics)) + + allMetrics := sink.AllMetrics() + assert.Len(t, allMetrics, 1) + + expected, err := golden.ReadMetrics(filepath.Join("testdata", "metrics", tc.name+".yaml")) + assert.NoError(t, err) + assert.NoError(t, pmetrictest.CompareMetrics(expected, allMetrics[0], + pmetrictest.IgnoreTimestamp(), + pmetrictest.IgnoreResourceMetricsOrder(), + pmetrictest.IgnoreMetricsOrder(), + pmetrictest.IgnoreMetricFloatPrecision(3), + pmetrictest.IgnoreMetricDataPointsOrder())) + }) + } +} + +// The test input file has a repetitive structure: +// - There are four resources, each with four logs. +// - The four resources have the following sets of attributes: +// - resource.required: foo, resource.optional: bar +// - resource.required: foo, resource.optional: notbar +// - resource.required: notfoo +// - (no attributes) +// +// - The four logs on each resource have the following sets of attributes: +// - log.required: foo, log.optional: bar +// - log.required: foo, log.optional: notbar +// - log.required: notfoo +// - (no attributes) +func TestLogsToMetrics(t *testing.T) { + testCases := []struct { + name string + cfg *Config + }{ + { + name: "one_attribute", + cfg: &Config{ + Logs: map[string]MetricInfo{ + "log.sum.by_attr": { + Description: "Log sum by attribute", + SourceAttribute: "beep", + Attributes: []AttributeConfig{ + { + Key: "log.required", + }, + }, + }, + }, + }, + }, + { + name: "one_condition", + cfg: &Config{ + Logs: map[string]MetricInfo{ + "sum.if": { + Description: "Sum if ...", + SourceAttribute: "beep", + Conditions: []string{ + `resource.attributes["resource.optional"] != nil`, + }, + }, + }, + }, + }, + { + name: "multiple_conditions", + cfg: &Config{ + Logs: map[string]MetricInfo{ + "sum.if": { + Description: "Sum if ...", + SourceAttribute: "beep", + Conditions: []string{ + `resource.attributes["resource.optional"] != nil`, + `attributes["log.optional"] != nil`, + }, + }, + }, + }, + }, + { + name: "multiple_metrics", + cfg: &Config{ + Logs: map[string]MetricInfo{ + "sum.all": { + Description: "All logs Sum", + SourceAttribute: "beep", + }, + "sum.if": { + Description: "Sum if ...", + SourceAttribute: "beep", + Conditions: []string{ + `resource.attributes["resource.optional"] != nil`, + }, + }, + }, + }, + }, + { + name: "multiple_attributes", + cfg: &Config{ + Logs: map[string]MetricInfo{ + "log.sum.by_attr": { + Description: "Log sum by attributes", + SourceAttribute: "beep", + Attributes: []AttributeConfig{ + { + Key: "log.required", + }, + { + Key: "log.optional", + }, + }, + }, + }, + }, + }, + { + name: "default_attribute_value", + cfg: &Config{ + Logs: map[string]MetricInfo{ + "log.sum.by_attr": { + Description: "Log sum by attribute with default", + SourceAttribute: "beep", + Attributes: []AttributeConfig{ + { + Key: "log.required", + }, + { + Key: "log.optional", + DefaultValue: "other", + }, + }, + }, + }, + }, + }, + { + name: "condition_and_attribute", + cfg: &Config{ + Logs: map[string]MetricInfo{ + "log.sum.if.by_attr": { + Description: "Log sum by attribute if ...", + SourceAttribute: "beep", + Conditions: []string{ + `resource.attributes["resource.optional"] != nil`, + }, + Attributes: []AttributeConfig{ + { + Key: "log.required", + }, + }, + }, + }, + }, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + require.NoError(t, tc.cfg.Validate()) + factory := NewFactory() + sink := &consumertest.MetricsSink{} + conn, err := factory.CreateLogsToMetrics(context.Background(), + connectortest.NewNopSettings(), tc.cfg, sink) + require.NoError(t, err) + require.NotNil(t, conn) + assert.False(t, conn.Capabilities().MutatesData) + + require.NoError(t, conn.Start(context.Background(), componenttest.NewNopHost())) + defer func() { + assert.NoError(t, conn.Shutdown(context.Background())) + }() + + testLogs, err := golden.ReadLogs(filepath.Join("testdata", "logs", "input.yaml")) + assert.NoError(t, err) + assert.NoError(t, conn.ConsumeLogs(context.Background(), testLogs)) + + allMetrics := sink.AllMetrics() + assert.Len(t, allMetrics, 1) + + expected, err := golden.ReadMetrics(filepath.Join("testdata", "logs", tc.name+".yaml")) + assert.NoError(t, err) + assert.NoError(t, pmetrictest.CompareMetrics(expected, allMetrics[0], + pmetrictest.IgnoreTimestamp(), + pmetrictest.IgnoreResourceMetricsOrder(), + pmetrictest.IgnoreMetricsOrder(), + pmetrictest.IgnoreMetricFloatPrecision(3), + pmetrictest.IgnoreMetricDataPointsOrder())) + }) + } +} From ed768b7f7bb5517e1c1f0c01e2521a8d72383412 Mon Sep 17 00:00:00 2001 From: jeremyh Date: Thu, 26 Sep 2024 10:03:44 -0400 Subject: [PATCH 2/3] log and metric test data --- .../logs/condition_and_attribute.yaml | 57 + .../logs/default_attribute_value.yaml | 163 ++ .../sumconnector/testdata/logs/input.yaml | 223 +++ .../testdata/logs/multiple_attributes.yaml | 127 ++ .../testdata/logs/multiple_conditions.yaml | 63 + .../testdata/logs/multiple_metrics.yaml | 79 + .../testdata/logs/one_attribute.yaml | 103 ++ .../testdata/logs/one_condition.yaml | 37 + .../metrics/condition_and_attribute.yaml | 57 + .../metrics/default_attribute_value.yaml | 163 ++ .../sumconnector/testdata/metrics/input.yaml | 1390 +++++++++++++++++ .../testdata/metrics/multiple_attributes.yaml | 127 ++ .../testdata/metrics/multiple_conditions.yaml | 63 + .../testdata/metrics/multiple_metrics.yaml | 113 ++ .../testdata/metrics/one_attribute.yaml | 103 ++ .../testdata/metrics/one_condition.yaml | 37 + 16 files changed, 2905 insertions(+) create mode 100644 connector/sumconnector/testdata/logs/condition_and_attribute.yaml create mode 100644 connector/sumconnector/testdata/logs/default_attribute_value.yaml create mode 100644 connector/sumconnector/testdata/logs/input.yaml create mode 100644 connector/sumconnector/testdata/logs/multiple_attributes.yaml create mode 100644 connector/sumconnector/testdata/logs/multiple_conditions.yaml create mode 100644 connector/sumconnector/testdata/logs/multiple_metrics.yaml create mode 100644 connector/sumconnector/testdata/logs/one_attribute.yaml create mode 100644 connector/sumconnector/testdata/logs/one_condition.yaml create mode 100644 connector/sumconnector/testdata/metrics/condition_and_attribute.yaml create mode 100644 connector/sumconnector/testdata/metrics/default_attribute_value.yaml create mode 100644 connector/sumconnector/testdata/metrics/input.yaml create mode 100644 connector/sumconnector/testdata/metrics/multiple_attributes.yaml create mode 100644 connector/sumconnector/testdata/metrics/multiple_conditions.yaml create mode 100644 connector/sumconnector/testdata/metrics/multiple_metrics.yaml create mode 100644 connector/sumconnector/testdata/metrics/one_attribute.yaml create mode 100644 connector/sumconnector/testdata/metrics/one_condition.yaml diff --git a/connector/sumconnector/testdata/logs/condition_and_attribute.yaml b/connector/sumconnector/testdata/logs/condition_and_attribute.yaml new file mode 100644 index 000000000000..ecce8be30eee --- /dev/null +++ b/connector/sumconnector/testdata/logs/condition_and_attribute.yaml @@ -0,0 +1,57 @@ +resourceMetrics: + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: bar + scopeMetrics: + - metrics: + - description: Log sum by attribute if ... + name: log.sum.if.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "2.1" + attributes: + - key: log.required + value: + stringValue: foo + timeUnixNano: "1678390948399018000" + - asDouble: "2" + attributes: + - key: log.required + value: + stringValue: notfoo + timeUnixNano: "1678390948399018000" + isMonotonic: true + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: notbar + scopeMetrics: + - metrics: + - description: Log sum by attribute if ... + name: log.sum.if.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "4.1" + attributes: + - key: log.required + value: + stringValue: foo + timeUnixNano: "1678390948399021000" + - asDouble: "2" + attributes: + - key: log.required + value: + stringValue: notfoo + timeUnixNano: "1678390948399021000" + isMonotonic: true diff --git a/connector/sumconnector/testdata/logs/default_attribute_value.yaml b/connector/sumconnector/testdata/logs/default_attribute_value.yaml new file mode 100644 index 000000000000..e61873e8eed9 --- /dev/null +++ b/connector/sumconnector/testdata/logs/default_attribute_value.yaml @@ -0,0 +1,163 @@ +resourceMetrics: + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: bar + scopeMetrics: + - metrics: + - description: Log sum by attribute with default + name: log.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "4.2" + attributes: + - key: log.required + value: + stringValue: foo + - key: log.optional + value: + stringValue: bar + timeUnixNano: "1678390948398365000" + - asDouble: "0" + attributes: + - key: log.required + value: + stringValue: foo + - key: log.optional + value: + stringValue: notbar + timeUnixNano: "1678390948398365000" + - asDouble: "4" + attributes: + - key: log.required + value: + stringValue: notfoo + - key: log.optional + value: + stringValue: other + timeUnixNano: "1678390948398365000" + isMonotonic: true + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: notbar + scopeMetrics: + - metrics: + - description: Log sum by attribute with default + name: log.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "4.2" + attributes: + - key: log.required + value: + stringValue: foo + - key: log.optional + value: + stringValue: bar + timeUnixNano: "1678390948398368000" + - asDouble: "4" + attributes: + - key: log.required + value: + stringValue: foo + - key: log.optional + value: + stringValue: notbar + timeUnixNano: "1678390948398368000" + - asDouble: "4" + attributes: + - key: log.required + value: + stringValue: notfoo + - key: log.optional + value: + stringValue: other + timeUnixNano: "1678390948398368000" + isMonotonic: true + - resource: + attributes: + - key: resource.required + value: + stringValue: notfoo + scopeMetrics: + - metrics: + - description: Log sum by attribute with default + name: log.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "4.2" + attributes: + - key: log.required + value: + stringValue: foo + - key: log.optional + value: + stringValue: bar + timeUnixNano: "1678390948398371000" + - asDouble: "4" + attributes: + - key: log.required + value: + stringValue: foo + - key: log.optional + value: + stringValue: notbar + timeUnixNano: "1678390948398371000" + - asDouble: "4" + attributes: + - key: log.required + value: + stringValue: notfoo + - key: log.optional + value: + stringValue: other + timeUnixNano: "1678390948398371000" + isMonotonic: true + - resource: {} + scopeMetrics: + - metrics: + - description: Log sum by attribute with default + name: log.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "4.2" + attributes: + - key: log.required + value: + stringValue: foo + - key: log.optional + value: + stringValue: bar + timeUnixNano: "1678390948398373000" + - asDouble: "4" + attributes: + - key: log.required + value: + stringValue: foo + - key: log.optional + value: + stringValue: notbar + timeUnixNano: "1678390948398373000" + - asDouble: "4" + attributes: + - key: log.required + value: + stringValue: notfoo + - key: log.optional + value: + stringValue: other + timeUnixNano: "1678390948398373000" + isMonotonic: true diff --git a/connector/sumconnector/testdata/logs/input.yaml b/connector/sumconnector/testdata/logs/input.yaml new file mode 100644 index 000000000000..05044f21650c --- /dev/null +++ b/connector/sumconnector/testdata/logs/input.yaml @@ -0,0 +1,223 @@ +resourceLogs: + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: bar + scopeLogs: + - logRecords: + - attributes: + - key: log.required + value: + stringValue: foo + - key: log.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + body: + stringValue: This is a log message + spanId: "" + timeUnixNano: "1581452773000000789" + traceId: "" + - attributes: + - key: log.required + value: + stringValue: foo + - key: log.optional + value: + stringValue: notbar + - key: beep + value: + stringValue: "astring" + body: + stringValue: This is a log message + spanId: "" + timeUnixNano: "1581452773000000789" + traceId: "" + - attributes: + - key: log.required + value: + stringValue: notfoo + - key: beep + value: + doubleValue: 2 + body: + stringValue: This is a log message + spanId: "" + timeUnixNano: "1581452773000000789" + traceId: "" + - body: + stringValue: This is a log message + spanId: "" + timeUnixNano: "1581452773000000789" + traceId: "" + scope: {} + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: notbar + scopeLogs: + - logRecords: + - attributes: + - key: log.required + value: + stringValue: foo + - key: log.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + body: + stringValue: This is a log message + spanId: "" + timeUnixNano: "1581452773000000789" + traceId: "" + - attributes: + - key: log.required + value: + stringValue: foo + - key: log.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + body: + stringValue: This is a log message + spanId: "" + timeUnixNano: "1581452773000000789" + traceId: "" + - attributes: + - key: log.required + value: + stringValue: notfoo + - key: beep + value: + doubleValue: 2 + body: + stringValue: This is a log message + spanId: "" + timeUnixNano: "1581452773000000789" + traceId: "" + - body: + stringValue: This is a log message + spanId: "" + timeUnixNano: "1581452773000000789" + traceId: "" + scope: {} + - resource: + attributes: + - key: resource.required + value: + stringValue: notfoo + scopeLogs: + - logRecords: + - attributes: + - key: log.required + value: + stringValue: foo + - key: log.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + body: + stringValue: This is a log message + spanId: "" + timeUnixNano: "1581452773000000789" + traceId: "" + - attributes: + - key: log.required + value: + stringValue: foo + - key: log.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + body: + stringValue: This is a log message + spanId: "" + timeUnixNano: "1581452773000000789" + traceId: "" + - attributes: + - key: log.required + value: + stringValue: notfoo + - key: beep + value: + doubleValue: 2 + body: + stringValue: This is a log message + spanId: "" + timeUnixNano: "1581452773000000789" + traceId: "" + - body: + stringValue: This is a log message + spanId: "" + timeUnixNano: "1581452773000000789" + traceId: "" + scope: {} + - resource: {} + scopeLogs: + - logRecords: + - attributes: + - key: log.required + value: + stringValue: foo + - key: log.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + body: + stringValue: This is a log message + spanId: "" + timeUnixNano: "1581452773000000789" + traceId: "" + - attributes: + - key: log.required + value: + stringValue: foo + - key: log.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + body: + stringValue: This is a log message + spanId: "" + timeUnixNano: "1581452773000000789" + traceId: "" + - attributes: + - key: log.required + value: + stringValue: notfoo + - key: beep + value: + doubleValue: 2 + body: + stringValue: This is a log message + spanId: "" + timeUnixNano: "1581452773000000789" + traceId: "" + - body: + stringValue: This is a log message + spanId: "" + timeUnixNano: "1581452773000000789" + traceId: "" + scope: {} diff --git a/connector/sumconnector/testdata/logs/multiple_attributes.yaml b/connector/sumconnector/testdata/logs/multiple_attributes.yaml new file mode 100644 index 000000000000..175bf2d7f55a --- /dev/null +++ b/connector/sumconnector/testdata/logs/multiple_attributes.yaml @@ -0,0 +1,127 @@ +resourceMetrics: + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: bar + scopeMetrics: + - metrics: + - description: Log sum by attributes + name: log.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "4.2" + attributes: + - key: log.required + value: + stringValue: foo + - key: log.optional + value: + stringValue: bar + timeUnixNano: "1678390948397879000" + - asDouble: "0" + attributes: + - key: log.required + value: + stringValue: foo + - key: log.optional + value: + stringValue: notbar + timeUnixNano: "1678390948397879000" + isMonotonic: true + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: notbar + scopeMetrics: + - metrics: + - description: Log sum by attributes + name: log.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "4.2" + attributes: + - key: log.required + value: + stringValue: foo + - key: log.optional + value: + stringValue: bar + timeUnixNano: "1678390948397882000" + - asDouble: "4" + attributes: + - key: log.required + value: + stringValue: foo + - key: log.optional + value: + stringValue: notbar + timeUnixNano: "1678390948397882000" + isMonotonic: true + - resource: + attributes: + - key: resource.required + value: + stringValue: notfoo + scopeMetrics: + - metrics: + - description: Log sum by attributes + name: log.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "4.2" + attributes: + - key: log.required + value: + stringValue: foo + - key: log.optional + value: + stringValue: bar + timeUnixNano: "1678390948397884000" + - asDouble: "4" + attributes: + - key: log.required + value: + stringValue: foo + - key: log.optional + value: + stringValue: notbar + timeUnixNano: "1678390948397884000" + isMonotonic: true + - resource: {} + scopeMetrics: + - metrics: + - description: Log sum by attributes + name: log.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "4.2" + attributes: + - key: log.required + value: + stringValue: foo + - key: log.optional + value: + stringValue: bar + timeUnixNano: "1678390948397886000" + - asDouble: "4" + attributes: + - key: log.required + value: + stringValue: foo + - key: log.optional + value: + stringValue: notbar + timeUnixNano: "1678390948397886000" + isMonotonic: true diff --git a/connector/sumconnector/testdata/logs/multiple_conditions.yaml b/connector/sumconnector/testdata/logs/multiple_conditions.yaml new file mode 100644 index 000000000000..c4725a2bf72b --- /dev/null +++ b/connector/sumconnector/testdata/logs/multiple_conditions.yaml @@ -0,0 +1,63 @@ +resourceMetrics: + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: bar + scopeMetrics: + - metrics: + - description: Sum if ... + name: sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "4.1" + timeUnixNano: "1678390948395853000" + isMonotonic: true + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: notbar + scopeMetrics: + - metrics: + - description: Sum if ... + name: sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "6.1" + timeUnixNano: "1678390948395856000" + isMonotonic: true + - resource: + attributes: + - key: resource.required + value: + stringValue: notfoo + scopeMetrics: + - metrics: + - description: Sum if ... + name: sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "4.1" + timeUnixNano: "1678390948395858000" + isMonotonic: true + - resource: {} + scopeMetrics: + - metrics: + - description: Sum if ... + name: sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "4.1" + timeUnixNano: "1678390948395859000" + isMonotonic: true diff --git a/connector/sumconnector/testdata/logs/multiple_metrics.yaml b/connector/sumconnector/testdata/logs/multiple_metrics.yaml new file mode 100644 index 000000000000..a4f951a7a452 --- /dev/null +++ b/connector/sumconnector/testdata/logs/multiple_metrics.yaml @@ -0,0 +1,79 @@ +resourceMetrics: + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: bar + scopeMetrics: + - metrics: + - description: All logs Sum + name: sum.all + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "4.1" + timeUnixNano: "1678390948396984000" + isMonotonic: true + - description: Sum if ... + name: sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "4.1" + timeUnixNano: "1678390948396984000" + isMonotonic: true + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: notbar + scopeMetrics: + - metrics: + - description: All logs Sum + name: sum.all + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "6.1" + timeUnixNano: "1678390948396988000" + isMonotonic: true + - description: Sum if ... + name: sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "6.1" + timeUnixNano: "1678390948396988000" + isMonotonic: true + - resource: + attributes: + - key: resource.required + value: + stringValue: notfoo + scopeMetrics: + - metrics: + - description: All logs Sum + name: sum.all + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "6.1" + timeUnixNano: "1678390948396990000" + isMonotonic: true + - resource: {} + scopeMetrics: + - metrics: + - description: All logs Sum + name: sum.all + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "6.1" + timeUnixNano: "1678390948396992000" + isMonotonic: true diff --git a/connector/sumconnector/testdata/logs/one_attribute.yaml b/connector/sumconnector/testdata/logs/one_attribute.yaml new file mode 100644 index 000000000000..40aebf83ebda --- /dev/null +++ b/connector/sumconnector/testdata/logs/one_attribute.yaml @@ -0,0 +1,103 @@ +resourceMetrics: + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: bar + scopeMetrics: + - metrics: + - description: Log sum by attribute + name: log.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "2.1" + attributes: + - key: log.required + value: + stringValue: foo + timeUnixNano: "1678390948397419000" + - asDouble: "2" + attributes: + - key: log.required + value: + stringValue: notfoo + timeUnixNano: "1678390948397419000" + isMonotonic: true + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: notbar + scopeMetrics: + - metrics: + - description: Log sum by attribute + name: log.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "4.1" + attributes: + - key: log.required + value: + stringValue: foo + timeUnixNano: "1678390948397423000" + - asDouble: "2" + attributes: + - key: log.required + value: + stringValue: notfoo + timeUnixNano: "1678390948397423000" + isMonotonic: true + - resource: + attributes: + - key: resource.required + value: + stringValue: notfoo + scopeMetrics: + - metrics: + - description: Log sum by attribute + name: log.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "4.1" + attributes: + - key: log.required + value: + stringValue: foo + timeUnixNano: "1678390948397425000" + - asDouble: "2" + attributes: + - key: log.required + value: + stringValue: notfoo + timeUnixNano: "1678390948397425000" + isMonotonic: true + - resource: {} + scopeMetrics: + - metrics: + - description: Log sum by attribute + name: log.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "4.1" + attributes: + - key: log.required + value: + stringValue: foo + timeUnixNano: "1678390948397427000" + - asDouble: "2" + attributes: + - key: log.required + value: + stringValue: notfoo + timeUnixNano: "1678390948397427000" + isMonotonic: true diff --git a/connector/sumconnector/testdata/logs/one_condition.yaml b/connector/sumconnector/testdata/logs/one_condition.yaml new file mode 100644 index 000000000000..dd26fb4d630f --- /dev/null +++ b/connector/sumconnector/testdata/logs/one_condition.yaml @@ -0,0 +1,37 @@ +resourceMetrics: + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: bar + scopeMetrics: + - metrics: + - description: Sum if ... + name: sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "4.1" + timeUnixNano: "1678390948395244000" + isMonotonic: true + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: notbar + scopeMetrics: + - metrics: + - description: Sum if ... + name: sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "6.1" + timeUnixNano: "1678390948395279000" + isMonotonic: true diff --git a/connector/sumconnector/testdata/metrics/condition_and_attribute.yaml b/connector/sumconnector/testdata/metrics/condition_and_attribute.yaml new file mode 100644 index 000000000000..414827d5557f --- /dev/null +++ b/connector/sumconnector/testdata/metrics/condition_and_attribute.yaml @@ -0,0 +1,57 @@ +resourceMetrics: + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: bar + scopeMetrics: + - metrics: + - description: Data point sum by attribute if ... + name: datapoint.sum.if.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "22.5" + attributes: + - key: datapoint.required + value: + stringValue: foo + timeUnixNano: "1678391923823222000" + - asDouble: "6" + attributes: + - key: datapoint.required + value: + stringValue: notfoo + timeUnixNano: "1678391923823222000" + isMonotonic: true + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: notbar + scopeMetrics: + - metrics: + - description: Data point sum by attribute if ... + name: datapoint.sum.if.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "6" + attributes: + - key: datapoint.required + value: + stringValue: notfoo + timeUnixNano: "1678391923823233000" + - asDouble: "24.6" + attributes: + - key: datapoint.required + value: + stringValue: foo + timeUnixNano: "1678391923823233000" + isMonotonic: true diff --git a/connector/sumconnector/testdata/metrics/default_attribute_value.yaml b/connector/sumconnector/testdata/metrics/default_attribute_value.yaml new file mode 100644 index 000000000000..d0ccb3f7b790 --- /dev/null +++ b/connector/sumconnector/testdata/metrics/default_attribute_value.yaml @@ -0,0 +1,163 @@ +resourceMetrics: + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: bar + scopeMetrics: + - metrics: + - description: Data point sum by attribute with default + name: datapoint.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "24" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + timeUnixNano: "1678391923822404000" + - asDouble: "12" + attributes: + - key: datapoint.required + value: + stringValue: notfoo + - key: datapoint.optional + value: + stringValue: other + timeUnixNano: "1678391923822404000" + - asDouble: "21" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + timeUnixNano: "1678391923822404000" + isMonotonic: true + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: notbar + scopeMetrics: + - metrics: + - description: Data point sum by attribute with default + name: datapoint.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "25.2" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + timeUnixNano: "1678391923822416000" + - asDouble: "24" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + timeUnixNano: "1678391923822416000" + - asDouble: "12" + attributes: + - key: datapoint.required + value: + stringValue: notfoo + - key: datapoint.optional + value: + stringValue: other + timeUnixNano: "1678391923822416000" + isMonotonic: true + - resource: + attributes: + - key: resource.required + value: + stringValue: notfoo + scopeMetrics: + - metrics: + - description: Data point sum by attribute with default + name: datapoint.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "25.2" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + timeUnixNano: "1678391923822426000" + - asDouble: "24" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + timeUnixNano: "1678391923822426000" + - asDouble: "12" + attributes: + - key: datapoint.required + value: + stringValue: notfoo + - key: datapoint.optional + value: + stringValue: other + timeUnixNano: "1678391923822426000" + isMonotonic: true + - resource: {} + scopeMetrics: + - metrics: + - description: Data point sum by attribute with default + name: datapoint.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "24" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + timeUnixNano: "1678391923822435000" + - asDouble: "12" + attributes: + - key: datapoint.required + value: + stringValue: notfoo + - key: datapoint.optional + value: + stringValue: other + timeUnixNano: "1678391923822435000" + - asDouble: "25.2" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + timeUnixNano: "1678391923822435000" + isMonotonic: true diff --git a/connector/sumconnector/testdata/metrics/input.yaml b/connector/sumconnector/testdata/metrics/input.yaml new file mode 100644 index 000000000000..8a04ab206c3f --- /dev/null +++ b/connector/sumconnector/testdata/metrics/input.yaml @@ -0,0 +1,1390 @@ +resourceMetrics: + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: bar + scopeMetrics: + - metrics: + - gauge: + dataPoints: + - asInt: "123" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + - key: beep + value: + stringValue: "astring" + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asInt: "456" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asInt: "789" + attributes: + - key: datapoint.required + value: + stringValue: notfoo + - key: beep + value: + intValue: 1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asInt: "0" + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + name: gauge-int + unit: "1" + - gauge: + dataPoints: + - asDouble: 1.23 + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asDouble: 4.56 + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asDouble: 7.89 + attributes: + - key: datapoint.required + value: + stringValue: notfoo + - key: beep + value: + intValue: 1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asDouble: 0 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + name: gauge-double + unit: "1" + - name: counter-int + sum: + aggregationTemporality: 2 + dataPoints: + - asInt: "123" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asInt: "456" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asInt: "789" + attributes: + - key: datapoint.required + value: + stringValue: notfoo + - key: beep + value: + intValue: 1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asInt: "0" + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + isMonotonic: true + unit: "1" + - name: counter-double + sum: + aggregationTemporality: 2 + dataPoints: + - asDouble: 1.23 + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asDouble: 4.56 + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asDouble: 4.56 + attributes: + - key: datapoint.required + value: + stringValue: notfoo + - key: beep + value: + intValue: 1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asDouble: 0 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + isMonotonic: true + unit: "1" + - histogram: + aggregationTemporality: 2 + dataPoints: + - attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + count: "1" + startTimeUnixNano: "1581452772000000321" + sum: 15 + timeUnixNano: "1581452773000000789" + - attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + count: "2" + startTimeUnixNano: "1581452772000000321" + sum: 30 + timeUnixNano: "1581452773000000789" + - attributes: + - key: datapoint.required + value: + stringValue: notfoo + - key: beep + value: + intValue: 1 + count: "3" + startTimeUnixNano: "1581452772000000321" + sum: 45 + timeUnixNano: "1581452773000000789" + - startTimeUnixNano: "1581452772000000321" + sum: 0 + timeUnixNano: "1581452773000000789" + name: double-histogram + unit: "1" + - name: double-summary + summary: + dataPoints: + - attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + count: "1" + startTimeUnixNano: "1581452772000000321" + sum: 15 + timeUnixNano: "1581452773000000789" + - attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + count: "2" + startTimeUnixNano: "1581452772000000321" + sum: 30 + timeUnixNano: "1581452773000000789" + - attributes: + - key: datapoint.required + value: + stringValue: notfoo + - key: beep + value: + intValue: 1 + count: "3" + startTimeUnixNano: "1581452772000000321" + sum: 45 + timeUnixNano: "1581452773000000789" + - startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + unit: "1" + scope: {} + + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: notbar + scopeMetrics: + - metrics: + - gauge: + dataPoints: + - asInt: "123" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asInt: "456" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asInt: "789" + attributes: + - key: datapoint.required + value: + stringValue: notfoo + - key: beep + value: + intValue: 1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asInt: "0" + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + name: gauge-int + unit: "1" + - gauge: + dataPoints: + - asDouble: 1.23 + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asDouble: 4.56 + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asDouble: 7.89 + attributes: + - key: datapoint.required + value: + stringValue: notfoo + - key: beep + value: + intValue: 1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asDouble: 0 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + name: gauge-double + unit: "1" + - name: counter-int + sum: + aggregationTemporality: 2 + dataPoints: + - asInt: "123" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asInt: "456" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asInt: "789" + attributes: + - key: datapoint.required + value: + stringValue: notfoo + - key: beep + value: + intValue: 1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asInt: "0" + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + isMonotonic: true + unit: "1" + - name: counter-double + sum: + aggregationTemporality: 2 + dataPoints: + - asDouble: 1.23 + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asDouble: 4.56 + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asDouble: 4.56 + attributes: + - key: datapoint.required + value: + stringValue: notfoo + - key: beep + value: + intValue: 1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asDouble: 0 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + isMonotonic: true + unit: "1" + - histogram: + aggregationTemporality: 2 + dataPoints: + - attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + count: "1" + startTimeUnixNano: "1581452772000000321" + sum: 15 + timeUnixNano: "1581452773000000789" + - attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + count: "2" + startTimeUnixNano: "1581452772000000321" + sum: 30 + timeUnixNano: "1581452773000000789" + - attributes: + - key: datapoint.required + value: + stringValue: notfoo + - key: beep + value: + intValue: 1 + count: "3" + startTimeUnixNano: "1581452772000000321" + sum: 45 + timeUnixNano: "1581452773000000789" + - startTimeUnixNano: "1581452772000000321" + sum: 0 + timeUnixNano: "1581452773000000789" + name: double-histogram + unit: "1" + - name: double-summary + summary: + dataPoints: + - attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + count: "1" + startTimeUnixNano: "1581452772000000321" + sum: 15 + timeUnixNano: "1581452773000000789" + - attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + count: "2" + startTimeUnixNano: "1581452772000000321" + sum: 30 + timeUnixNano: "1581452773000000789" + - attributes: + - key: datapoint.required + value: + stringValue: notfoo + - key: beep + value: + intValue: 1 + count: "3" + startTimeUnixNano: "1581452772000000321" + sum: 45 + timeUnixNano: "1581452773000000789" + - startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + unit: "1" + scope: {} + + - resource: + attributes: + - key: resource.int + value: + intValue: 1 + - key: resource.optional_int + value: + intValue: 2 + scopeMetrics: + - metrics: + - gauge: + dataPoints: + - asInt: "123" + attributes: + - key: datapoint.int + value: + intValue: 1 + - key: datapoint.optional_int + value: + intValue: 2 + - key: beep + value: + doubleValue: 2.1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asInt: "456" + attributes: + - key: datapoint.int + value: + intValue: 1 + - key: datapoint.optional_int + value: + intValue: 4 + - key: beep + value: + doubleValue: 2 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asInt: "789" + attributes: + - key: datapoint.int + value: + intValue: 10 + - key: beep + value: + intValue: 1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asInt: "0" + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + name: gauge-int + unit: "1" + - gauge: + dataPoints: + - asDouble: 1.23 + attributes: + - key: datapoint.int + value: + intValue: 1 + - key: datapoint.optional_int + value: + intValue: 2 + - key: beep + value: + doubleValue: 2.1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asDouble: 4.56 + attributes: + - key: datapoint.int + value: + intValue: 1 + - key: datapoint.optional_int + value: + intValue: 4 + - key: beep + value: + doubleValue: 2 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asDouble: 7.89 + attributes: + - key: datapoint.int + value: + intValue: 10 + - key: beep + value: + intValue: 1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asDouble: 0 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + name: gauge-double + unit: "1" + - name: counter-int + sum: + aggregationTemporality: 2 + dataPoints: + - asInt: "123" + attributes: + - key: datapoint.int + value: + intValue: 1 + - key: datapoint.optional_int + value: + intValue: 2 + - key: beep + value: + doubleValue: 2.1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asInt: "456" + attributes: + - key: datapoint.int + value: + intValue: 1 + - key: datapoint.optional_int + value: + intValue: 4 + - key: beep + value: + doubleValue: 2 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asInt: "789" + attributes: + - key: datapoint.int + value: + intValue: 10 + - key: beep + value: + intValue: 1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asInt: "0" + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + isMonotonic: true + unit: "1" + - name: counter-double + sum: + aggregationTemporality: 2 + dataPoints: + - asDouble: 1.23 + attributes: + - key: datapoint.int + value: + intValue: 1 + - key: datapoint.optional_int + value: + intValue: 2 + - key: beep + value: + doubleValue: 2.1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asDouble: 4.56 + attributes: + - key: datapoint.int + value: + intValue: 1 + - key: datapoint.optional_int + value: + intValue: 4 + - key: beep + value: + doubleValue: 2 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asDouble: 4.56 + attributes: + - key: datapoint.int + value: + intValue: 10 + - key: beep + value: + intValue: 1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asDouble: 0 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + isMonotonic: true + unit: "1" + - histogram: + aggregationTemporality: 2 + dataPoints: + - attributes: + - key: datapoint.int + value: + intValue: 1 + - key: datapoint.optional_int + value: + intValue: 2 + - key: beep + value: + doubleValue: 2.1 + count: "1" + startTimeUnixNano: "1581452772000000321" + sum: 15 + timeUnixNano: "1581452773000000789" + - attributes: + - key: datapoint.int + value: + intValue: 1 + - key: datapoint.optional_int + value: + intValue: 4 + - key: beep + value: + doubleValue: 2 + count: "2" + startTimeUnixNano: "1581452772000000321" + sum: 30 + timeUnixNano: "1581452773000000789" + - attributes: + - key: datapoint.int + value: + intValue: 10 + - key: beep + value: + intValue: 1 + count: "3" + startTimeUnixNano: "1581452772000000321" + sum: 45 + timeUnixNano: "1581452773000000789" + - startTimeUnixNano: "1581452772000000321" + sum: 0 + timeUnixNano: "1581452773000000789" + name: double-histogram + unit: "1" + - name: double-summary + summary: + dataPoints: + - attributes: + - key: datapoint.int + value: + intValue: 1 + - key: datapoint.optional_int + value: + intValue: 2 + - key: beep + value: + doubleValue: 2.1 + count: "1" + startTimeUnixNano: "1581452772000000321" + sum: 15 + timeUnixNano: "1581452773000000789" + - attributes: + - key: datapoint.int + value: + intValue: 10 + - key: datapoint.optional_int + value: + intValue: 4 + - key: beep + value: + doubleValue: 2 + count: "2" + startTimeUnixNano: "1581452772000000321" + sum: 30 + timeUnixNano: "1581452773000000789" + - attributes: + - key: datapoint.int + value: + intValue: 10 + - key: beep + value: + intValue: 1 + count: "3" + startTimeUnixNano: "1581452772000000321" + sum: 45 + timeUnixNano: "1581452773000000789" + - startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + unit: "1" + scope: {} + + - resource: + attributes: + - key: resource.required + value: + stringValue: notfoo + scopeMetrics: + - metrics: + - gauge: + dataPoints: + - asInt: "123" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asInt: "456" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asInt: "789" + attributes: + - key: datapoint.required + value: + stringValue: notfoo + - key: beep + value: + intValue: 1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asInt: "0" + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + name: gauge-int + unit: "1" + - gauge: + dataPoints: + - asDouble: 1.23 + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asDouble: 4.56 + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asDouble: 7.89 + attributes: + - key: datapoint.required + value: + stringValue: notfoo + - key: beep + value: + intValue: 1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asDouble: 0 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + name: gauge-double + unit: "1" + - name: counter-int + sum: + aggregationTemporality: 2 + dataPoints: + - asInt: "123" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asInt: "456" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asInt: "789" + attributes: + - key: datapoint.required + value: + stringValue: notfoo + - key: beep + value: + intValue: 1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asInt: "0" + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + isMonotonic: true + unit: "1" + - name: counter-double + sum: + aggregationTemporality: 2 + dataPoints: + - asDouble: 1.23 + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asDouble: 4.56 + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asDouble: 4.56 + attributes: + - key: datapoint.required + value: + stringValue: notfoo + - key: beep + value: + intValue: 1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asDouble: 0 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + isMonotonic: true + unit: "1" + - histogram: + aggregationTemporality: 2 + dataPoints: + - attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + count: "1" + startTimeUnixNano: "1581452772000000321" + sum: 15 + timeUnixNano: "1581452773000000789" + - attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + count: "2" + startTimeUnixNano: "1581452772000000321" + sum: 30 + timeUnixNano: "1581452773000000789" + - attributes: + - key: datapoint.required + value: + stringValue: notfoo + - key: beep + value: + intValue: 1 + count: "3" + startTimeUnixNano: "1581452772000000321" + sum: 45 + timeUnixNano: "1581452773000000789" + - startTimeUnixNano: "1581452772000000321" + sum: 0 + timeUnixNano: "1581452773000000789" + name: double-histogram + unit: "1" + - name: double-summary + summary: + dataPoints: + - attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + count: "1" + startTimeUnixNano: "1581452772000000321" + sum: 15 + timeUnixNano: "1581452773000000789" + - attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + count: "2" + startTimeUnixNano: "1581452772000000321" + sum: 30 + timeUnixNano: "1581452773000000789" + - attributes: + - key: datapoint.required + value: + stringValue: notfoo + - key: beep + value: + intValue: 1 + count: "3" + startTimeUnixNano: "1581452772000000321" + sum: 45 + timeUnixNano: "1581452773000000789" + - startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + unit: "1" + scope: {} + + - resource: {} + scopeMetrics: + - metrics: + - gauge: + dataPoints: + - asInt: "123" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asInt: "456" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asInt: "789" + attributes: + - key: datapoint.required + value: + stringValue: notfoo + - key: beep + value: + intValue: 1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asInt: "0" + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + name: gauge-int + unit: "1" + - gauge: + dataPoints: + - asDouble: 1.23 + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asDouble: 4.56 + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asDouble: 7.89 + attributes: + - key: datapoint.required + value: + stringValue: notfoo + - key: beep + value: + intValue: 1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asDouble: 0 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + name: gauge-double + unit: "1" + - name: counter-int + sum: + aggregationTemporality: 2 + dataPoints: + - asInt: "123" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asInt: "456" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asInt: "789" + attributes: + - key: datapoint.required + value: + stringValue: notfoo + - key: beep + value: + intValue: 1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asInt: "0" + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + isMonotonic: true + unit: "1" + - name: counter-double + sum: + aggregationTemporality: 2 + dataPoints: + - asDouble: 1.23 + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asDouble: 4.56 + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asDouble: 4.56 + attributes: + - key: datapoint.required + value: + stringValue: notfoo + - key: beep + value: + intValue: 1 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + - asDouble: 0 + startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + isMonotonic: true + unit: "1" + - histogram: + aggregationTemporality: 2 + dataPoints: + - attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + count: "1" + startTimeUnixNano: "1581452772000000321" + sum: 15 + timeUnixNano: "1581452773000000789" + - attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + count: "2" + startTimeUnixNano: "1581452772000000321" + sum: 30 + timeUnixNano: "1581452773000000789" + - attributes: + - key: datapoint.required + value: + stringValue: notfoo + - key: beep + value: + intValue: 1 + count: "3" + startTimeUnixNano: "1581452772000000321" + sum: 45 + timeUnixNano: "1581452773000000789" + - startTimeUnixNano: "1581452772000000321" + sum: 0 + timeUnixNano: "1581452773000000789" + name: double-histogram + unit: "1" + - name: double-summary + summary: + dataPoints: + - attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + count: "1" + startTimeUnixNano: "1581452772000000321" + sum: 15 + timeUnixNano: "1581452773000000789" + - attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + count: "2" + startTimeUnixNano: "1581452772000000321" + sum: 30 + timeUnixNano: "1581452773000000789" + - attributes: + - key: datapoint.required + value: + stringValue: notfoo + - key: beep + value: + intValue: 1 + count: "3" + startTimeUnixNano: "1581452772000000321" + sum: 45 + timeUnixNano: "1581452773000000789" + - startTimeUnixNano: "1581452772000000321" + timeUnixNano: "1581452773000000789" + unit: "1" + scope: {} diff --git a/connector/sumconnector/testdata/metrics/multiple_attributes.yaml b/connector/sumconnector/testdata/metrics/multiple_attributes.yaml new file mode 100644 index 000000000000..5d598f2add3e --- /dev/null +++ b/connector/sumconnector/testdata/metrics/multiple_attributes.yaml @@ -0,0 +1,127 @@ +resourceMetrics: + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: bar + scopeMetrics: + - metrics: + - description: Data point sum by attributes + name: datapoint.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "21" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + timeUnixNano: "1678391923821783000" + - asDouble: "24" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + timeUnixNano: "1678391923821783000" + isMonotonic: true + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: notbar + scopeMetrics: + - metrics: + - description: Data point sum by attributes + name: datapoint.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "25.2" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + timeUnixNano: "1678391923821792000" + - asDouble: "24" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + timeUnixNano: "1678391923821792000" + isMonotonic: true + - resource: + attributes: + - key: resource.required + value: + stringValue: notfoo + scopeMetrics: + - metrics: + - description: Data point sum by attributes + name: datapoint.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "25.2" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + timeUnixNano: "1678391923821800000" + - asDouble: "24" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + timeUnixNano: "1678391923821800000" + isMonotonic: true + - resource: {} + scopeMetrics: + - metrics: + - description: Data point sum by attributes + name: datapoint.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "25.2" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + timeUnixNano: "1678391923821807000" + - asDouble: "24" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: notbar + timeUnixNano: "1678391923821807000" + isMonotonic: true diff --git a/connector/sumconnector/testdata/metrics/multiple_conditions.yaml b/connector/sumconnector/testdata/metrics/multiple_conditions.yaml new file mode 100644 index 000000000000..b95fee6578a9 --- /dev/null +++ b/connector/sumconnector/testdata/metrics/multiple_conditions.yaml @@ -0,0 +1,63 @@ +resourceMetrics: + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: bar + scopeMetrics: + - metrics: + - description: Data point sum if ... + name: datapoint.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "28.5" + timeUnixNano: "1678391923819487000" + isMonotonic: true + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: notbar + scopeMetrics: + - metrics: + - description: Data point sum if ... + name: datapoint.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "30.6" + timeUnixNano: "1678391923819499000" + isMonotonic: true + - resource: + attributes: + - key: resource.required + value: + stringValue: notfoo + scopeMetrics: + - metrics: + - description: Data point sum if ... + name: datapoint.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "24.6" + timeUnixNano: "1678391923819510000" + isMonotonic: true + - resource: {} + scopeMetrics: + - metrics: + - description: Data point sum if ... + name: datapoint.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "24.6" + timeUnixNano: "1678391923819529000" + isMonotonic: true diff --git a/connector/sumconnector/testdata/metrics/multiple_metrics.yaml b/connector/sumconnector/testdata/metrics/multiple_metrics.yaml new file mode 100644 index 000000000000..47982780fb20 --- /dev/null +++ b/connector/sumconnector/testdata/metrics/multiple_metrics.yaml @@ -0,0 +1,113 @@ +resourceMetrics: + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: bar + scopeMetrics: + - metrics: + - description: All data points sum + name: datapoint.sum.all + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "28.5" + timeUnixNano: "1678391923820453000" + isMonotonic: true + - description: Data point sum if ... + name: datapoint.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "28.5" + timeUnixNano: "1678391923820453000" + isMonotonic: true + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: notbar + scopeMetrics: + - metrics: + - description: All data points sum + name: datapoint.sum.all + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "30.6" + timeUnixNano: "1678391923820468000" + isMonotonic: true + - description: Data point sum if ... + name: datapoint.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "30.6" + timeUnixNano: "1678391923820468000" + isMonotonic: true + - resource: + attributes: + - key: resource.required + value: + stringValue: notfoo + scopeMetrics: + - metrics: + - description: All data points sum + name: datapoint.sum.all + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "30.6" + timeUnixNano: "1678391923820480000" + isMonotonic: true + - description: Data point sum if ... + name: datapoint.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "24.6" + timeUnixNano: "1678391923820480000" + isMonotonic: true + - resource: {} + scopeMetrics: + - metrics: + - description: All data points sum + name: datapoint.sum.all + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "30.6" + timeUnixNano: "1678391923820491000" + isMonotonic: true + - description: Data point sum if ... + name: datapoint.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "24.6" + timeUnixNano: "1678391923820491000" + isMonotonic: true + - resource: + attributes: + - key: resource.int + value: + intValue: 1 + - key: resource.optional_int + value: + intValue: 2 + scopeMetrics: + - metrics: + - description: All data points sum + name: datapoint.sum.all + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "30.6" + timeUnixNano: "1678391923820480000" + isMonotonic: true diff --git a/connector/sumconnector/testdata/metrics/one_attribute.yaml b/connector/sumconnector/testdata/metrics/one_attribute.yaml new file mode 100644 index 000000000000..2dac193abaf2 --- /dev/null +++ b/connector/sumconnector/testdata/metrics/one_attribute.yaml @@ -0,0 +1,103 @@ +resourceMetrics: + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: bar + scopeMetrics: + - metrics: + - description: Data point sum by attribute + name: datapoint.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "22.5" + attributes: + - key: datapoint.required + value: + stringValue: foo + timeUnixNano: "1678391923821179000" + - asDouble: "6" + attributes: + - key: datapoint.required + value: + stringValue: notfoo + timeUnixNano: "1678391923821179000" + isMonotonic: true + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: notbar + scopeMetrics: + - metrics: + - description: Data point sum by attribute + name: datapoint.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "24.6" + attributes: + - key: datapoint.required + value: + stringValue: foo + timeUnixNano: "1678391923821189000" + - asDouble: "6" + attributes: + - key: datapoint.required + value: + stringValue: notfoo + timeUnixNano: "1678391923821189000" + isMonotonic: true + - resource: + attributes: + - key: resource.required + value: + stringValue: notfoo + scopeMetrics: + - metrics: + - description: Data point sum by attribute + name: datapoint.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "24.6" + attributes: + - key: datapoint.required + value: + stringValue: foo + timeUnixNano: "1678391923821196000" + - asDouble: "6" + attributes: + - key: datapoint.required + value: + stringValue: notfoo + timeUnixNano: "1678391923821196000" + isMonotonic: true + - resource: {} + scopeMetrics: + - metrics: + - description: Data point sum by attribute + name: datapoint.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "24.6" + attributes: + - key: datapoint.required + value: + stringValue: foo + timeUnixNano: "1678391923821203000" + - asDouble: "6" + attributes: + - key: datapoint.required + value: + stringValue: notfoo + timeUnixNano: "1678391923821203000" + isMonotonic: true diff --git a/connector/sumconnector/testdata/metrics/one_condition.yaml b/connector/sumconnector/testdata/metrics/one_condition.yaml new file mode 100644 index 000000000000..c4953f43827a --- /dev/null +++ b/connector/sumconnector/testdata/metrics/one_condition.yaml @@ -0,0 +1,37 @@ +resourceMetrics: + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: bar + scopeMetrics: + - metrics: + - description: Data point sum if ... + name: datapoint.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "28.5" + timeUnixNano: "1678391923818482000" + isMonotonic: true + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: notbar + scopeMetrics: + - metrics: + - description: Data point sum if ... + name: datapoint.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "30.6" + timeUnixNano: "1678391923818549000" + isMonotonic: true From 67b53e38adc42a707c0f185d62ffe320ac6954d3 Mon Sep 17 00:00:00 2001 From: Jeremy Hicks Date: Fri, 27 Sep 2024 12:23:36 -0400 Subject: [PATCH 3/3] Update connector/sumconnector/connector_test.go Co-authored-by: Curtis Robert --- connector/sumconnector/connector_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connector/sumconnector/connector_test.go b/connector/sumconnector/connector_test.go index 7f1e2ecf190d..d37129de7c02 100644 --- a/connector/sumconnector/connector_test.go +++ b/connector/sumconnector/connector_test.go @@ -271,7 +271,7 @@ func TestTracesToMetrics(t *testing.T) { } // The test input file has a repetitive structure: -// - There are four resources, each with six metrics, each with four data point. +// - There are four resources, each with six metrics, each with four data points. // - The four resources have the following sets of attributes: // - resource.required: foo, resource.optional: bar // - resource.required: foo, resource.optional: notbar