From c38069d74e55e4574cbdc5a47bf3d3db3c9011f9 Mon Sep 17 00:00:00 2001 From: jeremyh Date: Wed, 21 Aug 2024 13:49:32 -0400 Subject: [PATCH 01/15] add connector and sum logic --- connector/sumconnector/connector.go | 142 ++++++++++++++++ connector/sumconnector/go.mod | 12 +- connector/sumconnector/go.sum | 10 +- .../internal/metadata/generated_status.go | 3 +- connector/sumconnector/metadata.yaml | 1 + connector/sumconnector/sum.go | 159 ++++++++++++++++++ 6 files changed, 315 insertions(+), 12 deletions(-) create mode 100644 connector/sumconnector/sum.go diff --git a/connector/sumconnector/connector.go b/connector/sumconnector/connector.go index 22ed13dd5c02..fe9f44440dca 100644 --- a/connector/sumconnector/connector.go +++ b/connector/sumconnector/connector.go @@ -5,9 +5,12 @@ package sumconnector // import "github.com/open-telemetry/opentelemetry-collecto import ( "context" + "errors" + "fmt" "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/consumer" + "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/plog" "go.opentelemetry.io/collector/pdata/pmetric" "go.opentelemetry.io/collector/pdata/ptrace" @@ -19,6 +22,8 @@ import ( "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/ottlspanevent" ) +const scopeName = "otelcol/sumconnector" + // sum can sum attribute values from spans, span event, metrics, data points, or log records // and emit the sums onto a metrics pipeline. type sum struct { @@ -38,22 +43,159 @@ func (c *sum) Capabilities() consumer.Capabilities { } func (c *sum) ConsumeTraces(ctx context.Context, td ptrace.Traces) error { + var multiError error sumMetrics := pmetric.NewMetrics() sumMetrics.ResourceMetrics().EnsureCapacity(td.ResourceSpans().Len()) + for i := 0; i < td.ResourceSpans().Len(); i++ { + resourceSpan := td.ResourceSpans().At(i) + spansSummer := newSummer[ottlspan.TransformContext](c.spansMetricDefs) + spanEventsSummer := newSummer[ottlspanevent.TransformContext](c.spanEventsMetricDefs) + + for j := 0; j < resourceSpan.ScopeSpans().Len(); j++ { + scopeSpan := resourceSpan.ScopeSpans().At(j) + + for k := 0; k < scopeSpan.Spans().Len(); k++ { + span := scopeSpan.Spans().At(k) + sCtx := ottlspan.NewTransformContext(span, scopeSpan.Scope(), resourceSpan.Resource(), scopeSpan, resourceSpan) + multiError = errors.Join(multiError, spansSummer.update(ctx, span.Attributes(), sCtx)) + + for l := 0; l < span.Events().Len(); l++ { + event := span.Events().At(l) + eCtx := ottlspanevent.NewTransformContext(event, span, scopeSpan.Scope(), resourceSpan.Resource(), scopeSpan, resourceSpan) + multiError = errors.Join(multiError, spanEventsSummer.update(ctx, event.Attributes(), eCtx)) + } + } + } + + if len(spansSummer.sums)+len(spanEventsSummer.sums) == 0 { + continue // don't add an empty resource + } + sumResource := sumMetrics.ResourceMetrics().AppendEmpty() + resourceSpan.Resource().Attributes().CopyTo(sumResource.Resource().Attributes()) + + sumResource.ScopeMetrics().EnsureCapacity(resourceSpan.ScopeSpans().Len()) + sumScope := sumResource.ScopeMetrics().AppendEmpty() + sumScope.Scope().SetName(scopeName) + + spansSummer.appendMetricsTo(sumScope.Metrics()) + spanEventsSummer.appendMetricsTo(sumScope.Metrics()) + } + if multiError != nil { + return multiError + } return c.metricsConsumer.ConsumeMetrics(ctx, sumMetrics) } func (c *sum) ConsumeMetrics(ctx context.Context, md pmetric.Metrics) error { + var multiError error sumMetrics := pmetric.NewMetrics() sumMetrics.ResourceMetrics().EnsureCapacity(md.ResourceMetrics().Len()) + for i := 0; i < md.ResourceMetrics().Len(); i++ { + resourceMetric := md.ResourceMetrics().At(i) + metricsSummer := newSummer[ottlmetric.TransformContext](c.metricsMetricDefs) + dataPointsSummer := newSummer[ottldatapoint.TransformContext](c.dataPointsMetricDefs) + + for j := 0; j < resourceMetric.ScopeMetrics().Len(); j++ { + scopeMetrics := resourceMetric.ScopeMetrics().At(j) + + for k := 0; k < scopeMetrics.Metrics().Len(); k++ { + metric := scopeMetrics.Metrics().At(k) + mCtx := ottlmetric.NewTransformContext(metric, scopeMetrics.Metrics(), scopeMetrics.Scope(), resourceMetric.Resource(), scopeMetrics, resourceMetric) + multiError = errors.Join(multiError, metricsSummer.update(ctx, pcommon.NewMap(), mCtx)) + + //exhaustive:enforce + switch metric.Type() { + case pmetric.MetricTypeGauge: + dps := metric.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dCtx := ottldatapoint.NewTransformContext(dps.At(i), metric, scopeMetrics.Metrics(), scopeMetrics.Scope(), resourceMetric.Resource(), scopeMetrics, resourceMetric) + multiError = errors.Join(multiError, dataPointsSummer.update(ctx, dps.At(i).Attributes(), dCtx)) + } + case pmetric.MetricTypeSum: + dps := metric.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dCtx := ottldatapoint.NewTransformContext(dps.At(i), metric, scopeMetrics.Metrics(), scopeMetrics.Scope(), resourceMetric.Resource(), scopeMetrics, resourceMetric) + multiError = errors.Join(multiError, dataPointsSummer.update(ctx, dps.At(i).Attributes(), dCtx)) + } + case pmetric.MetricTypeSummary: + dps := metric.Summary().DataPoints() + for i := 0; i < dps.Len(); i++ { + dCtx := ottldatapoint.NewTransformContext(dps.At(i), metric, scopeMetrics.Metrics(), scopeMetrics.Scope(), resourceMetric.Resource(), scopeMetrics, resourceMetric) + multiError = errors.Join(multiError, dataPointsSummer.update(ctx, dps.At(i).Attributes(), dCtx)) + } + case pmetric.MetricTypeHistogram: + dps := metric.Histogram().DataPoints() + for i := 0; i < dps.Len(); i++ { + dCtx := ottldatapoint.NewTransformContext(dps.At(i), metric, scopeMetrics.Metrics(), scopeMetrics.Scope(), resourceMetric.Resource(), scopeMetrics, resourceMetric) + multiError = errors.Join(multiError, dataPointsSummer.update(ctx, dps.At(i).Attributes(), dCtx)) + } + case pmetric.MetricTypeExponentialHistogram: + dps := metric.ExponentialHistogram().DataPoints() + for i := 0; i < dps.Len(); i++ { + dCtx := ottldatapoint.NewTransformContext(dps.At(i), metric, scopeMetrics.Metrics(), scopeMetrics.Scope(), resourceMetric.Resource(), scopeMetrics, resourceMetric) + multiError = errors.Join(multiError, dataPointsSummer.update(ctx, dps.At(i).Attributes(), dCtx)) + } + case pmetric.MetricTypeEmpty: + multiError = errors.Join(multiError, fmt.Errorf("metric %q: invalid metric type: %v", metric.Name(), metric.Type())) + } + } + } + if len(metricsSummer.sums)+len(dataPointsSummer.sums) == 0 { + continue // don't add an empty resource + } + + sumResource := sumMetrics.ResourceMetrics().AppendEmpty() + resourceMetric.Resource().Attributes().CopyTo(sumResource.Resource().Attributes()) + + sumResource.ScopeMetrics().EnsureCapacity(resourceMetric.ScopeMetrics().Len()) + sumScope := sumResource.ScopeMetrics().AppendEmpty() + sumScope.Scope().SetName(scopeName) + + metricsSummer.appendMetricsTo(sumScope.Metrics()) + dataPointsSummer.appendMetricsTo(sumScope.Metrics()) + } + if multiError != nil { + return multiError + } return c.metricsConsumer.ConsumeMetrics(ctx, sumMetrics) } func (c *sum) ConsumeLogs(ctx context.Context, ld plog.Logs) error { + var multiError error sumMetrics := pmetric.NewMetrics() sumMetrics.ResourceMetrics().EnsureCapacity(ld.ResourceLogs().Len()) + for i := 0; i < ld.ResourceLogs().Len(); i++ { + resourceLog := ld.ResourceLogs().At(i) + summer := newSummer[ottllog.TransformContext](c.logsMetricDefs) + + for j := 0; j < resourceLog.ScopeLogs().Len(); j++ { + scopeLogs := resourceLog.ScopeLogs().At(j) + + for k := 0; k < scopeLogs.LogRecords().Len(); k++ { + logRecord := scopeLogs.LogRecords().At(k) + + lCtx := ottllog.NewTransformContext(logRecord, scopeLogs.Scope(), resourceLog.Resource(), scopeLogs, resourceLog) + multiError = errors.Join(multiError, summer.update(ctx, logRecord.Attributes(), lCtx)) + } + } + + if len(summer.sums) == 0 { + continue // don't add an empty resource + } + + sumResource := sumMetrics.ResourceMetrics().AppendEmpty() + resourceLog.Resource().Attributes().CopyTo(sumResource.Resource().Attributes()) + + sumResource.ScopeMetrics().EnsureCapacity(resourceLog.ScopeLogs().Len()) + sumScope := sumResource.ScopeMetrics().AppendEmpty() + sumScope.Scope().SetName(scopeName) + summer.appendMetricsTo(sumScope.Metrics()) + } + if multiError != nil { + return multiError + } return c.metricsConsumer.ConsumeMetrics(ctx, sumMetrics) } diff --git a/connector/sumconnector/go.mod b/connector/sumconnector/go.mod index 6531d40ca27a..9213f78f173f 100644 --- a/connector/sumconnector/go.mod +++ b/connector/sumconnector/go.mod @@ -2,13 +2,18 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/connector/sumco go 1.22.0 +toolchain go1.22.1 + require ( - github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter v0.107.0 + github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter v0.105.0 + github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden v0.107.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl v0.107.0 + github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.107.0 + github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.107.0 github.com/stretchr/testify v1.9.0 go.opentelemetry.io/collector/component v0.107.1-0.20240821120936-6764622672bc go.opentelemetry.io/collector/confmap v0.107.1-0.20240821120936-6764622672bc - go.opentelemetry.io/collector/connector v0.107.1-0.20240821120936-6764622672bc + go.opentelemetry.io/collector/connector v0.106.1 go.opentelemetry.io/collector/consumer v0.107.1-0.20240821120936-6764622672bc go.opentelemetry.io/collector/consumer/consumertest v0.107.1-0.20240821120936-6764622672bc go.opentelemetry.io/collector/pdata v1.13.1-0.20240821120936-6764622672bc @@ -49,8 +54,7 @@ require ( github.com/prometheus/common v0.55.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect github.com/ua-parser/uap-go v0.0.0-20240611065828-3a4781585db6 // indirect - go.opentelemetry.io/collector v0.107.1-0.20240821120936-6764622672bc // indirect - go.opentelemetry.io/collector/component/componentprofiles v0.107.1-0.20240821120936-6764622672bc // indirect + go.opentelemetry.io/collector v0.106.1 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.107.1-0.20240821120936-6764622672bc // indirect go.opentelemetry.io/collector/consumer/consumerprofiles v0.107.1-0.20240821120936-6764622672bc // indirect go.opentelemetry.io/collector/pdata/pprofile v0.107.1-0.20240821120936-6764622672bc // indirect diff --git a/connector/sumconnector/go.sum b/connector/sumconnector/go.sum index 7214be32310f..8c6d0f63ca35 100644 --- a/connector/sumconnector/go.sum +++ b/connector/sumconnector/go.sum @@ -88,18 +88,16 @@ github.com/ua-parser/uap-go v0.0.0-20240611065828-3a4781585db6 h1:SIKIoA4e/5Y9ZO github.com/ua-parser/uap-go v0.0.0-20240611065828-3a4781585db6/go.mod h1:BUbeWZiieNxAuuADTBNb3/aeje6on3DhU3rpWsQSB1E= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.opentelemetry.io/collector v0.107.1-0.20240821120936-6764622672bc h1:07hOlKIqLv9cCkmJP1lWyxovBuTKqjDXCHkRb8TcwLU= -go.opentelemetry.io/collector v0.107.1-0.20240821120936-6764622672bc/go.mod h1:CV+TcsXAbzku7KOsstpAgnmkM5JvE7TDSoDN0/UBTtQ= +go.opentelemetry.io/collector v0.106.1 h1:ZSQMpFGzFP3RILe1/+K80kCCT2ahn3MKt5e3u0Yz7Rs= +go.opentelemetry.io/collector v0.106.1/go.mod h1:1FabMxWLluLNcC0dq8cI01GaE6t6fYxE6Oxuf8u7AGQ= go.opentelemetry.io/collector/component v0.107.1-0.20240821120936-6764622672bc h1:g2ZH4rsZ3RaPwaY8w8IawP2nDC0IIDK8FJyS1Dr68JM= go.opentelemetry.io/collector/component v0.107.1-0.20240821120936-6764622672bc/go.mod h1:gfntGv2c1Zvc9juFwe9PFX6IxNkkibA9VZb67KJqx9Y= -go.opentelemetry.io/collector/component/componentprofiles v0.107.1-0.20240821120936-6764622672bc h1:2GC5kmNuMSNa1+X0MyAwZcXr0evX6CcMWsZamf8DIIQ= -go.opentelemetry.io/collector/component/componentprofiles v0.107.1-0.20240821120936-6764622672bc/go.mod h1:rx96BZhx7MuGMZ8o/+mPSbCSWVHDeTw8Ihcxjr1we9A= go.opentelemetry.io/collector/config/configtelemetry v0.107.1-0.20240821120936-6764622672bc h1:/KTt1JrsrAnjIVas8I+ULnXGzKX2Uyp4o/DMqSxrc9Q= go.opentelemetry.io/collector/config/configtelemetry v0.107.1-0.20240821120936-6764622672bc/go.mod h1:R0MBUxjSMVMIhljuDHWIygzzJWQyZHXXWIgQNxcFwhc= go.opentelemetry.io/collector/confmap v0.107.1-0.20240821120936-6764622672bc h1:do58ygb12Zt3//CBAGtrZBjxZkZbnx+y5QSMTDOF7XU= go.opentelemetry.io/collector/confmap v0.107.1-0.20240821120936-6764622672bc/go.mod h1:GrIZ12P/9DPOuTpe2PIS51a0P/ZM6iKtByVee1Uf3+k= -go.opentelemetry.io/collector/connector v0.107.1-0.20240821120936-6764622672bc h1:zmlXZLgjLrrcmlyx1gwrcvYxpOJY9A8CMo6xzz4LaR0= -go.opentelemetry.io/collector/connector v0.107.1-0.20240821120936-6764622672bc/go.mod h1:4jSz/K8GpSVQE9N1dZIm0MVgySjZ+h22aC0GjnsoNgI= +go.opentelemetry.io/collector/connector v0.106.1 h1:sgPSyzqKBuxo7qz+kTfa6GxSAtt0T6H9mwdm9VDYObA= +go.opentelemetry.io/collector/connector v0.106.1/go.mod h1:HpQIfCV9j72XjdnF0g+V4W064dy0Qu63hlb84rAXPZ4= go.opentelemetry.io/collector/consumer v0.107.1-0.20240821120936-6764622672bc h1:81GkskkDn4B07yC9kUXlKUqGNNQim4mFShwdYlGesCo= go.opentelemetry.io/collector/consumer v0.107.1-0.20240821120936-6764622672bc/go.mod h1:eNdgFcd4kPmFcNi6b1A9rCvaWr/9mXnKOb2qS/YC6ec= go.opentelemetry.io/collector/consumer/consumerprofiles v0.107.1-0.20240821120936-6764622672bc h1:ttI2LUPSQlyH4E6Ms4PDyyh04SMx45+ZxfSkGU+/XNU= diff --git a/connector/sumconnector/internal/metadata/generated_status.go b/connector/sumconnector/internal/metadata/generated_status.go index d4155ac3e40a..93382f53d902 100644 --- a/connector/sumconnector/internal/metadata/generated_status.go +++ b/connector/sumconnector/internal/metadata/generated_status.go @@ -7,8 +7,7 @@ import ( ) var ( - Type = component.MustNewType("sum") - ScopeName = "github.com/open-telemetry/opentelemetry-collector-contrib/connector/sumconnector" + Type = component.MustNewType("sum") ) const ( diff --git a/connector/sumconnector/metadata.yaml b/connector/sumconnector/metadata.yaml index 42a50533af3d..fdbb70077050 100644 --- a/connector/sumconnector/metadata.yaml +++ b/connector/sumconnector/metadata.yaml @@ -1,4 +1,5 @@ type: sum +scope_name: otelcol/sumconnector status: class: connector diff --git a/connector/sumconnector/sum.go b/connector/sumconnector/sum.go new file mode 100644 index 000000000000..22a3fce0a0f6 --- /dev/null +++ b/connector/sumconnector/sum.go @@ -0,0 +1,159 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package sumconnector // import "github.com/open-telemetry/opentelemetry-collector-contrib/connector/sumconnector" + +import ( + "context" + "errors" + "fmt" + "math" + "strconv" + "time" + + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/pmetric" + + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil" +) + +var noAttributes = [16]byte{} + +func roundFloat(val float64) float64 { + return math.Round(val*100000) / 100000 +} + +func newSummer[K any](metricDefs map[string]metricDef[K]) *summer[K] { + return &summer[K]{ + metricDefs: metricDefs, + sums: make(map[string]map[[16]byte]*attrSummer, len(metricDefs)), + timestamp: time.Now(), + } +} + +type summer[K any] struct { + metricDefs map[string]metricDef[K] + sums map[string]map[[16]byte]*attrSummer + timestamp time.Time +} + +type attrSummer struct { + attrs pcommon.Map + sum float64 +} + +func (c *summer[K]) update(ctx context.Context, attrs pcommon.Map, tCtx K) error { + var multiError error + for name, md := range c.metricDefs { + sourceAttribute := md.sourceAttr + sumAttrs := pcommon.NewMap() + var sumVal float64 + + // Get source attribute value + if sourceAttrVal, ok := attrs.Get(sourceAttribute); ok { + switch { + case sourceAttrVal.Str() != "": + sumVal, _ = strconv.ParseFloat(sourceAttrVal.Str(), 64) + case sourceAttrVal.Double() != 0: + sumVal = sourceAttrVal.Double() + case sourceAttrVal.Int() != 0: + sumVal = float64(sourceAttrVal.Int()) + } + } + + // Get attribute values to include otherwise include default value + for _, attr := range md.attrs { + if attrVal, ok := attrs.Get(attr.Key); ok { + switch { + case attrVal.Str() != "": + sumAttrs.PutStr(attr.Key, attrVal.Str()) + case attrVal.Double() != 0: + sumAttrs.PutStr(attr.Key, fmt.Sprintf("%v", attrVal.Double())) + case attrVal.Int() != 0: + sumAttrs.PutStr(attr.Key, fmt.Sprintf("%v", attrVal.Int())) + } + } else if attr.DefaultValue != nil { + switch v := attr.DefaultValue.(type) { + case string: + if v != "" { + sumAttrs.PutStr(attr.Key, v) + } + case int: + if v != 0 { + sumAttrs.PutInt(attr.Key, int64(v)) + } + case float64: + if v != 0 { + sumAttrs.PutDouble(attr.Key, float64(v)) + } + } + } + } + + // Missing necessary attributes + if sumAttrs.Len() != len(md.attrs) { + continue + } + + // Perform condition matching or not + if md.condition == nil { + multiError = errors.Join(multiError, c.increment(name, sumVal, sumAttrs)) + continue + } + + if match, err := md.condition.Eval(ctx, tCtx); err != nil { + multiError = errors.Join(multiError, err) + } else if match { + multiError = errors.Join(multiError, c.increment(name, sumVal, sumAttrs)) + } + } + return multiError +} + +func (c *summer[K]) increment(metricName string, sumVal float64, attrs pcommon.Map) error { + if _, ok := c.sums[metricName]; !ok { + c.sums[metricName] = make(map[[16]byte]*attrSummer) + } + + key := noAttributes + if attrs.Len() > 0 { + key = pdatautil.MapHash(attrs) + } + + if _, ok := c.sums[metricName][key]; !ok { + c.sums[metricName][key] = &attrSummer{attrs: attrs} + } + + for strings := range c.sums[metricName][key].attrs.AsRaw() { + if _, ok := c.sums[metricName][key].attrs.Get(strings); ok { + c.sums[metricName][key].sum += sumVal + } + } + + if attrs.Len() == 0 { + c.sums[metricName][key].sum += sumVal + } + + return nil +} + +func (c *summer[K]) appendMetricsTo(metricSlice pmetric.MetricSlice) { + for name, md := range c.metricDefs { + if len(c.sums[name]) == 0 { + continue + } + sumMetric := metricSlice.AppendEmpty() + sumMetric.SetName(name) + sumMetric.SetDescription(md.desc) + sum := sumMetric.SetEmptySum() + // The delta value is always positive, so a value accumulated downstream is monotonic + sum.SetIsMonotonic(true) + sum.SetAggregationTemporality(pmetric.AggregationTemporalityDelta) + for _, dpSum := range c.sums[name] { + dp := sum.DataPoints().AppendEmpty() + dpSum.attrs.CopyTo(dp.Attributes()) + dp.SetDoubleValue(roundFloat(dpSum.sum)) + dp.SetTimestamp(pcommon.NewTimestampFromTime(c.timestamp)) + } + } +} From 36d9c7ef6364edbd14c9c28b7a39faab5084fb38 Mon Sep 17 00:00:00 2001 From: jeremyh Date: Wed, 21 Aug 2024 13:50:13 -0400 Subject: [PATCH 02/15] add connector testing for traces, spans, metrics, logs --- connector/sumconnector/connector_test.go | 624 ++++++++ .../logs/condition_and_attribute.yaml | 61 + .../logs/default_attribute_value.yaml | 171 ++ .../sumconnector/testdata/logs/input.yaml | 223 +++ .../testdata/logs/multiple_attributes.yaml | 135 ++ .../testdata/logs/multiple_conditions.yaml | 71 + .../testdata/logs/multiple_metrics.yaml | 87 ++ .../testdata/logs/one_attribute.yaml | 111 ++ .../testdata/logs/one_condition.yaml | 41 + .../metrics/condition_and_attribute.yaml | 61 + .../metrics/default_attribute_value.yaml | 171 ++ .../sumconnector/testdata/metrics/input.yaml | 1390 +++++++++++++++++ .../testdata/metrics/multiple_attributes.yaml | 135 ++ .../testdata/metrics/multiple_conditions.yaml | 71 + .../testdata/metrics/multiple_metrics.yaml | 123 ++ .../testdata/metrics/one_attribute.yaml | 111 ++ .../testdata/metrics/one_condition.yaml | 41 + .../traces/condition_and_attribute.yaml | 97 ++ .../sumconnector/testdata/traces/input.yaml | 852 ++++++++++ .../testdata/traces/multiple_attributes.yaml | 231 +++ .../testdata/traces/multiple_conditions.yaml | 103 ++ .../testdata/traces/multiple_metrics.yaml | 167 ++ .../testdata/traces/one_attribute.yaml | 186 +++ .../testdata/traces/one_condition.yaml | 57 + .../testdata/traces/zero_conditions.yaml | 103 ++ 25 files changed, 5423 insertions(+) create mode 100644 connector/sumconnector/connector_test.go 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 create mode 100644 connector/sumconnector/testdata/traces/condition_and_attribute.yaml create mode 100644 connector/sumconnector/testdata/traces/input.yaml create mode 100644 connector/sumconnector/testdata/traces/multiple_attributes.yaml create mode 100644 connector/sumconnector/testdata/traces/multiple_conditions.yaml create mode 100644 connector/sumconnector/testdata/traces/multiple_metrics.yaml create mode 100644 connector/sumconnector/testdata/traces/one_attribute.yaml create mode 100644 connector/sumconnector/testdata/traces/one_condition.yaml create mode 100644 connector/sumconnector/testdata/traces/zero_conditions.yaml diff --git a/connector/sumconnector/connector_test.go b/connector/sumconnector/connector_test.go new file mode 100644 index 000000000000..5eb8e1d1639d --- /dev/null +++ b/connector/sumconnector/connector_test.go @@ -0,0 +1,624 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package sumconnector + +import ( + "context" + "path/filepath" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component/componenttest" + "go.opentelemetry.io/collector/connector/connectortest" + "go.opentelemetry.io/collector/consumer/consumertest" + + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest/pmetrictest" +) + +// The test input file has a repetitive structure: +// - There are four resources, each with four spans, each with four span events. +// - 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 spans on each resource have the following sets of attributes: +// - span.required: foo, span.optional: bar +// - span.required: foo, span.optional: notbar +// - span.required: notfoo +// - (no attributes) +// +// - The four span events on each span have the following sets of attributes: +// - event.required: foo, event.optional: bar +// - event.required: foo, event.optional: notbar +// - event.required: notfoo +// - (no attributes) +func TestTracesToMetrics(t *testing.T) { + testCases := []struct { + name string + cfg *Config + }{ + { + name: "zero_conditions", + cfg: &Config{ + Spans: map[string]MetricInfo{ + "trace.span.sum": { + Description: "The sum of beep values observed in spans.", + SourceAttribute: "beep", + }, + }, + SpanEvents: map[string]MetricInfo{ + "trace.span.event.sum": { + Description: "The sum of beep values observed in span events.", + SourceAttribute: "beep", + }, + }, + }, + }, + { + name: "one_condition", + cfg: &Config{ + Spans: map[string]MetricInfo{ + "span.sum.if": { + Description: "Span sum if ...", + SourceAttribute: "beep", + Conditions: []string{ + `resource.attributes["resource.optional"] != nil`, + }, + }, + }, + SpanEvents: map[string]MetricInfo{ + "spanevent.sum.if": { + Description: "Span event sum if ...", + SourceAttribute: "beep", + Conditions: []string{ + `resource.attributes["resource.optional"] != nil`, + }, + }, + }, + }, + }, + { + name: "one_attribute", + cfg: &Config{ + Spans: map[string]MetricInfo{ + "span.sum.by_attr": { + Description: "Span sum by attribute", + SourceAttribute: "beep", + Attributes: []AttributeConfig{ + { + Key: "span.required", + }, + }, + }, + }, + SpanEvents: map[string]MetricInfo{ + "spanevent.sum.by_attr": { + Description: "Span event sum by attribute", + SourceAttribute: "beep", + Attributes: []AttributeConfig{ + { + Key: "event.required", + }, + }, + }, + }, + }, + }, + { + name: "multiple_conditions", + cfg: &Config{ + Spans: map[string]MetricInfo{ + "span.sum.if": { + Description: "Span sum if ...", + SourceAttribute: "beep", + Conditions: []string{ + `resource.attributes["resource.optional"] != nil`, + `attributes["span.optional"] != nil`, + }, + }, + }, + SpanEvents: map[string]MetricInfo{ + "spanevent.sum.if": { + Description: "Span event sum if ...", + SourceAttribute: "beep", + Conditions: []string{ + `resource.attributes["resource.optional"] != nil`, + `attributes["event.optional"] != nil`, + }, + }, + }, + }, + }, + { + name: "multiple_attributes", + cfg: &Config{ + Spans: map[string]MetricInfo{ + "span.sum.by_attr": { + Description: "Span sum by attributes", + SourceAttribute: "beep", + Attributes: []AttributeConfig{ + { + Key: "span.required", + }, + { + Key: "span.optional", + }, + }, + }, + }, + SpanEvents: map[string]MetricInfo{ + "spanevent.sum.by_attr": { + Description: "Span event sum by attributes", + SourceAttribute: "beep", + Attributes: []AttributeConfig{ + { + Key: "event.required", + }, + { + Key: "event.optional", + }, + }, + }, + }, + }, + }, + { + name: "multiple_metrics", + cfg: &Config{ + Spans: map[string]MetricInfo{ + "span.sum.all": { + Description: "All spans sum", + SourceAttribute: "beep", + }, + "span.sum.if": { + Description: "Span sum if ...", + SourceAttribute: "beep", + Conditions: []string{ + `resource.attributes["resource.optional"] != nil`, + `attributes["span.optional"] != nil`, + }, + }, + }, + SpanEvents: map[string]MetricInfo{ + "spanevent.sum.all": { + Description: "All span events sum", + SourceAttribute: "beep", + }, + "spanevent.sum.if": { + Description: "Span event sum if ...", + SourceAttribute: "beep", + Conditions: []string{ + `resource.attributes["resource.optional"] != nil`, + `attributes["event.optional"] != nil`, + }, + }, + }, + }, + }, + { + name: "condition_and_attribute", + cfg: &Config{ + Spans: map[string]MetricInfo{ + "span.sum.if.by_attr": { + Description: "Span sum if ...", + SourceAttribute: "beep", + Conditions: []string{ + `resource.attributes["resource.optional"] != nil`, + }, + Attributes: []AttributeConfig{ + { + Key: "span.required", + }, + }, + }, + }, + SpanEvents: map[string]MetricInfo{ + "spanevent.sum.if.by_attr": { + Description: "Span event sum by attribute if ...", + SourceAttribute: "beep", + Conditions: []string{ + `resource.attributes["resource.optional"] != nil`, + }, + Attributes: []AttributeConfig{ + { + Key: "event.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.CreateTracesToMetrics(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())) + }() + + testSpans, err := golden.ReadTraces(filepath.Join("testdata", "traces", "input.yaml")) + assert.NoError(t, err) + assert.NoError(t, conn.ConsumeTraces(context.Background(), testSpans)) + + allMetrics := sink.AllMetrics() + assert.Equal(t, 1, len(allMetrics)) + + expected, err := golden.ReadMetrics(filepath.Join("testdata", "traces", tc.name+".yaml")) + assert.NoError(t, err) + assert.NoError(t, pmetrictest.CompareMetrics(expected, allMetrics[0], + pmetrictest.IgnoreTimestamp(), + pmetrictest.IgnoreResourceMetricsOrder(), + pmetrictest.IgnoreMetricsOrder(), + pmetrictest.IgnoreMetricDataPointsOrder())) + }) + } +} + +// 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.Equal(t, 1, len(allMetrics)) + + 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.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.Equal(t, 1, len(allMetrics)) + + 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.IgnoreMetricDataPointsOrder())) + }) + } +} 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..7baf26c31c13 --- /dev/null +++ b/connector/sumconnector/testdata/logs/condition_and_attribute.yaml @@ -0,0 +1,61 @@ +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: "4.1" + attributes: + - key: log.required + value: + stringValue: foo + timeUnixNano: "1678390948399018000" + - asDouble: "2" + attributes: + - key: log.required + value: + stringValue: notfoo + timeUnixNano: "1678390948399018000" + isMonotonic: true + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector 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..5c5157c86827 --- /dev/null +++ b/connector/sumconnector/testdata/logs/default_attribute_value.yaml @@ -0,0 +1,171 @@ +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: "4" + 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 + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/logs/input.yaml b/connector/sumconnector/testdata/logs/input.yaml new file mode 100644 index 000000000000..61a1f039b9ef --- /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: + 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: 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..ac6ce90bdf19 --- /dev/null +++ b/connector/sumconnector/testdata/logs/multiple_attributes.yaml @@ -0,0 +1,135 @@ +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: "4" + attributes: + - key: log.required + value: + stringValue: foo + - key: log.optional + value: + stringValue: notbar + timeUnixNano: "1678390948397879000" + isMonotonic: true + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/logs/multiple_conditions.yaml b/connector/sumconnector/testdata/logs/multiple_conditions.yaml new file mode 100644 index 000000000000..e8a2ed9680d3 --- /dev/null +++ b/connector/sumconnector/testdata/logs/multiple_conditions.yaml @@ -0,0 +1,71 @@ +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: "6.1" + timeUnixNano: "1678390948395853000" + isMonotonic: true + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector + - resource: {} + scopeMetrics: + - metrics: + - description: Sum if ... + name: sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "4.1" + timeUnixNano: "1678390948395859000" + isMonotonic: true + scope: + name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/logs/multiple_metrics.yaml b/connector/sumconnector/testdata/logs/multiple_metrics.yaml new file mode 100644 index 000000000000..b147cd2cd6fc --- /dev/null +++ b/connector/sumconnector/testdata/logs/multiple_metrics.yaml @@ -0,0 +1,87 @@ +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: "6.1" + timeUnixNano: "1678390948396984000" + isMonotonic: true + - description: Sum if ... + name: sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "6.1" + timeUnixNano: "1678390948396984000" + isMonotonic: true + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector + - resource: {} + scopeMetrics: + - metrics: + - description: All logs Sum + name: sum.all + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "6.1" + timeUnixNano: "1678390948396992000" + isMonotonic: true + scope: + name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/logs/one_attribute.yaml b/connector/sumconnector/testdata/logs/one_attribute.yaml new file mode 100644 index 000000000000..e762e4a671be --- /dev/null +++ b/connector/sumconnector/testdata/logs/one_attribute.yaml @@ -0,0 +1,111 @@ +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: "4.1" + attributes: + - key: log.required + value: + stringValue: foo + timeUnixNano: "1678390948397419000" + - asDouble: "2" + attributes: + - key: log.required + value: + stringValue: notfoo + timeUnixNano: "1678390948397419000" + isMonotonic: true + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/logs/one_condition.yaml b/connector/sumconnector/testdata/logs/one_condition.yaml new file mode 100644 index 000000000000..2db00fc7f9f0 --- /dev/null +++ b/connector/sumconnector/testdata/logs/one_condition.yaml @@ -0,0 +1,41 @@ +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: "6.1" + timeUnixNano: "1678390948395244000" + isMonotonic: true + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector 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..604110e5dd9d --- /dev/null +++ b/connector/sumconnector/testdata/metrics/condition_and_attribute.yaml @@ -0,0 +1,61 @@ +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: "24.6" + attributes: + - key: datapoint.required + value: + stringValue: foo + timeUnixNano: "1678391923823222000" + - asDouble: "6" + attributes: + - key: datapoint.required + value: + stringValue: notfoo + timeUnixNano: "1678391923823222000" + isMonotonic: true + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector 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..436ebe3b2c99 --- /dev/null +++ b/connector/sumconnector/testdata/metrics/default_attribute_value.yaml @@ -0,0 +1,171 @@ +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: "25.2" + attributes: + - key: datapoint.required + value: + stringValue: foo + - key: datapoint.optional + value: + stringValue: bar + timeUnixNano: "1678391923822404000" + isMonotonic: true + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/metrics/input.yaml b/connector/sumconnector/testdata/metrics/input.yaml new file mode 100644 index 000000000000..f92aa2d647a1 --- /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: + 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.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..3d2738d928d3 --- /dev/null +++ b/connector/sumconnector/testdata/metrics/multiple_attributes.yaml @@ -0,0 +1,135 @@ +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: "25.2" + 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 + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/metrics/multiple_conditions.yaml b/connector/sumconnector/testdata/metrics/multiple_conditions.yaml new file mode 100644 index 000000000000..0f32d6f6d208 --- /dev/null +++ b/connector/sumconnector/testdata/metrics/multiple_conditions.yaml @@ -0,0 +1,71 @@ +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: "30.6" + timeUnixNano: "1678391923819487000" + isMonotonic: true + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector + - resource: {} + scopeMetrics: + - metrics: + - description: Data point sum if ... + name: datapoint.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "24.6" + timeUnixNano: "1678391923819529000" + isMonotonic: true + scope: + name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/metrics/multiple_metrics.yaml b/connector/sumconnector/testdata/metrics/multiple_metrics.yaml new file mode 100644 index 000000000000..48eab893b8bc --- /dev/null +++ b/connector/sumconnector/testdata/metrics/multiple_metrics.yaml @@ -0,0 +1,123 @@ +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: "30.6" + timeUnixNano: "1678391923820453000" + isMonotonic: true + - description: Data point sum if ... + name: datapoint.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "30.6" + timeUnixNano: "1678391923820453000" + isMonotonic: true + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/metrics/one_attribute.yaml b/connector/sumconnector/testdata/metrics/one_attribute.yaml new file mode 100644 index 000000000000..d28402103aa1 --- /dev/null +++ b/connector/sumconnector/testdata/metrics/one_attribute.yaml @@ -0,0 +1,111 @@ +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: "24.6" + attributes: + - key: datapoint.required + value: + stringValue: foo + timeUnixNano: "1678391923821179000" + - asDouble: "6" + attributes: + - key: datapoint.required + value: + stringValue: notfoo + timeUnixNano: "1678391923821179000" + isMonotonic: true + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/metrics/one_condition.yaml b/connector/sumconnector/testdata/metrics/one_condition.yaml new file mode 100644 index 000000000000..919887284515 --- /dev/null +++ b/connector/sumconnector/testdata/metrics/one_condition.yaml @@ -0,0 +1,41 @@ +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: "30.6" + timeUnixNano: "1678391923818482000" + isMonotonic: true + scope: + name: otelcol/sumconnector + - 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 + scope: + name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/traces/condition_and_attribute.yaml b/connector/sumconnector/testdata/traces/condition_and_attribute.yaml new file mode 100644 index 000000000000..2c3fc84de612 --- /dev/null +++ b/connector/sumconnector/testdata/traces/condition_and_attribute.yaml @@ -0,0 +1,97 @@ +resourceMetrics: + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: bar + scopeMetrics: + - metrics: + - description: Span sum if ... + name: span.sum.if.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "5.1" + attributes: + - key: span.required + value: + stringValue: foo + timeUnixNano: "1678392127929005000" + - asDouble: "3.1" + attributes: + - key: span.required + value: + stringValue: notfoo + timeUnixNano: "1678392127929005000" + isMonotonic: true + - description: Span event sum by attribute if ... + name: spanevent.sum.if.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "15" + attributes: + - key: event.required + value: + stringValue: foo + timeUnixNano: "1678392127929006000" + - asDouble: "8" + attributes: + - key: event.required + value: + stringValue: notfoo + timeUnixNano: "1678392127929006000" + isMonotonic: true + scope: + name: otelcol/sumconnector + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: notbar + scopeMetrics: + - metrics: + - description: Span sum if ... + name: span.sum.if.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "5.1" + attributes: + - key: span.required + value: + stringValue: foo + timeUnixNano: "1678392127929018000" + - asDouble: "3.1" + attributes: + - key: span.required + value: + stringValue: notfoo + timeUnixNano: "1678392127929018000" + isMonotonic: true + - description: Span event sum by attribute if ... + name: spanevent.sum.if.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "15" + attributes: + - key: event.required + value: + stringValue: foo + timeUnixNano: "1678392127929018000" + - asDouble: "8" + attributes: + - key: event.required + value: + stringValue: notfoo + timeUnixNano: "1678392127929018000" + isMonotonic: true + scope: + name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/traces/input.yaml b/connector/sumconnector/testdata/traces/input.yaml new file mode 100644 index 000000000000..ea357d4423d8 --- /dev/null +++ b/connector/sumconnector/testdata/traces/input.yaml @@ -0,0 +1,852 @@ +resourceSpans: + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: bar + scopeSpans: + - scope: {} + spans: + - name: span-with-attrs-foo-bar + parentSpanId: "" + spanId: "" + startTimeUnixNano: "1581452772000000321" + status: {} + traceId: "" + attributes: + - key: span.required + value: + stringValue: foo + - key: span.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + endTimeUnixNano: "1581452773000000789" + events: + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2 + name: event-with-attrs-foo-bar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + name: event-with-attrs-foo-notbar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: notfoo + - key: beep + value: + doubleValue: 2 + name: event-with-attr-notfoo + timeUnixNano: "1581452773000000123" + - name: event-with-no-attrs + timeUnixNano: "1581452773000000123" + + - name: span-with-attrs-foo-notbar + parentSpanId: "" + spanId: "" + startTimeUnixNano: "1581452772000000321" + status: {} + traceId: "" + attributes: + - key: span.required + value: + stringValue: foo + - key: span.optional + value: + stringValue: notbar + - key: beep + value: + intValue: 3 + endTimeUnixNano: "1581452773000000789" + events: + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: bar + - key: beep + value: + intValue: 2 + name: event-with-attrs-foo-bar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: notbar + - key: beep + value: + stringValue: "3" + name: event-with-attrs-foo-notbar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: notfoo + - key: beep + value: + doubleValue: 2 + name: event-with-attr-notfoo + timeUnixNano: "1581452773000000123" + - name: event-with-no-attrs + timeUnixNano: "1581452773000000123" + + - name: span-with-attr-notfoo + parentSpanId: "" + spanId: "" + startTimeUnixNano: "1581452772000000321" + status: {} + traceId: "" + attributes: + - key: span.required + value: + stringValue: notfoo + - key: beep + value: + doubleValue: 3.1 + endTimeUnixNano: "1581452773000000789" + events: + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2 + name: event-with-attrs-foo-bar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + name: event-with-attrs-foo-notbar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: notfoo + - key: beep + value: + doubleValue: 2 + name: event-with-attr-notfoo + timeUnixNano: "1581452773000000123" + - name: event-with-no-attrs + timeUnixNano: "1581452773000000123" + + - name: span-with-no-attrs + parentSpanId: "" + spanId: "" + startTimeUnixNano: "1581452772000000321" + status: {} + traceId: "" + attributes: + endTimeUnixNano: "1581452773000000789" + events: + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 1 + name: event-with-attrs-foo-bar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 1 + name: event-with-attrs-foo-notbar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: notfoo + - key: beep + value: + doubleValue: 2 + name: event-with-attr-notfoo + timeUnixNano: "1581452773000000123" + - name: event-with-no-attrs + timeUnixNano: "1581452773000000123" + + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: notbar + scopeSpans: + - scope: {} + spans: + - name: span-with-attrs-foo-bar + parentSpanId: "" + spanId: "" + startTimeUnixNano: "1581452772000000321" + status: {} + traceId: "" + attributes: + - key: span.required + value: + stringValue: foo + - key: span.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + endTimeUnixNano: "1581452773000000789" + events: + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2 + name: event-with-attrs-foo-bar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + name: event-with-attrs-foo-notbar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: notfoo + - key: beep + value: + doubleValue: 2 + name: event-with-attr-notfoo + timeUnixNano: "1581452773000000123" + - name: event-with-no-attrs + timeUnixNano: "1581452773000000123" + + - name: span-with-attrs-foo-notbar + parentSpanId: "" + spanId: "" + startTimeUnixNano: "1581452772000000321" + status: {} + traceId: "" + attributes: + - key: span.required + value: + stringValue: foo + - key: span.optional + value: + stringValue: notbar + - key: beep + value: + intValue: 3 + endTimeUnixNano: "1581452773000000789" + events: + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: bar + - key: beep + value: + intValue: 2 + name: event-with-attrs-foo-bar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: notbar + - key: beep + value: + stringValue: "3" + name: event-with-attrs-foo-notbar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: notfoo + - key: beep + value: + doubleValue: 2 + name: event-with-attr-notfoo + timeUnixNano: "1581452773000000123" + - name: event-with-no-attrs + timeUnixNano: "1581452773000000123" + + - name: span-with-attr-notfoo + parentSpanId: "" + spanId: "" + startTimeUnixNano: "1581452772000000321" + status: {} + traceId: "" + attributes: + - key: span.required + value: + stringValue: notfoo + - key: beep + value: + doubleValue: 3.1 + endTimeUnixNano: "1581452773000000789" + events: + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2 + name: event-with-attrs-foo-bar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + name: event-with-attrs-foo-notbar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: notfoo + - key: beep + value: + doubleValue: 2 + name: event-with-attr-notfoo + timeUnixNano: "1581452773000000123" + - name: event-with-no-attrs + timeUnixNano: "1581452773000000123" + + - name: span-with-no-attrs + parentSpanId: "" + spanId: "" + startTimeUnixNano: "1581452772000000321" + status: {} + traceId: "" + attributes: + endTimeUnixNano: "1581452773000000789" + events: + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 1 + name: event-with-attrs-foo-bar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 1 + name: event-with-attrs-foo-notbar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: notfoo + - key: beep + value: + doubleValue: 2 + name: event-with-attr-notfoo + timeUnixNano: "1581452773000000123" + - name: event-with-no-attrs + timeUnixNano: "1581452773000000123" + + - resource: + attributes: + - key: resource.required + value: + stringValue: notfoo + scopeSpans: + - scope: {} + spans: + - name: span-with-attrs-foo-bar + parentSpanId: "" + spanId: "" + startTimeUnixNano: "1581452772000000321" + status: {} + traceId: "" + attributes: + - key: span.required + value: + stringValue: foo + - key: span.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + endTimeUnixNano: "1581452773000000789" + events: + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2 + name: event-with-attrs-foo-bar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + name: event-with-attrs-foo-notbar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: notfoo + - key: beep + value: + doubleValue: 2 + name: event-with-attr-notfoo + timeUnixNano: "1581452773000000123" + - name: event-with-no-attrs + timeUnixNano: "1581452773000000123" + + - name: span-with-attrs-foo-notbar + parentSpanId: "" + spanId: "" + startTimeUnixNano: "1581452772000000321" + status: {} + traceId: "" + attributes: + - key: span.required + value: + stringValue: foo + - key: span.optional + value: + stringValue: notbar + - key: beep + value: + intValue: 3 + endTimeUnixNano: "1581452773000000789" + events: + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: bar + - key: beep + value: + intValue: 2 + name: event-with-attrs-foo-bar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: notbar + - key: beep + value: + stringValue: "3" + name: event-with-attrs-foo-notbar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: notfoo + - key: beep + value: + doubleValue: 2 + name: event-with-attr-notfoo + timeUnixNano: "1581452773000000123" + - name: event-with-no-attrs + timeUnixNano: "1581452773000000123" + + - name: span-with-attr-notfoo + parentSpanId: "" + spanId: "" + startTimeUnixNano: "1581452772000000321" + status: {} + traceId: "" + attributes: + - key: span.required + value: + stringValue: notfoo + - key: beep + value: + doubleValue: 3.1 + endTimeUnixNano: "1581452773000000789" + events: + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2 + name: event-with-attrs-foo-bar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + name: event-with-attrs-foo-notbar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: notfoo + - key: beep + value: + doubleValue: 2 + name: event-with-attr-notfoo + timeUnixNano: "1581452773000000123" + - name: event-with-no-attrs + timeUnixNano: "1581452773000000123" + + - name: span-with-no-attrs + parentSpanId: "" + spanId: "" + startTimeUnixNano: "1581452772000000321" + status: {} + traceId: "" + attributes: + endTimeUnixNano: "1581452773000000789" + events: + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 1 + name: event-with-attrs-foo-bar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 1 + name: event-with-attrs-foo-notbar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: notfoo + - key: beep + value: + doubleValue: 2 + name: event-with-attr-notfoo + timeUnixNano: "1581452773000000123" + - name: event-with-no-attrs + timeUnixNano: "1581452773000000123" + + - resource: {} + scopeSpans: + - scope: {} + spans: + - name: span-with-attrs-foo-bar + parentSpanId: "" + spanId: "" + startTimeUnixNano: "1581452772000000321" + status: {} + traceId: "" + attributes: + - key: span.required + value: + stringValue: foo + - key: span.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2.1 + endTimeUnixNano: "1581452773000000789" + events: + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2 + name: event-with-attrs-foo-bar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + name: event-with-attrs-foo-notbar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: notfoo + - key: beep + value: + doubleValue: 2 + name: event-with-attr-notfoo + timeUnixNano: "1581452773000000123" + - name: event-with-no-attrs + timeUnixNano: "1581452773000000123" + + - name: span-with-attrs-foo-notbar + parentSpanId: "" + spanId: "" + startTimeUnixNano: "1581452772000000321" + status: {} + traceId: "" + attributes: + - key: span.required + value: + stringValue: foo + - key: span.optional + value: + stringValue: notbar + - key: beep + value: + intValue: 3 + endTimeUnixNano: "1581452773000000789" + events: + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: bar + - key: beep + value: + intValue: 2 + name: event-with-attrs-foo-bar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: notbar + - key: beep + value: + stringValue: "3" + name: event-with-attrs-foo-notbar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: notfoo + - key: beep + value: + doubleValue: 2 + name: event-with-attr-notfoo + timeUnixNano: "1581452773000000123" + - name: event-with-no-attrs + timeUnixNano: "1581452773000000123" + + - name: span-with-attr-notfoo + parentSpanId: "" + spanId: "" + startTimeUnixNano: "1581452772000000321" + status: {} + traceId: "" + attributes: + - key: span.required + value: + stringValue: notfoo + - key: beep + value: + doubleValue: 3.1 + endTimeUnixNano: "1581452773000000789" + events: + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 2 + name: event-with-attrs-foo-bar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 2 + name: event-with-attrs-foo-notbar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: notfoo + - key: beep + value: + doubleValue: 2 + name: event-with-attr-notfoo + timeUnixNano: "1581452773000000123" + - name: event-with-no-attrs + timeUnixNano: "1581452773000000123" + + - name: span-with-no-attrs + parentSpanId: "" + spanId: "" + startTimeUnixNano: "1581452772000000321" + status: {} + traceId: "" + attributes: + endTimeUnixNano: "1581452773000000789" + events: + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: bar + - key: beep + value: + doubleValue: 1 + name: event-with-attrs-foo-bar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: notbar + - key: beep + value: + doubleValue: 1 + name: event-with-attrs-foo-notbar + timeUnixNano: "1581452773000000123" + - attributes: + - key: event.required + value: + stringValue: notfoo + - key: beep + value: + doubleValue: 2 + name: event-with-attr-notfoo + timeUnixNano: "1581452773000000123" + - name: event-with-no-attrs + timeUnixNano: "1581452773000000123" + + diff --git a/connector/sumconnector/testdata/traces/multiple_attributes.yaml b/connector/sumconnector/testdata/traces/multiple_attributes.yaml new file mode 100644 index 000000000000..ec02bdcfefe9 --- /dev/null +++ b/connector/sumconnector/testdata/traces/multiple_attributes.yaml @@ -0,0 +1,231 @@ +resourceMetrics: + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: bar + scopeMetrics: + - metrics: + - description: Span sum by attributes + name: span.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "6" + attributes: + - key: span.required + value: + stringValue: foo + - key: span.optional + value: + stringValue: notbar + timeUnixNano: "1678392127926637000" + - asDouble: "4.2" + attributes: + - key: span.required + value: + stringValue: foo + - key: span.optional + value: + stringValue: bar + timeUnixNano: "1678392127926637000" + isMonotonic: true + - description: Span event sum by attributes + name: spanevent.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "14" + attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: bar + timeUnixNano: "1678392127926637000" + - asDouble: "16" + attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: notbar + timeUnixNano: "1678392127926637000" + isMonotonic: true + scope: + name: otelcol/sumconnector + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: notbar + scopeMetrics: + - metrics: + - description: Span sum by attributes + name: span.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "4.2" + attributes: + - key: span.required + value: + stringValue: foo + - key: span.optional + value: + stringValue: bar + timeUnixNano: "1678392127926647000" + - asDouble: "6" + attributes: + - key: span.required + value: + stringValue: foo + - key: span.optional + value: + stringValue: notbar + timeUnixNano: "1678392127926647000" + isMonotonic: true + - description: Span event sum by attributes + name: spanevent.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "14" + attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: bar + timeUnixNano: "1678392127926647000" + - asDouble: "16" + attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: notbar + timeUnixNano: "1678392127926647000" + isMonotonic: true + scope: + name: otelcol/sumconnector + - resource: + attributes: + - key: resource.required + value: + stringValue: notfoo + scopeMetrics: + - metrics: + - description: Span sum by attributes + name: span.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "4.2" + attributes: + - key: span.required + value: + stringValue: foo + - key: span.optional + value: + stringValue: bar + timeUnixNano: "1678392127926654000" + - asDouble: "6" + attributes: + - key: span.required + value: + stringValue: foo + - key: span.optional + value: + stringValue: notbar + timeUnixNano: "1678392127926654000" + isMonotonic: true + - description: Span event sum by attributes + name: spanevent.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "14" + attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: bar + timeUnixNano: "1678392127926654000" + - asDouble: "16" + attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: notbar + timeUnixNano: "1678392127926654000" + isMonotonic: true + scope: + name: otelcol/sumconnector + - resource: {} + scopeMetrics: + - metrics: + - description: Span sum by attributes + name: span.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "4.2" + attributes: + - key: span.required + value: + stringValue: foo + - key: span.optional + value: + stringValue: bar + timeUnixNano: "1678392127926661000" + - asDouble: "6" + attributes: + - key: span.required + value: + stringValue: foo + - key: span.optional + value: + stringValue: notbar + timeUnixNano: "1678392127926661000" + isMonotonic: true + - description: Span event sum by attributes + name: spanevent.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "14" + attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: bar + timeUnixNano: "1678392127926661000" + - asDouble: "16" + attributes: + - key: event.required + value: + stringValue: foo + - key: event.optional + value: + stringValue: notbar + timeUnixNano: "1678392127926661000" + isMonotonic: true + scope: + name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/traces/multiple_conditions.yaml b/connector/sumconnector/testdata/traces/multiple_conditions.yaml new file mode 100644 index 000000000000..55e4021be53e --- /dev/null +++ b/connector/sumconnector/testdata/traces/multiple_conditions.yaml @@ -0,0 +1,103 @@ +resourceMetrics: + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: bar + scopeMetrics: + - metrics: + - description: Span sum if ... + name: span.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "8.2" + timeUnixNano: "1678392127923826000" + isMonotonic: true + - description: Span event sum if ... + name: spanevent.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "23" + timeUnixNano: "1678392127923826000" + isMonotonic: true + scope: + name: otelcol/sumconnector + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: notbar + scopeMetrics: + - metrics: + - description: Span sum if ... + name: span.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "8.2" + timeUnixNano: "1678392127923836000" + isMonotonic: true + - description: Span event sum if ... + name: spanevent.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "23" + timeUnixNano: "1678392127923836000" + isMonotonic: true + scope: + name: otelcol/sumconnector + - resource: + attributes: + - key: resource.required + value: + stringValue: notfoo + scopeMetrics: + - metrics: + - description: Span sum if ... + name: span.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "5.1" + timeUnixNano: "1678392127923843000" + isMonotonic: true + - description: Span event sum if ... + name: spanevent.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "15" + timeUnixNano: "1678392127923843000" + isMonotonic: true + scope: + name: otelcol/sumconnector + - resource: {} + scopeMetrics: + - metrics: + - description: Span sum if ... + name: span.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "5.1" + timeUnixNano: "1678392127923849000" + isMonotonic: true + - description: Span event sum if ... + name: spanevent.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "15" + timeUnixNano: "1678392127923849000" + isMonotonic: true + scope: + name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/traces/multiple_metrics.yaml b/connector/sumconnector/testdata/traces/multiple_metrics.yaml new file mode 100644 index 000000000000..4f6fba85a388 --- /dev/null +++ b/connector/sumconnector/testdata/traces/multiple_metrics.yaml @@ -0,0 +1,167 @@ +resourceMetrics: + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: bar + scopeMetrics: + - metrics: + - description: All spans sum + name: span.sum.all + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "8.2" + timeUnixNano: "1678392127924753000" + isMonotonic: true + - description: Span sum if ... + name: span.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "8.2" + timeUnixNano: "1678392127924753000" + isMonotonic: true + - description: All span events sum + name: spanevent.sum.all + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "23" + timeUnixNano: "1678392127924753000" + isMonotonic: true + - description: Span event sum if ... + name: spanevent.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "23" + timeUnixNano: "1678392127924753000" + isMonotonic: true + scope: + name: otelcol/sumconnector + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: notbar + scopeMetrics: + - metrics: + - description: All spans sum + name: span.sum.all + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "8.2" + timeUnixNano: "1678392127924764000" + isMonotonic: true + - description: Span sum if ... + name: span.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "8.2" + timeUnixNano: "1678392127924764000" + isMonotonic: true + - description: All span events sum + name: spanevent.sum.all + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "23" + timeUnixNano: "1678392127924764000" + isMonotonic: true + - description: Span event sum if ... + name: spanevent.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "23" + timeUnixNano: "1678392127924764000" + isMonotonic: true + scope: + name: otelcol/sumconnector + - resource: + attributes: + - key: resource.required + value: + stringValue: notfoo + scopeMetrics: + - metrics: + - description: All spans sum + name: span.sum.all + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "8.2" + timeUnixNano: "1678392127924772000" + isMonotonic: true + - description: Span sum if ... + name: span.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "5.1" + timeUnixNano: "1678392127924772000" + isMonotonic: true + - description: All span events sum + name: spanevent.sum.all + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "23" + timeUnixNano: "1678392127924772000" + isMonotonic: true + - description: Span event sum if ... + name: spanevent.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "15" + timeUnixNano: "1678392127924772000" + isMonotonic: true + scope: + name: otelcol/sumconnector + - resource: {} + scopeMetrics: + - metrics: + - description: All spans sum + name: span.sum.all + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "8.2" + timeUnixNano: "1678392127924780000" + isMonotonic: true + - description: Span sum if ... + name: span.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "5.1" + timeUnixNano: "1678392127924780000" + isMonotonic: true + - description: All span events sum + name: spanevent.sum.all + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "23" + timeUnixNano: "1678392127924780000" + isMonotonic: true + - description: Span event sum if ... + name: spanevent.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "15" + timeUnixNano: "1678392127924780000" + isMonotonic: true + scope: + name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/traces/one_attribute.yaml b/connector/sumconnector/testdata/traces/one_attribute.yaml new file mode 100644 index 000000000000..549fa408ab9a --- /dev/null +++ b/connector/sumconnector/testdata/traces/one_attribute.yaml @@ -0,0 +1,186 @@ +resourceMetrics: + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: bar + scopeMetrics: + - metrics: + - description: Span sum by attribute + name: span.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "5.1" + attributes: + - key: span.required + value: + stringValue: foo + timeUnixNano: "1678392127925459000" + - asDouble: "3.1" + attributes: + - key: span.required + value: + stringValue: notfoo + timeUnixNano: "1678392127925459000" + isMonotonic: true + - description: Span event sum by attribute + name: spanevent.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "15" + attributes: + - key: event.required + value: + stringValue: foo + timeUnixNano: "1678392127925459000" + - asDouble: "8" + attributes: + - key: event.required + value: + stringValue: notfoo + timeUnixNano: "1678392127925459000" + isMonotonic: true + scope: + name: otelcol/sumconnector + + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: notbar + scopeMetrics: + - metrics: + - description: Span sum by attribute + name: span.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "5.1" + attributes: + - key: span.required + value: + stringValue: foo + timeUnixNano: "1678392127925459000" + - asDouble: "3.1" + attributes: + - key: span.required + value: + stringValue: notfoo + timeUnixNano: "1678392127925459000" + isMonotonic: true + - description: Span event sum by attribute + name: spanevent.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "15" + attributes: + - key: event.required + value: + stringValue: foo + timeUnixNano: "1678392127925459000" + - asDouble: "8" + attributes: + - key: event.required + value: + stringValue: notfoo + timeUnixNano: "1678392127925459000" + isMonotonic: true + scope: + name: otelcol/sumconnector + + - resource: + attributes: + - key: resource.required + value: + stringValue: notfoo + scopeMetrics: + - metrics: + - description: Span sum by attribute + name: span.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "5.1" + attributes: + - key: span.required + value: + stringValue: foo + timeUnixNano: "1678392127925459000" + - asDouble: "3.1" + attributes: + - key: span.required + value: + stringValue: notfoo + timeUnixNano: "1678392127925459000" + isMonotonic: true + - description: Span event sum by attribute + name: spanevent.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "15" + attributes: + - key: event.required + value: + stringValue: foo + timeUnixNano: "1678392127925459000" + - asDouble: "8" + attributes: + - key: event.required + value: + stringValue: notfoo + timeUnixNano: "1678392127925459000" + isMonotonic: true + scope: + name: otelcol/sumconnector + + - resource: {} + scopeMetrics: + - metrics: + - description: Span sum by attribute + name: span.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "5.1" + attributes: + - key: span.required + value: + stringValue: foo + timeUnixNano: "1678392127925459000" + - asDouble: "3.1" + attributes: + - key: span.required + value: + stringValue: notfoo + timeUnixNano: "1678392127925459000" + isMonotonic: true + - description: Span event sum by attribute + name: spanevent.sum.by_attr + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "15" + attributes: + - key: event.required + value: + stringValue: foo + timeUnixNano: "1678392127925459000" + - asDouble: "8" + attributes: + - key: event.required + value: + stringValue: notfoo + timeUnixNano: "1678392127925459000" + isMonotonic: true + scope: + name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/traces/one_condition.yaml b/connector/sumconnector/testdata/traces/one_condition.yaml new file mode 100644 index 000000000000..ac83f4fc7abf --- /dev/null +++ b/connector/sumconnector/testdata/traces/one_condition.yaml @@ -0,0 +1,57 @@ +resourceMetrics: + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: bar + scopeMetrics: + - metrics: + - description: Span sum if ... + name: span.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "8.2" + timeUnixNano: "1678392127922309000" + isMonotonic: true + - description: Span event sum if ... + name: spanevent.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "23" + timeUnixNano: "1678392127922310000" + isMonotonic: true + scope: + name: otelcol/sumconnector + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: notbar + scopeMetrics: + - metrics: + - description: Span sum if ... + name: span.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "8.2" + timeUnixNano: "1678392127922363000" + isMonotonic: true + - description: Span event sum if ... + name: spanevent.sum.if + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "23" + timeUnixNano: "1678392127922364000" + isMonotonic: true + scope: + name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/traces/zero_conditions.yaml b/connector/sumconnector/testdata/traces/zero_conditions.yaml new file mode 100644 index 000000000000..fb3bbc09aa5a --- /dev/null +++ b/connector/sumconnector/testdata/traces/zero_conditions.yaml @@ -0,0 +1,103 @@ +resourceMetrics: + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: bar + scopeMetrics: + - metrics: + - description: The sum of beep values observed in spans. + name: trace.span.sum + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "8.2" + timeUnixNano: "1678392127920605000" + isMonotonic: true + - description: The sum of beep values observed in span events. + name: trace.span.event.sum + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "23" + timeUnixNano: "1678392127920605000" + isMonotonic: true + scope: + name: otelcol/sumconnector + - resource: + attributes: + - key: resource.required + value: + stringValue: foo + - key: resource.optional + value: + stringValue: notbar + scopeMetrics: + - metrics: + - description: The sum of beep values observed in spans. + name: trace.span.sum + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "8.2" + timeUnixNano: "1678392127920632000" + isMonotonic: true + - description: The sum of beep values observed in span events. + name: trace.span.event.sum + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "23" + timeUnixNano: "1678392127920632000" + isMonotonic: true + scope: + name: otelcol/sumconnector + - resource: + attributes: + - key: resource.required + value: + stringValue: notfoo + scopeMetrics: + - metrics: + - description: The sum of beep values observed in spans. + name: trace.span.sum + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "8.2" + timeUnixNano: "1678392127920635000" + isMonotonic: true + - description: The sum of beep values observed in span events. + name: trace.span.event.sum + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "23" + timeUnixNano: "1678392127920635000" + isMonotonic: true + scope: + name: otelcol/sumconnector + - resource: {} + scopeMetrics: + - metrics: + - description: The sum of beep values observed in spans. + name: trace.span.sum + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "8.2" + timeUnixNano: "1678392127920638000" + isMonotonic: true + - description: The sum of beep values observed in span events. + name: trace.span.event.sum + sum: + aggregationTemporality: 1 + dataPoints: + - asDouble: "23" + timeUnixNano: "1678392127920638000" + isMonotonic: true + scope: + name: otelcol/sumconnector From 0854f8551fec6a11307d54767a13ed17a948fbdf Mon Sep 17 00:00:00 2001 From: jeremyh Date: Wed, 21 Aug 2024 14:59:44 -0400 Subject: [PATCH 03/15] changelog and make generate --- .chloggen/32669-sumconnector-sum-logic.yaml | 27 +++++++++++++++++++ .../internal/metadata/generated_status.go | 3 ++- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 .chloggen/32669-sumconnector-sum-logic.yaml diff --git a/.chloggen/32669-sumconnector-sum-logic.yaml b/.chloggen/32669-sumconnector-sum-logic.yaml new file mode 100644 index 000000000000..55917c0576f8 --- /dev/null +++ b/.chloggen/32669-sumconnector-sum-logic.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: 'breaking' + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: 'sumconnector' + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: "adds connector and summing logic along with tests" + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [32669] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [user, api] diff --git a/connector/sumconnector/internal/metadata/generated_status.go b/connector/sumconnector/internal/metadata/generated_status.go index 93382f53d902..ef0868cd8aae 100644 --- a/connector/sumconnector/internal/metadata/generated_status.go +++ b/connector/sumconnector/internal/metadata/generated_status.go @@ -7,7 +7,8 @@ import ( ) var ( - Type = component.MustNewType("sum") + Type = component.MustNewType("sum") + ScopeName = "otelcol/sumconnector" ) const ( From 9ad7238945b16907b5668d87504bd19b65e97e78 Mon Sep 17 00:00:00 2001 From: jeremyh Date: Thu, 22 Aug 2024 09:32:11 -0400 Subject: [PATCH 04/15] fix collector subversion --- connector/sumconnector/go.mod | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/connector/sumconnector/go.mod b/connector/sumconnector/go.mod index 9213f78f173f..ac9af874c109 100644 --- a/connector/sumconnector/go.mod +++ b/connector/sumconnector/go.mod @@ -13,7 +13,7 @@ require ( github.com/stretchr/testify v1.9.0 go.opentelemetry.io/collector/component v0.107.1-0.20240821120936-6764622672bc go.opentelemetry.io/collector/confmap v0.107.1-0.20240821120936-6764622672bc - go.opentelemetry.io/collector/connector v0.106.1 + go.opentelemetry.io/collector/connector v0.107.1-0.20240821120936-6764622672bc go.opentelemetry.io/collector/consumer v0.107.1-0.20240821120936-6764622672bc go.opentelemetry.io/collector/consumer/consumertest v0.107.1-0.20240821120936-6764622672bc go.opentelemetry.io/collector/pdata v1.13.1-0.20240821120936-6764622672bc @@ -54,7 +54,7 @@ require ( github.com/prometheus/common v0.55.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect github.com/ua-parser/uap-go v0.0.0-20240611065828-3a4781585db6 // indirect - go.opentelemetry.io/collector v0.106.1 // indirect + go.opentelemetry.io/collector/connector v0.107.1-0.20240821120936-6764622672bc // indirect go.opentelemetry.io/collector/config/configtelemetry v0.107.1-0.20240821120936-6764622672bc // indirect go.opentelemetry.io/collector/consumer/consumerprofiles v0.107.1-0.20240821120936-6764622672bc // indirect go.opentelemetry.io/collector/pdata/pprofile v0.107.1-0.20240821120936-6764622672bc // indirect From d3ad724c92088fd0e1cbe528657980a1c4bf3b71 Mon Sep 17 00:00:00 2001 From: jeremyh Date: Thu, 22 Aug 2024 11:21:33 -0400 Subject: [PATCH 05/15] gotidy golint etc --- connector/sumconnector/go.mod | 3 ++- connector/sumconnector/go.sum | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/connector/sumconnector/go.mod b/connector/sumconnector/go.mod index ac9af874c109..8eb21d6703a7 100644 --- a/connector/sumconnector/go.mod +++ b/connector/sumconnector/go.mod @@ -54,7 +54,8 @@ require ( github.com/prometheus/common v0.55.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect github.com/ua-parser/uap-go v0.0.0-20240611065828-3a4781585db6 // indirect - go.opentelemetry.io/collector/connector v0.107.1-0.20240821120936-6764622672bc // indirect + go.opentelemetry.io/collector v0.107.0 // indirect + go.opentelemetry.io/collector/component/componentprofiles v0.107.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.107.1-0.20240821120936-6764622672bc // indirect go.opentelemetry.io/collector/consumer/consumerprofiles v0.107.1-0.20240821120936-6764622672bc // indirect go.opentelemetry.io/collector/pdata/pprofile v0.107.1-0.20240821120936-6764622672bc // indirect diff --git a/connector/sumconnector/go.sum b/connector/sumconnector/go.sum index 8c6d0f63ca35..9359fcbb2dfa 100644 --- a/connector/sumconnector/go.sum +++ b/connector/sumconnector/go.sum @@ -88,16 +88,18 @@ github.com/ua-parser/uap-go v0.0.0-20240611065828-3a4781585db6 h1:SIKIoA4e/5Y9ZO github.com/ua-parser/uap-go v0.0.0-20240611065828-3a4781585db6/go.mod h1:BUbeWZiieNxAuuADTBNb3/aeje6on3DhU3rpWsQSB1E= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.opentelemetry.io/collector v0.106.1 h1:ZSQMpFGzFP3RILe1/+K80kCCT2ahn3MKt5e3u0Yz7Rs= -go.opentelemetry.io/collector v0.106.1/go.mod h1:1FabMxWLluLNcC0dq8cI01GaE6t6fYxE6Oxuf8u7AGQ= +go.opentelemetry.io/collector v0.107.0 h1:C1Mng03iE73flGhEg795IFVlr3qhDLef5GESjIVtx5g= +go.opentelemetry.io/collector v0.107.0/go.mod h1:7xDYvzBb3Ez6qFQl0IArBbmNNazIxZMVoRkbgJYRjyg= go.opentelemetry.io/collector/component v0.107.1-0.20240821120936-6764622672bc h1:g2ZH4rsZ3RaPwaY8w8IawP2nDC0IIDK8FJyS1Dr68JM= go.opentelemetry.io/collector/component v0.107.1-0.20240821120936-6764622672bc/go.mod h1:gfntGv2c1Zvc9juFwe9PFX6IxNkkibA9VZb67KJqx9Y= +go.opentelemetry.io/collector/component/componentprofiles v0.107.0 h1:6RB6n4HqTbj+ux0SuaLV3egrzFkqjhU4ceWqxN8dOVk= +go.opentelemetry.io/collector/component/componentprofiles v0.107.0/go.mod h1:7yFxZsS0nrFs/N3bdNSHg7ENs7nYRoaZXYsyuLvQG6g= go.opentelemetry.io/collector/config/configtelemetry v0.107.1-0.20240821120936-6764622672bc h1:/KTt1JrsrAnjIVas8I+ULnXGzKX2Uyp4o/DMqSxrc9Q= go.opentelemetry.io/collector/config/configtelemetry v0.107.1-0.20240821120936-6764622672bc/go.mod h1:R0MBUxjSMVMIhljuDHWIygzzJWQyZHXXWIgQNxcFwhc= go.opentelemetry.io/collector/confmap v0.107.1-0.20240821120936-6764622672bc h1:do58ygb12Zt3//CBAGtrZBjxZkZbnx+y5QSMTDOF7XU= go.opentelemetry.io/collector/confmap v0.107.1-0.20240821120936-6764622672bc/go.mod h1:GrIZ12P/9DPOuTpe2PIS51a0P/ZM6iKtByVee1Uf3+k= -go.opentelemetry.io/collector/connector v0.106.1 h1:sgPSyzqKBuxo7qz+kTfa6GxSAtt0T6H9mwdm9VDYObA= -go.opentelemetry.io/collector/connector v0.106.1/go.mod h1:HpQIfCV9j72XjdnF0g+V4W064dy0Qu63hlb84rAXPZ4= +go.opentelemetry.io/collector/connector v0.107.1-0.20240821120936-6764622672bc h1:zmlXZLgjLrrcmlyx1gwrcvYxpOJY9A8CMo6xzz4LaR0= +go.opentelemetry.io/collector/connector v0.107.1-0.20240821120936-6764622672bc/go.mod h1:4jSz/K8GpSVQE9N1dZIm0MVgySjZ+h22aC0GjnsoNgI= go.opentelemetry.io/collector/consumer v0.107.1-0.20240821120936-6764622672bc h1:81GkskkDn4B07yC9kUXlKUqGNNQim4mFShwdYlGesCo= go.opentelemetry.io/collector/consumer v0.107.1-0.20240821120936-6764622672bc/go.mod h1:eNdgFcd4kPmFcNi6b1A9rCvaWr/9mXnKOb2qS/YC6ec= go.opentelemetry.io/collector/consumer/consumerprofiles v0.107.1-0.20240821120936-6764622672bc h1:ttI2LUPSQlyH4E6Ms4PDyyh04SMx45+ZxfSkGU+/XNU= From 37a22a0d66815a43cb2e061c555d00e1962fdf6b Mon Sep 17 00:00:00 2001 From: jeremyh Date: Tue, 3 Sep 2024 20:49:28 -0400 Subject: [PATCH 06/15] slim down to just trace and span for testing --- .chloggen/32669-sumconnector-sum-logic.yaml | 2 +- connector/sumconnector/README.md | 2 + connector/sumconnector/connector.go | 5 - connector/sumconnector/connector_test.go | 356 +---- connector/sumconnector/go.mod | 3 + .../internal/metadata/generated_status.go | 2 +- connector/sumconnector/metadata.yaml | 1 - connector/sumconnector/sum.go | 12 +- .../logs/condition_and_attribute.yaml | 61 - .../logs/default_attribute_value.yaml | 171 -- .../sumconnector/testdata/logs/input.yaml | 223 --- .../testdata/logs/multiple_attributes.yaml | 135 -- .../testdata/logs/multiple_conditions.yaml | 71 - .../testdata/logs/multiple_metrics.yaml | 87 -- .../testdata/logs/one_attribute.yaml | 111 -- .../testdata/logs/one_condition.yaml | 41 - .../metrics/condition_and_attribute.yaml | 61 - .../metrics/default_attribute_value.yaml | 171 -- .../sumconnector/testdata/metrics/input.yaml | 1390 ----------------- .../testdata/metrics/multiple_attributes.yaml | 135 -- .../testdata/metrics/multiple_conditions.yaml | 71 - .../testdata/metrics/multiple_metrics.yaml | 123 -- .../testdata/metrics/one_attribute.yaml | 111 -- .../testdata/metrics/one_condition.yaml | 41 - .../traces/condition_and_attribute.yaml | 6 +- .../testdata/traces/multiple_attributes.yaml | 12 +- .../testdata/traces/multiple_conditions.yaml | 12 +- .../testdata/traces/multiple_metrics.yaml | 12 +- .../testdata/traces/one_attribute.yaml | 12 +- .../testdata/traces/one_condition.yaml | 6 +- .../testdata/traces/zero_conditions.yaml | 12 +- 31 files changed, 38 insertions(+), 3420 deletions(-) delete mode 100644 connector/sumconnector/testdata/logs/condition_and_attribute.yaml delete mode 100644 connector/sumconnector/testdata/logs/default_attribute_value.yaml delete mode 100644 connector/sumconnector/testdata/logs/input.yaml delete mode 100644 connector/sumconnector/testdata/logs/multiple_attributes.yaml delete mode 100644 connector/sumconnector/testdata/logs/multiple_conditions.yaml delete mode 100644 connector/sumconnector/testdata/logs/multiple_metrics.yaml delete mode 100644 connector/sumconnector/testdata/logs/one_attribute.yaml delete mode 100644 connector/sumconnector/testdata/logs/one_condition.yaml delete mode 100644 connector/sumconnector/testdata/metrics/condition_and_attribute.yaml delete mode 100644 connector/sumconnector/testdata/metrics/default_attribute_value.yaml delete mode 100644 connector/sumconnector/testdata/metrics/input.yaml delete mode 100644 connector/sumconnector/testdata/metrics/multiple_attributes.yaml delete mode 100644 connector/sumconnector/testdata/metrics/multiple_conditions.yaml delete mode 100644 connector/sumconnector/testdata/metrics/multiple_metrics.yaml delete mode 100644 connector/sumconnector/testdata/metrics/one_attribute.yaml delete mode 100644 connector/sumconnector/testdata/metrics/one_condition.yaml diff --git a/.chloggen/32669-sumconnector-sum-logic.yaml b/.chloggen/32669-sumconnector-sum-logic.yaml index 55917c0576f8..95f76a6a9e16 100644 --- a/.chloggen/32669-sumconnector-sum-logic.yaml +++ b/.chloggen/32669-sumconnector-sum-logic.yaml @@ -1,7 +1,7 @@ # Use this changelog template to create an entry for release notes. # One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' -change_type: 'breaking' +change_type: 'enhancement' # The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) component: 'sumconnector' diff --git a/connector/sumconnector/README.md b/connector/sumconnector/README.md index 105783c17e1a..8204e5d20fc5 100644 --- a/connector/sumconnector/README.md +++ b/connector/sumconnector/README.md @@ -33,6 +33,8 @@ If you are not already familiar with connectors, you may find it helpful to firs This configuration will sum numerical values found within the attribute `attribute.with.numerical.value` of any log telemetry routed to the connector. It will then output a metric time series with the name `my.example.metric.name` with those summed values. +Note: Values found within an attribute will be converted into a float regardless of their original type before being summed and output as a metric value. Non-convertable strings will be dropped and not included. + ```yaml receivers: foo: diff --git a/connector/sumconnector/connector.go b/connector/sumconnector/connector.go index fe9f44440dca..fd8e5e09224c 100644 --- a/connector/sumconnector/connector.go +++ b/connector/sumconnector/connector.go @@ -22,8 +22,6 @@ import ( "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/ottlspanevent" ) -const scopeName = "otelcol/sumconnector" - // sum can sum attribute values from spans, span event, metrics, data points, or log records // and emit the sums onto a metrics pipeline. type sum struct { @@ -76,7 +74,6 @@ func (c *sum) ConsumeTraces(ctx context.Context, td ptrace.Traces) error { sumResource.ScopeMetrics().EnsureCapacity(resourceSpan.ScopeSpans().Len()) sumScope := sumResource.ScopeMetrics().AppendEmpty() - sumScope.Scope().SetName(scopeName) spansSummer.appendMetricsTo(sumScope.Metrics()) spanEventsSummer.appendMetricsTo(sumScope.Metrics()) @@ -151,7 +148,6 @@ func (c *sum) ConsumeMetrics(ctx context.Context, md pmetric.Metrics) error { sumResource.ScopeMetrics().EnsureCapacity(resourceMetric.ScopeMetrics().Len()) sumScope := sumResource.ScopeMetrics().AppendEmpty() - sumScope.Scope().SetName(scopeName) metricsSummer.appendMetricsTo(sumScope.Metrics()) dataPointsSummer.appendMetricsTo(sumScope.Metrics()) @@ -190,7 +186,6 @@ func (c *sum) ConsumeLogs(ctx context.Context, ld plog.Logs) error { sumResource.ScopeMetrics().EnsureCapacity(resourceLog.ScopeLogs().Len()) sumScope := sumResource.ScopeMetrics().AppendEmpty() - sumScope.Scope().SetName(scopeName) summer.appendMetricsTo(sumScope.Metrics()) } diff --git a/connector/sumconnector/connector_test.go b/connector/sumconnector/connector_test.go index 5eb8e1d1639d..da50b2540878 100644 --- a/connector/sumconnector/connector_test.go +++ b/connector/sumconnector/connector_test.go @@ -256,7 +256,7 @@ func TestTracesToMetrics(t *testing.T) { assert.NoError(t, conn.ConsumeTraces(context.Background(), testSpans)) allMetrics := sink.AllMetrics() - assert.Equal(t, 1, len(allMetrics)) + assert.Len(t, allMetrics, 1) expected, err := golden.ReadMetrics(filepath.Join("testdata", "traces", tc.name+".yaml")) assert.NoError(t, err) @@ -268,357 +268,3 @@ 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.Equal(t, 1, len(allMetrics)) - - 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.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.Equal(t, 1, len(allMetrics)) - - 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.IgnoreMetricDataPointsOrder())) - }) - } -} diff --git a/connector/sumconnector/go.mod b/connector/sumconnector/go.mod index 0905c1885cf8..bfffaaca4fe5 100644 --- a/connector/sumconnector/go.mod +++ b/connector/sumconnector/go.mod @@ -6,7 +6,10 @@ toolchain go1.22.1 require ( github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter v0.108.0 + github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden v0.108.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl v0.108.0 + github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.108.0 + github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.108.0 github.com/stretchr/testify v1.9.0 go.opentelemetry.io/collector/component v0.108.2-0.20240829190554-7da6b618a7ee go.opentelemetry.io/collector/confmap v1.14.2-0.20240829190554-7da6b618a7ee diff --git a/connector/sumconnector/internal/metadata/generated_status.go b/connector/sumconnector/internal/metadata/generated_status.go index ef0868cd8aae..d4155ac3e40a 100644 --- a/connector/sumconnector/internal/metadata/generated_status.go +++ b/connector/sumconnector/internal/metadata/generated_status.go @@ -8,7 +8,7 @@ import ( var ( Type = component.MustNewType("sum") - ScopeName = "otelcol/sumconnector" + ScopeName = "github.com/open-telemetry/opentelemetry-collector-contrib/connector/sumconnector" ) const ( diff --git a/connector/sumconnector/metadata.yaml b/connector/sumconnector/metadata.yaml index fdbb70077050..42a50533af3d 100644 --- a/connector/sumconnector/metadata.yaml +++ b/connector/sumconnector/metadata.yaml @@ -1,5 +1,4 @@ type: sum -scope_name: otelcol/sumconnector status: class: connector diff --git a/connector/sumconnector/sum.go b/connector/sumconnector/sum.go index 22a3fce0a0f6..50be604790cd 100644 --- a/connector/sumconnector/sum.go +++ b/connector/sumconnector/sum.go @@ -19,10 +19,6 @@ import ( var noAttributes = [16]byte{} -func roundFloat(val float64) float64 { - return math.Round(val*100000) / 100000 -} - func newSummer[K any](metricDefs map[string]metricDef[K]) *summer[K] { return &summer[K]{ metricDefs: metricDefs, @@ -61,7 +57,7 @@ func (c *summer[K]) update(ctx context.Context, attrs pcommon.Map, tCtx K) error } } - // Get attribute values to include otherwise include default value + // Get attribute values to include otherwise use default value for _, attr := range md.attrs { if attrVal, ok := attrs.Get(attr.Key); ok { switch { @@ -137,6 +133,10 @@ func (c *summer[K]) increment(metricName string, sumVal float64, attrs pcommon.M return nil } +func reduceFloatPrecision(val float64) float64 { + return math.Round(val*100000) / 100000 +} + func (c *summer[K]) appendMetricsTo(metricSlice pmetric.MetricSlice) { for name, md := range c.metricDefs { if len(c.sums[name]) == 0 { @@ -152,7 +152,7 @@ func (c *summer[K]) appendMetricsTo(metricSlice pmetric.MetricSlice) { for _, dpSum := range c.sums[name] { dp := sum.DataPoints().AppendEmpty() dpSum.attrs.CopyTo(dp.Attributes()) - dp.SetDoubleValue(roundFloat(dpSum.sum)) + dp.SetDoubleValue(reduceFloatPrecision(dpSum.sum)) dp.SetTimestamp(pcommon.NewTimestampFromTime(c.timestamp)) } } diff --git a/connector/sumconnector/testdata/logs/condition_and_attribute.yaml b/connector/sumconnector/testdata/logs/condition_and_attribute.yaml deleted file mode 100644 index 7baf26c31c13..000000000000 --- a/connector/sumconnector/testdata/logs/condition_and_attribute.yaml +++ /dev/null @@ -1,61 +0,0 @@ -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: "4.1" - attributes: - - key: log.required - value: - stringValue: foo - timeUnixNano: "1678390948399018000" - - asDouble: "2" - attributes: - - key: log.required - value: - stringValue: notfoo - timeUnixNano: "1678390948399018000" - isMonotonic: true - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/logs/default_attribute_value.yaml b/connector/sumconnector/testdata/logs/default_attribute_value.yaml deleted file mode 100644 index 5c5157c86827..000000000000 --- a/connector/sumconnector/testdata/logs/default_attribute_value.yaml +++ /dev/null @@ -1,171 +0,0 @@ -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: "4" - 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 - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/logs/input.yaml b/connector/sumconnector/testdata/logs/input.yaml deleted file mode 100644 index 61a1f039b9ef..000000000000 --- a/connector/sumconnector/testdata/logs/input.yaml +++ /dev/null @@ -1,223 +0,0 @@ -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: - 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: 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 deleted file mode 100644 index ac6ce90bdf19..000000000000 --- a/connector/sumconnector/testdata/logs/multiple_attributes.yaml +++ /dev/null @@ -1,135 +0,0 @@ -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: "4" - attributes: - - key: log.required - value: - stringValue: foo - - key: log.optional - value: - stringValue: notbar - timeUnixNano: "1678390948397879000" - isMonotonic: true - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/logs/multiple_conditions.yaml b/connector/sumconnector/testdata/logs/multiple_conditions.yaml deleted file mode 100644 index e8a2ed9680d3..000000000000 --- a/connector/sumconnector/testdata/logs/multiple_conditions.yaml +++ /dev/null @@ -1,71 +0,0 @@ -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: "6.1" - timeUnixNano: "1678390948395853000" - isMonotonic: true - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector - - resource: {} - scopeMetrics: - - metrics: - - description: Sum if ... - name: sum.if - sum: - aggregationTemporality: 1 - dataPoints: - - asDouble: "4.1" - timeUnixNano: "1678390948395859000" - isMonotonic: true - scope: - name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/logs/multiple_metrics.yaml b/connector/sumconnector/testdata/logs/multiple_metrics.yaml deleted file mode 100644 index b147cd2cd6fc..000000000000 --- a/connector/sumconnector/testdata/logs/multiple_metrics.yaml +++ /dev/null @@ -1,87 +0,0 @@ -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: "6.1" - timeUnixNano: "1678390948396984000" - isMonotonic: true - - description: Sum if ... - name: sum.if - sum: - aggregationTemporality: 1 - dataPoints: - - asDouble: "6.1" - timeUnixNano: "1678390948396984000" - isMonotonic: true - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector - - resource: {} - scopeMetrics: - - metrics: - - description: All logs Sum - name: sum.all - sum: - aggregationTemporality: 1 - dataPoints: - - asDouble: "6.1" - timeUnixNano: "1678390948396992000" - isMonotonic: true - scope: - name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/logs/one_attribute.yaml b/connector/sumconnector/testdata/logs/one_attribute.yaml deleted file mode 100644 index e762e4a671be..000000000000 --- a/connector/sumconnector/testdata/logs/one_attribute.yaml +++ /dev/null @@ -1,111 +0,0 @@ -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: "4.1" - attributes: - - key: log.required - value: - stringValue: foo - timeUnixNano: "1678390948397419000" - - asDouble: "2" - attributes: - - key: log.required - value: - stringValue: notfoo - timeUnixNano: "1678390948397419000" - isMonotonic: true - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/logs/one_condition.yaml b/connector/sumconnector/testdata/logs/one_condition.yaml deleted file mode 100644 index 2db00fc7f9f0..000000000000 --- a/connector/sumconnector/testdata/logs/one_condition.yaml +++ /dev/null @@ -1,41 +0,0 @@ -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: "6.1" - timeUnixNano: "1678390948395244000" - isMonotonic: true - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/metrics/condition_and_attribute.yaml b/connector/sumconnector/testdata/metrics/condition_and_attribute.yaml deleted file mode 100644 index 604110e5dd9d..000000000000 --- a/connector/sumconnector/testdata/metrics/condition_and_attribute.yaml +++ /dev/null @@ -1,61 +0,0 @@ -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: "24.6" - attributes: - - key: datapoint.required - value: - stringValue: foo - timeUnixNano: "1678391923823222000" - - asDouble: "6" - attributes: - - key: datapoint.required - value: - stringValue: notfoo - timeUnixNano: "1678391923823222000" - isMonotonic: true - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/metrics/default_attribute_value.yaml b/connector/sumconnector/testdata/metrics/default_attribute_value.yaml deleted file mode 100644 index 436ebe3b2c99..000000000000 --- a/connector/sumconnector/testdata/metrics/default_attribute_value.yaml +++ /dev/null @@ -1,171 +0,0 @@ -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: "25.2" - attributes: - - key: datapoint.required - value: - stringValue: foo - - key: datapoint.optional - value: - stringValue: bar - timeUnixNano: "1678391923822404000" - isMonotonic: true - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/metrics/input.yaml b/connector/sumconnector/testdata/metrics/input.yaml deleted file mode 100644 index f92aa2d647a1..000000000000 --- a/connector/sumconnector/testdata/metrics/input.yaml +++ /dev/null @@ -1,1390 +0,0 @@ -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: - 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.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 deleted file mode 100644 index 3d2738d928d3..000000000000 --- a/connector/sumconnector/testdata/metrics/multiple_attributes.yaml +++ /dev/null @@ -1,135 +0,0 @@ -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: "25.2" - 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 - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/metrics/multiple_conditions.yaml b/connector/sumconnector/testdata/metrics/multiple_conditions.yaml deleted file mode 100644 index 0f32d6f6d208..000000000000 --- a/connector/sumconnector/testdata/metrics/multiple_conditions.yaml +++ /dev/null @@ -1,71 +0,0 @@ -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: "30.6" - timeUnixNano: "1678391923819487000" - isMonotonic: true - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector - - resource: {} - scopeMetrics: - - metrics: - - description: Data point sum if ... - name: datapoint.sum.if - sum: - aggregationTemporality: 1 - dataPoints: - - asDouble: "24.6" - timeUnixNano: "1678391923819529000" - isMonotonic: true - scope: - name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/metrics/multiple_metrics.yaml b/connector/sumconnector/testdata/metrics/multiple_metrics.yaml deleted file mode 100644 index 48eab893b8bc..000000000000 --- a/connector/sumconnector/testdata/metrics/multiple_metrics.yaml +++ /dev/null @@ -1,123 +0,0 @@ -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: "30.6" - timeUnixNano: "1678391923820453000" - isMonotonic: true - - description: Data point sum if ... - name: datapoint.sum.if - sum: - aggregationTemporality: 1 - dataPoints: - - asDouble: "30.6" - timeUnixNano: "1678391923820453000" - isMonotonic: true - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/metrics/one_attribute.yaml b/connector/sumconnector/testdata/metrics/one_attribute.yaml deleted file mode 100644 index d28402103aa1..000000000000 --- a/connector/sumconnector/testdata/metrics/one_attribute.yaml +++ /dev/null @@ -1,111 +0,0 @@ -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: "24.6" - attributes: - - key: datapoint.required - value: - stringValue: foo - timeUnixNano: "1678391923821179000" - - asDouble: "6" - attributes: - - key: datapoint.required - value: - stringValue: notfoo - timeUnixNano: "1678391923821179000" - isMonotonic: true - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/metrics/one_condition.yaml b/connector/sumconnector/testdata/metrics/one_condition.yaml deleted file mode 100644 index 919887284515..000000000000 --- a/connector/sumconnector/testdata/metrics/one_condition.yaml +++ /dev/null @@ -1,41 +0,0 @@ -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: "30.6" - timeUnixNano: "1678391923818482000" - isMonotonic: true - scope: - name: otelcol/sumconnector - - 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 - scope: - name: otelcol/sumconnector diff --git a/connector/sumconnector/testdata/traces/condition_and_attribute.yaml b/connector/sumconnector/testdata/traces/condition_and_attribute.yaml index 2c3fc84de612..98aabeffdc8c 100644 --- a/connector/sumconnector/testdata/traces/condition_and_attribute.yaml +++ b/connector/sumconnector/testdata/traces/condition_and_attribute.yaml @@ -45,8 +45,7 @@ resourceMetrics: stringValue: notfoo timeUnixNano: "1678392127929006000" isMonotonic: true - scope: - name: otelcol/sumconnector + - resource: attributes: - key: resource.required @@ -93,5 +92,4 @@ resourceMetrics: stringValue: notfoo timeUnixNano: "1678392127929018000" isMonotonic: true - scope: - name: otelcol/sumconnector + diff --git a/connector/sumconnector/testdata/traces/multiple_attributes.yaml b/connector/sumconnector/testdata/traces/multiple_attributes.yaml index ec02bdcfefe9..5ec3be5690c7 100644 --- a/connector/sumconnector/testdata/traces/multiple_attributes.yaml +++ b/connector/sumconnector/testdata/traces/multiple_attributes.yaml @@ -57,8 +57,7 @@ resourceMetrics: stringValue: notbar timeUnixNano: "1678392127926637000" isMonotonic: true - scope: - name: otelcol/sumconnector + - resource: attributes: - key: resource.required @@ -117,8 +116,7 @@ resourceMetrics: stringValue: notbar timeUnixNano: "1678392127926647000" isMonotonic: true - scope: - name: otelcol/sumconnector + - resource: attributes: - key: resource.required @@ -174,8 +172,7 @@ resourceMetrics: stringValue: notbar timeUnixNano: "1678392127926654000" isMonotonic: true - scope: - name: otelcol/sumconnector + - resource: {} scopeMetrics: - metrics: @@ -227,5 +224,4 @@ resourceMetrics: stringValue: notbar timeUnixNano: "1678392127926661000" isMonotonic: true - scope: - name: otelcol/sumconnector + diff --git a/connector/sumconnector/testdata/traces/multiple_conditions.yaml b/connector/sumconnector/testdata/traces/multiple_conditions.yaml index 55e4021be53e..15f6b8520b75 100644 --- a/connector/sumconnector/testdata/traces/multiple_conditions.yaml +++ b/connector/sumconnector/testdata/traces/multiple_conditions.yaml @@ -25,8 +25,7 @@ resourceMetrics: - asDouble: "23" timeUnixNano: "1678392127923826000" isMonotonic: true - scope: - name: otelcol/sumconnector + - resource: attributes: - key: resource.required @@ -53,8 +52,7 @@ resourceMetrics: - asDouble: "23" timeUnixNano: "1678392127923836000" isMonotonic: true - scope: - name: otelcol/sumconnector + - resource: attributes: - key: resource.required @@ -78,8 +76,7 @@ resourceMetrics: - asDouble: "15" timeUnixNano: "1678392127923843000" isMonotonic: true - scope: - name: otelcol/sumconnector + - resource: {} scopeMetrics: - metrics: @@ -99,5 +96,4 @@ resourceMetrics: - asDouble: "15" timeUnixNano: "1678392127923849000" isMonotonic: true - scope: - name: otelcol/sumconnector + diff --git a/connector/sumconnector/testdata/traces/multiple_metrics.yaml b/connector/sumconnector/testdata/traces/multiple_metrics.yaml index 4f6fba85a388..c97064d230d1 100644 --- a/connector/sumconnector/testdata/traces/multiple_metrics.yaml +++ b/connector/sumconnector/testdata/traces/multiple_metrics.yaml @@ -41,8 +41,7 @@ resourceMetrics: - asDouble: "23" timeUnixNano: "1678392127924753000" isMonotonic: true - scope: - name: otelcol/sumconnector + - resource: attributes: - key: resource.required @@ -85,8 +84,7 @@ resourceMetrics: - asDouble: "23" timeUnixNano: "1678392127924764000" isMonotonic: true - scope: - name: otelcol/sumconnector + - resource: attributes: - key: resource.required @@ -126,8 +124,7 @@ resourceMetrics: - asDouble: "15" timeUnixNano: "1678392127924772000" isMonotonic: true - scope: - name: otelcol/sumconnector + - resource: {} scopeMetrics: - metrics: @@ -163,5 +160,4 @@ resourceMetrics: - asDouble: "15" timeUnixNano: "1678392127924780000" isMonotonic: true - scope: - name: otelcol/sumconnector + diff --git a/connector/sumconnector/testdata/traces/one_attribute.yaml b/connector/sumconnector/testdata/traces/one_attribute.yaml index 549fa408ab9a..1ac2623341a9 100644 --- a/connector/sumconnector/testdata/traces/one_attribute.yaml +++ b/connector/sumconnector/testdata/traces/one_attribute.yaml @@ -45,8 +45,7 @@ resourceMetrics: stringValue: notfoo timeUnixNano: "1678392127925459000" isMonotonic: true - scope: - name: otelcol/sumconnector + - resource: attributes: @@ -94,8 +93,7 @@ resourceMetrics: stringValue: notfoo timeUnixNano: "1678392127925459000" isMonotonic: true - scope: - name: otelcol/sumconnector + - resource: attributes: @@ -140,8 +138,7 @@ resourceMetrics: stringValue: notfoo timeUnixNano: "1678392127925459000" isMonotonic: true - scope: - name: otelcol/sumconnector + - resource: {} scopeMetrics: @@ -182,5 +179,4 @@ resourceMetrics: stringValue: notfoo timeUnixNano: "1678392127925459000" isMonotonic: true - scope: - name: otelcol/sumconnector + diff --git a/connector/sumconnector/testdata/traces/one_condition.yaml b/connector/sumconnector/testdata/traces/one_condition.yaml index ac83f4fc7abf..6ca4d0a69ab4 100644 --- a/connector/sumconnector/testdata/traces/one_condition.yaml +++ b/connector/sumconnector/testdata/traces/one_condition.yaml @@ -25,8 +25,7 @@ resourceMetrics: - asDouble: "23" timeUnixNano: "1678392127922310000" isMonotonic: true - scope: - name: otelcol/sumconnector + - resource: attributes: - key: resource.required @@ -53,5 +52,4 @@ resourceMetrics: - asDouble: "23" timeUnixNano: "1678392127922364000" isMonotonic: true - scope: - name: otelcol/sumconnector + diff --git a/connector/sumconnector/testdata/traces/zero_conditions.yaml b/connector/sumconnector/testdata/traces/zero_conditions.yaml index fb3bbc09aa5a..3c2fdcccc10c 100644 --- a/connector/sumconnector/testdata/traces/zero_conditions.yaml +++ b/connector/sumconnector/testdata/traces/zero_conditions.yaml @@ -25,8 +25,7 @@ resourceMetrics: - asDouble: "23" timeUnixNano: "1678392127920605000" isMonotonic: true - scope: - name: otelcol/sumconnector + - resource: attributes: - key: resource.required @@ -53,8 +52,7 @@ resourceMetrics: - asDouble: "23" timeUnixNano: "1678392127920632000" isMonotonic: true - scope: - name: otelcol/sumconnector + - resource: attributes: - key: resource.required @@ -78,8 +76,7 @@ resourceMetrics: - asDouble: "23" timeUnixNano: "1678392127920635000" isMonotonic: true - scope: - name: otelcol/sumconnector + - resource: {} scopeMetrics: - metrics: @@ -99,5 +96,4 @@ resourceMetrics: - asDouble: "23" timeUnixNano: "1678392127920638000" isMonotonic: true - scope: - name: otelcol/sumconnector + From 7182f7ae3f3d98007b49cbcd2c0ed22622ee0f45 Mon Sep 17 00:00:00 2001 From: jeremyh Date: Wed, 4 Sep 2024 15:46:54 -0400 Subject: [PATCH 07/15] run make genotelcontribcol --- cmd/otelcontribcol/go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/otelcontribcol/go.mod b/cmd/otelcontribcol/go.mod index cbc76c271fcd..4ac3584e1ff5 100644 --- a/cmd/otelcontribcol/go.mod +++ b/cmd/otelcontribcol/go.mod @@ -4,7 +4,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/cmd/otelcontrib go 1.22.0 -toolchain go1.22.6 +toolchain go1.22.1 require ( github.com/open-telemetry/opentelemetry-collector-contrib/confmap/provider/s3provider v0.108.0 From 0250a1f12ec89dbea18dda63a459b31d54656bf8 Mon Sep 17 00:00:00 2001 From: Jeremy Hicks Date: Thu, 5 Sep 2024 11:05:09 -0400 Subject: [PATCH 08/15] Update cmd/otelcontribcol/go.mod revert change from `make genotelcontribcol` Co-authored-by: Antoine Toulme --- cmd/otelcontribcol/go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/otelcontribcol/go.mod b/cmd/otelcontribcol/go.mod index f540dd698046..55d36c7b5e1c 100644 --- a/cmd/otelcontribcol/go.mod +++ b/cmd/otelcontribcol/go.mod @@ -4,7 +4,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/cmd/otelcontrib go 1.22.0 -toolchain go1.22.1 +toolchain go1.22.6 require ( github.com/open-telemetry/opentelemetry-collector-contrib/confmap/provider/s3provider v0.108.0 From ad4621002846e1a6ca392e18ca3f7aefad82869c Mon Sep 17 00:00:00 2001 From: jeremyh Date: Thu, 5 Sep 2024 17:59:22 -0400 Subject: [PATCH 09/15] clarify logic and update readme --- .chloggen/32669-sumconnector-sum-logic.yaml | 2 +- connector/sumconnector/README.md | 12 +++++------- connector/sumconnector/connector.go | 2 ++ connector/sumconnector/go.mod | 2 -- connector/sumconnector/sum.go | 1 + 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.chloggen/32669-sumconnector-sum-logic.yaml b/.chloggen/32669-sumconnector-sum-logic.yaml index 95f76a6a9e16..e2b38e64b94a 100644 --- a/.chloggen/32669-sumconnector-sum-logic.yaml +++ b/.chloggen/32669-sumconnector-sum-logic.yaml @@ -24,4 +24,4 @@ subtext: # Include 'user' if the change is relevant to end users. # Include 'api' if there is a change to a library API. # Default: '[user]' -change_logs: [user, api] +change_logs: [user] diff --git a/connector/sumconnector/README.md b/connector/sumconnector/README.md index 8204e5d20fc5..f2996d2b6c29 100644 --- a/connector/sumconnector/README.md +++ b/connector/sumconnector/README.md @@ -27,13 +27,11 @@ The `sum` connector can be used to sum attribute values from spans, span events, If you are not already familiar with connectors, you may find it helpful to first visit the [Connectors README](https://github.com/open-telemetry/opentelemetry-collector/blob/main/connector/README.md). -### Configuration - -#### Basic configuration +### Basic configuration This configuration will sum numerical values found within the attribute `attribute.with.numerical.value` of any log telemetry routed to the connector. It will then output a metric time series with the name `my.example.metric.name` with those summed values. -Note: Values found within an attribute will be converted into a float regardless of their original type before being summed and output as a metric value. Non-convertable strings will be dropped and not included. +Note: Values found within an attribute will be converted into a float regardless of their original type before being summed and output as a metric value. Non-convertible strings will be dropped and not included. ```yaml receivers: @@ -60,15 +58,15 @@ service: The sum connector has three required configuration settings and numerous optional settings -- Telemetry type: Nested below the `sum:` connector declaration. Declared as `logs:` in the [Basic Example](#basic-configuration). +- Telemetry type: Nested below the `sum:` connector declaration. Declared as `logs:` in the [Basic Example](#basic-configuration). - Can be any of `spans`, `spanevents`, `metrics`, `datapoints`, or `logs`. - Metric name: Nested below the telemetry type; this is the metric name the sum connector will output summed values to. Declared as `my.example.metric.name` in the [Basic Example](#basic-configuration) - `source_attribute`: A specific attribute to search for within the source telemetry being fed to the connector. This attribute is where the connector will look for numerical values to sum into the output metric value. Declared as `attribute.with.numerical.value` in the [Basic Example](#basic-configuration) #### Optional Settings -- `conditions`: [OTTL syntax](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/ottl/LANGUAGE.md) can be used to provide conditions for processing incoming telemetry. Conditions are ORed together, so if any condition is met the attribute's value will be included in the resulting sum. -- `attributes`: Declaration of attributes to include. Any of these attributes found will generate a separate sum for each set of unique combination of attribute values and output as its own datapoint in the metric time series. +- `conditions`: [OTTL syntax](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/ottl/LANGUAGE.md) can be used to provide conditions for processing incoming telemetry. Conditions are ORed together, so if any condition is met the attribute's value will be included in the resulting sum. +- `attributes`: Declaration of attributes to include. Any of these attributes found will generate a separate sum for each set of unique combination of attribute values and output as its own datapoint in the metric time series. - `key`: (required for `attributes`) the attribute name to match against - `default_value`: (optional for `attributes`) a default value for the attribute when no matches are found. The `default_value` value can be of type string, integer, or float. diff --git a/connector/sumconnector/connector.go b/connector/sumconnector/connector.go index fd8e5e09224c..88b332075dfc 100644 --- a/connector/sumconnector/connector.go +++ b/connector/sumconnector/connector.go @@ -102,6 +102,8 @@ func (c *sum) ConsumeMetrics(ctx context.Context, md pmetric.Metrics) error { multiError = errors.Join(multiError, metricsSummer.update(ctx, pcommon.NewMap(), mCtx)) //exhaustive:enforce + // For metric types each must be handled in exactly the same way + // Switch case required because each type calls DataPoints() differently switch metric.Type() { case pmetric.MetricTypeGauge: dps := metric.Gauge().DataPoints() diff --git a/connector/sumconnector/go.mod b/connector/sumconnector/go.mod index 367b53d6a458..513276439231 100644 --- a/connector/sumconnector/go.mod +++ b/connector/sumconnector/go.mod @@ -2,8 +2,6 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/connector/sumco go 1.22.0 -toolchain go1.22.1 - require ( github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter v0.108.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden v0.108.0 diff --git a/connector/sumconnector/sum.go b/connector/sumconnector/sum.go index 50be604790cd..e4361fcfa4ad 100644 --- a/connector/sumconnector/sum.go +++ b/connector/sumconnector/sum.go @@ -133,6 +133,7 @@ func (c *summer[K]) increment(metricName string, sumVal float64, attrs pcommon.M return nil } +// Addresses issues with float precision smaller than 6 decimal places func reduceFloatPrecision(val float64) float64 { return math.Round(val*100000) / 100000 } From 73f03a714717ae8c31c5b2f42b8469bc9ea06850 Mon Sep 17 00:00:00 2001 From: jeremyh Date: Thu, 5 Sep 2024 18:16:00 -0400 Subject: [PATCH 10/15] generate and lint --- connector/sumconnector/connector.go | 2 +- connector/sumconnector/generated_package_test.go | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/connector/sumconnector/connector.go b/connector/sumconnector/connector.go index 88b332075dfc..e9800c877a44 100644 --- a/connector/sumconnector/connector.go +++ b/connector/sumconnector/connector.go @@ -103,7 +103,7 @@ func (c *sum) ConsumeMetrics(ctx context.Context, md pmetric.Metrics) error { //exhaustive:enforce // For metric types each must be handled in exactly the same way - // Switch case required because each type calls DataPoints() differently + // Switch case required because each type calls DataPoints() differently switch metric.Type() { case pmetric.MetricTypeGauge: dps := metric.Gauge().DataPoints() diff --git a/connector/sumconnector/generated_package_test.go b/connector/sumconnector/generated_package_test.go index 6a2e7f1b6171..2c6d0cb52ca9 100644 --- a/connector/sumconnector/generated_package_test.go +++ b/connector/sumconnector/generated_package_test.go @@ -3,9 +3,8 @@ package sumconnector import ( - "testing" - "go.uber.org/goleak" + "testing" ) func TestMain(m *testing.M) { From dd5a3e28def232067f9a0d9779485b82196ff7bd Mon Sep 17 00:00:00 2001 From: jeremyh Date: Mon, 9 Sep 2024 15:32:43 -0400 Subject: [PATCH 11/15] test --- .../sumconnector/generated_package_test.go | 3 ++- connector/sumconnector/sum.go | 8 +----- .../sumconnector/testdata/traces/input.yaml | 26 +++++++++---------- .../testdata/traces/one_condition.yaml | 4 +-- .../testdata/traces/zero_conditions.yaml | 4 +-- 5 files changed, 20 insertions(+), 25 deletions(-) diff --git a/connector/sumconnector/generated_package_test.go b/connector/sumconnector/generated_package_test.go index 2c6d0cb52ca9..6a2e7f1b6171 100644 --- a/connector/sumconnector/generated_package_test.go +++ b/connector/sumconnector/generated_package_test.go @@ -3,8 +3,9 @@ package sumconnector import ( - "go.uber.org/goleak" "testing" + + "go.uber.org/goleak" ) func TestMain(m *testing.M) { diff --git a/connector/sumconnector/sum.go b/connector/sumconnector/sum.go index e4361fcfa4ad..5c89ed19e42e 100644 --- a/connector/sumconnector/sum.go +++ b/connector/sumconnector/sum.go @@ -7,7 +7,6 @@ import ( "context" "errors" "fmt" - "math" "strconv" "time" @@ -133,11 +132,6 @@ func (c *summer[K]) increment(metricName string, sumVal float64, attrs pcommon.M return nil } -// Addresses issues with float precision smaller than 6 decimal places -func reduceFloatPrecision(val float64) float64 { - return math.Round(val*100000) / 100000 -} - func (c *summer[K]) appendMetricsTo(metricSlice pmetric.MetricSlice) { for name, md := range c.metricDefs { if len(c.sums[name]) == 0 { @@ -153,7 +147,7 @@ func (c *summer[K]) appendMetricsTo(metricSlice pmetric.MetricSlice) { for _, dpSum := range c.sums[name] { dp := sum.DataPoints().AppendEmpty() dpSum.attrs.CopyTo(dp.Attributes()) - dp.SetDoubleValue(reduceFloatPrecision(dpSum.sum)) + dp.SetDoubleValue(dpSum.sum) dp.SetTimestamp(pcommon.NewTimestampFromTime(c.timestamp)) } } diff --git a/connector/sumconnector/testdata/traces/input.yaml b/connector/sumconnector/testdata/traces/input.yaml index ea357d4423d8..b6d74c2a11ac 100644 --- a/connector/sumconnector/testdata/traces/input.yaml +++ b/connector/sumconnector/testdata/traces/input.yaml @@ -37,7 +37,7 @@ resourceSpans: stringValue: bar - key: beep value: - doubleValue: 2 + doubleValue: 2.1 name: event-with-attrs-foo-bar timeUnixNano: "1581452773000000123" - attributes: @@ -49,7 +49,7 @@ resourceSpans: stringValue: notbar - key: beep value: - doubleValue: 2 + doubleValue: 2.1 name: event-with-attrs-foo-notbar timeUnixNano: "1581452773000000123" - attributes: @@ -58,7 +58,7 @@ resourceSpans: stringValue: notfoo - key: beep value: - doubleValue: 2 + doubleValue: 2.1 name: event-with-attr-notfoo timeUnixNano: "1581452773000000123" - name: event-with-no-attrs @@ -112,7 +112,7 @@ resourceSpans: stringValue: notfoo - key: beep value: - doubleValue: 2 + stringValue: "2" name: event-with-attr-notfoo timeUnixNano: "1581452773000000123" - name: event-with-no-attrs @@ -142,7 +142,7 @@ resourceSpans: stringValue: bar - key: beep value: - doubleValue: 2 + doubleValue: 2.1 name: event-with-attrs-foo-bar timeUnixNano: "1581452773000000123" - attributes: @@ -154,7 +154,7 @@ resourceSpans: stringValue: notbar - key: beep value: - doubleValue: 2 + doubleValue: 2.1 name: event-with-attrs-foo-notbar timeUnixNano: "1581452773000000123" - attributes: @@ -163,7 +163,7 @@ resourceSpans: stringValue: notfoo - key: beep value: - doubleValue: 2 + doubleValue: 2.1 name: event-with-attr-notfoo timeUnixNano: "1581452773000000123" - name: event-with-no-attrs @@ -187,7 +187,7 @@ resourceSpans: stringValue: bar - key: beep value: - doubleValue: 1 + doubleValue: 1.1 name: event-with-attrs-foo-bar timeUnixNano: "1581452773000000123" - attributes: @@ -199,7 +199,7 @@ resourceSpans: stringValue: notbar - key: beep value: - doubleValue: 1 + doubleValue: 1.1 name: event-with-attrs-foo-notbar timeUnixNano: "1581452773000000123" - attributes: @@ -208,7 +208,7 @@ resourceSpans: stringValue: notfoo - key: beep value: - doubleValue: 2 + doubleValue: 2.1 name: event-with-attr-notfoo timeUnixNano: "1581452773000000123" - name: event-with-no-attrs @@ -252,7 +252,7 @@ resourceSpans: stringValue: bar - key: beep value: - doubleValue: 2 + doubleValue: 2.1 name: event-with-attrs-foo-bar timeUnixNano: "1581452773000000123" - attributes: @@ -264,7 +264,7 @@ resourceSpans: stringValue: notbar - key: beep value: - doubleValue: 2 + doubleValue: 2.1 name: event-with-attrs-foo-notbar timeUnixNano: "1581452773000000123" - attributes: @@ -273,7 +273,7 @@ resourceSpans: stringValue: notfoo - key: beep value: - doubleValue: 2 + doubleValue: 2.1 name: event-with-attr-notfoo timeUnixNano: "1581452773000000123" - name: event-with-no-attrs diff --git a/connector/sumconnector/testdata/traces/one_condition.yaml b/connector/sumconnector/testdata/traces/one_condition.yaml index 6ca4d0a69ab4..9c95a0555a85 100644 --- a/connector/sumconnector/testdata/traces/one_condition.yaml +++ b/connector/sumconnector/testdata/traces/one_condition.yaml @@ -22,7 +22,7 @@ resourceMetrics: sum: aggregationTemporality: 1 dataPoints: - - asDouble: "23" + - asDouble: "23.900000" timeUnixNano: "1678392127922310000" isMonotonic: true @@ -49,7 +49,7 @@ resourceMetrics: sum: aggregationTemporality: 1 dataPoints: - - asDouble: "23" + - asDouble: "23.3" timeUnixNano: "1678392127922364000" isMonotonic: true diff --git a/connector/sumconnector/testdata/traces/zero_conditions.yaml b/connector/sumconnector/testdata/traces/zero_conditions.yaml index 3c2fdcccc10c..1c287e188dff 100644 --- a/connector/sumconnector/testdata/traces/zero_conditions.yaml +++ b/connector/sumconnector/testdata/traces/zero_conditions.yaml @@ -22,7 +22,7 @@ resourceMetrics: sum: aggregationTemporality: 1 dataPoints: - - asDouble: "23" + - asDouble: "23.9" timeUnixNano: "1678392127920605000" isMonotonic: true @@ -49,7 +49,7 @@ resourceMetrics: sum: aggregationTemporality: 1 dataPoints: - - asDouble: "23" + - asDouble: "23.3" timeUnixNano: "1678392127920632000" isMonotonic: true From 29941210da1361ce16a38fd915e4b644c0ed6f49 Mon Sep 17 00:00:00 2001 From: jeremyh Date: Wed, 11 Sep 2024 12:08:37 -0400 Subject: [PATCH 12/15] use new CompareMetrics option to ignore float precision --- connector/sumconnector/connector_test.go | 1 + connector/sumconnector/go.mod | 6 +++--- .../testdata/traces/condition_and_attribute.yaml | 8 ++++---- .../sumconnector/testdata/traces/multiple_attributes.yaml | 8 ++++---- .../sumconnector/testdata/traces/multiple_conditions.yaml | 4 ++-- .../sumconnector/testdata/traces/multiple_metrics.yaml | 8 ++++---- connector/sumconnector/testdata/traces/one_attribute.yaml | 8 ++++---- 7 files changed, 22 insertions(+), 21 deletions(-) diff --git a/connector/sumconnector/connector_test.go b/connector/sumconnector/connector_test.go index da50b2540878..4c2d4438c692 100644 --- a/connector/sumconnector/connector_test.go +++ b/connector/sumconnector/connector_test.go @@ -264,6 +264,7 @@ func TestTracesToMetrics(t *testing.T) { pmetrictest.IgnoreTimestamp(), pmetrictest.IgnoreResourceMetricsOrder(), pmetrictest.IgnoreMetricsOrder(), + pmetrictest.IgnoreMetricFloatPrecision(3), pmetrictest.IgnoreMetricDataPointsOrder())) }) } diff --git a/connector/sumconnector/go.mod b/connector/sumconnector/go.mod index 8fea59ddc761..8f40abd40473 100644 --- a/connector/sumconnector/go.mod +++ b/connector/sumconnector/go.mod @@ -4,10 +4,10 @@ go 1.22.0 require ( github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter v0.109.0 - github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden v0.108.0 + github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden v0.109.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl v0.109.0 - github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.108.0 - github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.108.0 + github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.109.0 + github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.109.0 github.com/stretchr/testify v1.9.0 go.opentelemetry.io/collector/component v0.109.0 go.opentelemetry.io/collector/confmap v1.15.0 diff --git a/connector/sumconnector/testdata/traces/condition_and_attribute.yaml b/connector/sumconnector/testdata/traces/condition_and_attribute.yaml index 98aabeffdc8c..1c26091ef995 100644 --- a/connector/sumconnector/testdata/traces/condition_and_attribute.yaml +++ b/connector/sumconnector/testdata/traces/condition_and_attribute.yaml @@ -32,13 +32,13 @@ resourceMetrics: sum: aggregationTemporality: 1 dataPoints: - - asDouble: "15" + - asDouble: "15.6" attributes: - key: event.required value: stringValue: foo timeUnixNano: "1678392127929006000" - - asDouble: "8" + - asDouble: "8.3" attributes: - key: event.required value: @@ -79,13 +79,13 @@ resourceMetrics: sum: aggregationTemporality: 1 dataPoints: - - asDouble: "15" + - asDouble: "15.2" attributes: - key: event.required value: stringValue: foo timeUnixNano: "1678392127929018000" - - asDouble: "8" + - asDouble: "8.1" attributes: - key: event.required value: diff --git a/connector/sumconnector/testdata/traces/multiple_attributes.yaml b/connector/sumconnector/testdata/traces/multiple_attributes.yaml index 5ec3be5690c7..7407a91f2eb5 100644 --- a/connector/sumconnector/testdata/traces/multiple_attributes.yaml +++ b/connector/sumconnector/testdata/traces/multiple_attributes.yaml @@ -38,7 +38,7 @@ resourceMetrics: sum: aggregationTemporality: 1 dataPoints: - - asDouble: "14" + - asDouble: "14.6" attributes: - key: event.required value: @@ -47,7 +47,7 @@ resourceMetrics: value: stringValue: bar timeUnixNano: "1678392127926637000" - - asDouble: "16" + - asDouble: "16.6" attributes: - key: event.required value: @@ -97,7 +97,7 @@ resourceMetrics: sum: aggregationTemporality: 1 dataPoints: - - asDouble: "14" + - asDouble: "14.2" attributes: - key: event.required value: @@ -106,7 +106,7 @@ resourceMetrics: value: stringValue: bar timeUnixNano: "1678392127926647000" - - asDouble: "16" + - asDouble: "16.2" attributes: - key: event.required value: diff --git a/connector/sumconnector/testdata/traces/multiple_conditions.yaml b/connector/sumconnector/testdata/traces/multiple_conditions.yaml index 15f6b8520b75..eea3335df200 100644 --- a/connector/sumconnector/testdata/traces/multiple_conditions.yaml +++ b/connector/sumconnector/testdata/traces/multiple_conditions.yaml @@ -22,7 +22,7 @@ resourceMetrics: sum: aggregationTemporality: 1 dataPoints: - - asDouble: "23" + - asDouble: "23.9" timeUnixNano: "1678392127923826000" isMonotonic: true @@ -49,7 +49,7 @@ resourceMetrics: sum: aggregationTemporality: 1 dataPoints: - - asDouble: "23" + - asDouble: "23.3" timeUnixNano: "1678392127923836000" isMonotonic: true diff --git a/connector/sumconnector/testdata/traces/multiple_metrics.yaml b/connector/sumconnector/testdata/traces/multiple_metrics.yaml index c97064d230d1..c19731ff7fac 100644 --- a/connector/sumconnector/testdata/traces/multiple_metrics.yaml +++ b/connector/sumconnector/testdata/traces/multiple_metrics.yaml @@ -30,7 +30,7 @@ resourceMetrics: sum: aggregationTemporality: 1 dataPoints: - - asDouble: "23" + - asDouble: "23.9" timeUnixNano: "1678392127924753000" isMonotonic: true - description: Span event sum if ... @@ -38,7 +38,7 @@ resourceMetrics: sum: aggregationTemporality: 1 dataPoints: - - asDouble: "23" + - asDouble: "23.9" timeUnixNano: "1678392127924753000" isMonotonic: true @@ -73,7 +73,7 @@ resourceMetrics: sum: aggregationTemporality: 1 dataPoints: - - asDouble: "23" + - asDouble: "23.3" timeUnixNano: "1678392127924764000" isMonotonic: true - description: Span event sum if ... @@ -81,7 +81,7 @@ resourceMetrics: sum: aggregationTemporality: 1 dataPoints: - - asDouble: "23" + - asDouble: "23.3" timeUnixNano: "1678392127924764000" isMonotonic: true diff --git a/connector/sumconnector/testdata/traces/one_attribute.yaml b/connector/sumconnector/testdata/traces/one_attribute.yaml index 1ac2623341a9..466f1558822e 100644 --- a/connector/sumconnector/testdata/traces/one_attribute.yaml +++ b/connector/sumconnector/testdata/traces/one_attribute.yaml @@ -32,13 +32,13 @@ resourceMetrics: sum: aggregationTemporality: 1 dataPoints: - - asDouble: "15" + - asDouble: "15.6" attributes: - key: event.required value: stringValue: foo timeUnixNano: "1678392127925459000" - - asDouble: "8" + - asDouble: "8.3" attributes: - key: event.required value: @@ -80,13 +80,13 @@ resourceMetrics: sum: aggregationTemporality: 1 dataPoints: - - asDouble: "15" + - asDouble: "15.2" attributes: - key: event.required value: stringValue: foo timeUnixNano: "1678392127925459000" - - asDouble: "8" + - asDouble: "8.1" attributes: - key: event.required value: From a2c4513ef499cff25ecac2ce103c1543280cceed Mon Sep 17 00:00:00 2001 From: jeremyh Date: Thu, 12 Sep 2024 14:51:53 -0400 Subject: [PATCH 13/15] update README --- connector/sumconnector/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/connector/sumconnector/README.md b/connector/sumconnector/README.md index f2996d2b6c29..9d6f39bcfd40 100644 --- a/connector/sumconnector/README.md +++ b/connector/sumconnector/README.md @@ -31,7 +31,7 @@ If you are not already familiar with connectors, you may find it helpful to firs This configuration will sum numerical values found within the attribute `attribute.with.numerical.value` of any log telemetry routed to the connector. It will then output a metric time series with the name `my.example.metric.name` with those summed values. -Note: Values found within an attribute will be converted into a float regardless of their original type before being summed and output as a metric value. Non-convertible strings will be dropped and not included. +Note: Values found within an attribute will be converted into a float regardless of their original type before being summed and output as a metric value. Non-convertible strings will be dropped and not included. ```yaml receivers: @@ -58,15 +58,15 @@ service: The sum connector has three required configuration settings and numerous optional settings -- Telemetry type: Nested below the `sum:` connector declaration. Declared as `logs:` in the [Basic Example](#basic-configuration). +- Telemetry type: Nested below the `sum:` connector declaration. Declared as `logs:` in the [Basic Example](#basic-configuration). - Can be any of `spans`, `spanevents`, `metrics`, `datapoints`, or `logs`. - Metric name: Nested below the telemetry type; this is the metric name the sum connector will output summed values to. Declared as `my.example.metric.name` in the [Basic Example](#basic-configuration) - `source_attribute`: A specific attribute to search for within the source telemetry being fed to the connector. This attribute is where the connector will look for numerical values to sum into the output metric value. Declared as `attribute.with.numerical.value` in the [Basic Example](#basic-configuration) #### Optional Settings -- `conditions`: [OTTL syntax](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/ottl/LANGUAGE.md) can be used to provide conditions for processing incoming telemetry. Conditions are ORed together, so if any condition is met the attribute's value will be included in the resulting sum. -- `attributes`: Declaration of attributes to include. Any of these attributes found will generate a separate sum for each set of unique combination of attribute values and output as its own datapoint in the metric time series. +- `conditions`: [OTTL syntax](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/ottl/LANGUAGE.md) can be used to provide conditions for processing incoming telemetry. Conditions are ORed together, so if any condition is met the attribute's value will be included in the resulting sum. +- `attributes`: Declaration of attributes to include. Any of these attributes found will generate a separate sum for each set of unique combination of attribute values and output as its own datapoint in the metric time series. - `key`: (required for `attributes`) the attribute name to match against - `default_value`: (optional for `attributes`) a default value for the attribute when no matches are found. The `default_value` value can be of type string, integer, or float. From 972debf1cf032a7caea247b3db8af2812ad548d8 Mon Sep 17 00:00:00 2001 From: jeremyh Date: Tue, 24 Sep 2024 09:13:37 -0400 Subject: [PATCH 14/15] gotidy --- connector/sumconnector/go.mod | 7 ++++--- connector/sumconnector/go.sum | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/connector/sumconnector/go.mod b/connector/sumconnector/go.mod index a73794171a45..b2e0d3cd93e3 100644 --- a/connector/sumconnector/go.mod +++ b/connector/sumconnector/go.mod @@ -4,10 +4,10 @@ go 1.22.0 require ( github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter v0.110.0 - github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden v0.109.0 + github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden v0.110.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl v0.110.0 - github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.109.0 - github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.109.0 + github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.110.0 + github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.110.0 github.com/stretchr/testify v1.9.0 go.opentelemetry.io/collector/component v0.110.0 go.opentelemetry.io/collector/confmap v1.16.0 @@ -22,6 +22,7 @@ require ( require ( github.com/alecthomas/participle/v2 v2.1.1 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/elastic/go-grok v0.3.1 // indirect github.com/elastic/lunes v0.1.0 // indirect diff --git a/connector/sumconnector/go.sum b/connector/sumconnector/go.sum index 58c0060e417e..48db5c85297e 100644 --- a/connector/sumconnector/go.sum +++ b/connector/sumconnector/go.sum @@ -4,6 +4,8 @@ github.com/alecthomas/participle/v2 v2.1.1 h1:hrjKESvSqGHzRb4yW1ciisFJ4p3MGYih6i github.com/alecthomas/participle/v2 v2.1.1/go.mod h1:Y1+hAs8DHPmc3YUFzqllV+eSQ9ljPTk0ZkPMtEdAx2c= github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk= github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= From 900637cd9d38def8c17a903a78583e3c08c57722 Mon Sep 17 00:00:00 2001 From: jeremyh Date: Tue, 24 Sep 2024 11:39:58 -0400 Subject: [PATCH 15/15] gotidy again --- connector/sumconnector/go.mod | 2 +- connector/sumconnector/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/connector/sumconnector/go.mod b/connector/sumconnector/go.mod index 86594c17c9c2..62619074a6d7 100644 --- a/connector/sumconnector/go.mod +++ b/connector/sumconnector/go.mod @@ -22,9 +22,9 @@ require ( require ( github.com/alecthomas/participle/v2 v2.1.1 // indirect - github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/antchfx/xmlquery v1.4.1 // indirect github.com/antchfx/xpath v1.3.1 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/elastic/go-grok v0.3.1 // indirect github.com/elastic/lunes v0.1.0 // indirect diff --git a/connector/sumconnector/go.sum b/connector/sumconnector/go.sum index 12d888a3a6d0..90ec98e1af59 100644 --- a/connector/sumconnector/go.sum +++ b/connector/sumconnector/go.sum @@ -4,12 +4,12 @@ github.com/alecthomas/participle/v2 v2.1.1 h1:hrjKESvSqGHzRb4yW1ciisFJ4p3MGYih6i github.com/alecthomas/participle/v2 v2.1.1/go.mod h1:Y1+hAs8DHPmc3YUFzqllV+eSQ9ljPTk0ZkPMtEdAx2c= github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk= github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= -github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= -github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/antchfx/xmlquery v1.4.1 h1:YgpSwbeWvLp557YFTi8E3z6t6/hYjmFEtiEKbDfEbl0= github.com/antchfx/xmlquery v1.4.1/go.mod h1:lKezcT8ELGt8kW5L+ckFMTbgdR61/odpPgDv8Gvi1fI= github.com/antchfx/xpath v1.3.1 h1:PNbFuUqHwWl0xRjvUPjJ95Agbmdj2uzzIwmQKgu4oCk= github.com/antchfx/xpath v1.3.1/go.mod h1:i54GszH55fYfBmoZXapTHN8T8tkcHfRgLyVwwqzXNcs= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=