diff --git a/collector/receiver/telemetryapireceiver/documentation.md b/collector/receiver/telemetryapireceiver/documentation.md index bd10f60016..aea1c98c39 100644 --- a/collector/receiver/telemetryapireceiver/documentation.md +++ b/collector/receiver/telemetryapireceiver/documentation.md @@ -12,13 +12,55 @@ metrics: enabled: false ``` -### faas.coldstart +### faas.coldstarts Number of invocation cold starts | Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | | ---- | ----------- | ---------- | ----------------------- | --------- | -| {coldstart} | Sum | Int | Cumulative | true | +| {coldstart} | Sum | Int | Delta | true | + +#### Attributes + +| Name | Description | Values | +| ---- | ----------- | ------ | +| faas.trigger | Type of the trigger which caused this function invocation | Str: ``datasource``, ``http``, ``other``, ``pubsub``, ``timer`` | + +### faas.errors + +Number of invocation errors + +| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | +| ---- | ----------- | ---------- | ----------------------- | --------- | +| {error} | Sum | Int | Delta | true | + +#### Attributes + +| Name | Description | Values | +| ---- | ----------- | ------ | +| faas.trigger | Type of the trigger which caused this function invocation | Str: ``datasource``, ``http``, ``other``, ``pubsub``, ``timer`` | + +### faas.invocations + +Number of successful invocations + +| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | +| ---- | ----------- | ---------- | ----------------------- | --------- | +| {invocation} | Sum | Int | Delta | true | + +#### Attributes + +| Name | Description | Values | +| ---- | ----------- | ------ | +| faas.trigger | Type of the trigger which caused this function invocation | Str: ``datasource``, ``http``, ``other``, ``pubsub``, ``timer`` | + +### faas.timeouts + +Number of invocation timeouts + +| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | +| ---- | ----------- | ---------- | ----------------------- | --------- | +| {timeout} | Sum | Int | Delta | true | #### Attributes diff --git a/collector/receiver/telemetryapireceiver/internal/metadata/generated_config.go b/collector/receiver/telemetryapireceiver/internal/metadata/generated_config.go index 226cb9d476..c890b43ce8 100644 --- a/collector/receiver/telemetryapireceiver/internal/metadata/generated_config.go +++ b/collector/receiver/telemetryapireceiver/internal/metadata/generated_config.go @@ -27,12 +27,24 @@ func (ms *MetricConfig) Unmarshal(parser *confmap.Conf) error { // MetricsConfig provides config for faas metrics. type MetricsConfig struct { - FaasColdstart MetricConfig `mapstructure:"faas.coldstart"` + FaasColdstarts MetricConfig `mapstructure:"faas.coldstarts"` + FaasErrors MetricConfig `mapstructure:"faas.errors"` + FaasInvocations MetricConfig `mapstructure:"faas.invocations"` + FaasTimeouts MetricConfig `mapstructure:"faas.timeouts"` } func DefaultMetricsConfig() MetricsConfig { return MetricsConfig{ - FaasColdstart: MetricConfig{ + FaasColdstarts: MetricConfig{ + Enabled: true, + }, + FaasErrors: MetricConfig{ + Enabled: true, + }, + FaasInvocations: MetricConfig{ + Enabled: true, + }, + FaasTimeouts: MetricConfig{ Enabled: true, }, } diff --git a/collector/receiver/telemetryapireceiver/internal/metadata/generated_config_test.go b/collector/receiver/telemetryapireceiver/internal/metadata/generated_config_test.go index 7af0086faf..51221d325f 100644 --- a/collector/receiver/telemetryapireceiver/internal/metadata/generated_config_test.go +++ b/collector/receiver/telemetryapireceiver/internal/metadata/generated_config_test.go @@ -25,7 +25,10 @@ func TestMetricsBuilderConfig(t *testing.T) { name: "all_set", want: MetricsBuilderConfig{ Metrics: MetricsConfig{ - FaasColdstart: MetricConfig{Enabled: true}, + FaasColdstarts: MetricConfig{Enabled: true}, + FaasErrors: MetricConfig{Enabled: true}, + FaasInvocations: MetricConfig{Enabled: true}, + FaasTimeouts: MetricConfig{Enabled: true}, }, }, }, @@ -33,7 +36,10 @@ func TestMetricsBuilderConfig(t *testing.T) { name: "none_set", want: MetricsBuilderConfig{ Metrics: MetricsConfig{ - FaasColdstart: MetricConfig{Enabled: false}, + FaasColdstarts: MetricConfig{Enabled: false}, + FaasErrors: MetricConfig{Enabled: false}, + FaasInvocations: MetricConfig{Enabled: false}, + FaasTimeouts: MetricConfig{Enabled: false}, }, }, }, diff --git a/collector/receiver/telemetryapireceiver/internal/metadata/generated_metrics.go b/collector/receiver/telemetryapireceiver/internal/metadata/generated_metrics.go index 6bdeb0e9f7..883920fdd9 100644 --- a/collector/receiver/telemetryapireceiver/internal/metadata/generated_metrics.go +++ b/collector/receiver/telemetryapireceiver/internal/metadata/generated_metrics.go @@ -51,24 +51,24 @@ var MapAttributeFaasTrigger = map[string]AttributeFaasTrigger{ "timer": AttributeFaasTriggerTimer, } -type metricFaasColdstart struct { +type metricFaasColdstarts struct { data pmetric.Metric // data buffer for generated metric. config MetricConfig // metric config provided by user. capacity int // max observed number of data points added to the metric. } -// init fills faas.coldstart metric with initial data. -func (m *metricFaasColdstart) init() { - m.data.SetName("faas.coldstart") +// init fills faas.coldstarts metric with initial data. +func (m *metricFaasColdstarts) init() { + m.data.SetName("faas.coldstarts") m.data.SetDescription("Number of invocation cold starts") m.data.SetUnit("{coldstart}") m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(true) - m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityDelta) m.data.Sum().DataPoints().EnsureCapacity(m.capacity) } -func (m *metricFaasColdstart) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, faasTriggerAttributeValue string) { +func (m *metricFaasColdstarts) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, faasTriggerAttributeValue string) { if !m.config.Enabled { return } @@ -80,14 +80,14 @@ func (m *metricFaasColdstart) recordDataPoint(start pcommon.Timestamp, ts pcommo } // updateCapacity saves max length of data point slices that will be used for the slice capacity. -func (m *metricFaasColdstart) updateCapacity() { +func (m *metricFaasColdstarts) updateCapacity() { if m.data.Sum().DataPoints().Len() > m.capacity { m.capacity = m.data.Sum().DataPoints().Len() } } // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. -func (m *metricFaasColdstart) emit(metrics pmetric.MetricSlice) { +func (m *metricFaasColdstarts) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) @@ -95,8 +95,167 @@ func (m *metricFaasColdstart) emit(metrics pmetric.MetricSlice) { } } -func newMetricFaasColdstart(cfg MetricConfig) metricFaasColdstart { - m := metricFaasColdstart{config: cfg} +func newMetricFaasColdstarts(cfg MetricConfig) metricFaasColdstarts { + m := metricFaasColdstarts{config: cfg} + if cfg.Enabled { + m.data = pmetric.NewMetric() + m.init() + } + return m +} + +type metricFaasErrors struct { + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. +} + +// init fills faas.errors metric with initial data. +func (m *metricFaasErrors) init() { + m.data.SetName("faas.errors") + m.data.SetDescription("Number of invocation errors") + m.data.SetUnit("{error}") + m.data.SetEmptySum() + m.data.Sum().SetIsMonotonic(true) + m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityDelta) + m.data.Sum().DataPoints().EnsureCapacity(m.capacity) +} + +func (m *metricFaasErrors) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, faasTriggerAttributeValue string) { + if !m.config.Enabled { + return + } + dp := m.data.Sum().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) + dp.Attributes().PutStr("faas.trigger", faasTriggerAttributeValue) +} + +// updateCapacity saves max length of data point slices that will be used for the slice capacity. +func (m *metricFaasErrors) updateCapacity() { + if m.data.Sum().DataPoints().Len() > m.capacity { + m.capacity = m.data.Sum().DataPoints().Len() + } +} + +// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. +func (m *metricFaasErrors) emit(metrics pmetric.MetricSlice) { + if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + m.updateCapacity() + m.data.MoveTo(metrics.AppendEmpty()) + m.init() + } +} + +func newMetricFaasErrors(cfg MetricConfig) metricFaasErrors { + m := metricFaasErrors{config: cfg} + if cfg.Enabled { + m.data = pmetric.NewMetric() + m.init() + } + return m +} + +type metricFaasInvocations struct { + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. +} + +// init fills faas.invocations metric with initial data. +func (m *metricFaasInvocations) init() { + m.data.SetName("faas.invocations") + m.data.SetDescription("Number of successful invocations") + m.data.SetUnit("{invocation}") + m.data.SetEmptySum() + m.data.Sum().SetIsMonotonic(true) + m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityDelta) + m.data.Sum().DataPoints().EnsureCapacity(m.capacity) +} + +func (m *metricFaasInvocations) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, faasTriggerAttributeValue string) { + if !m.config.Enabled { + return + } + dp := m.data.Sum().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) + dp.Attributes().PutStr("faas.trigger", faasTriggerAttributeValue) +} + +// updateCapacity saves max length of data point slices that will be used for the slice capacity. +func (m *metricFaasInvocations) updateCapacity() { + if m.data.Sum().DataPoints().Len() > m.capacity { + m.capacity = m.data.Sum().DataPoints().Len() + } +} + +// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. +func (m *metricFaasInvocations) emit(metrics pmetric.MetricSlice) { + if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + m.updateCapacity() + m.data.MoveTo(metrics.AppendEmpty()) + m.init() + } +} + +func newMetricFaasInvocations(cfg MetricConfig) metricFaasInvocations { + m := metricFaasInvocations{config: cfg} + if cfg.Enabled { + m.data = pmetric.NewMetric() + m.init() + } + return m +} + +type metricFaasTimeouts struct { + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. +} + +// init fills faas.timeouts metric with initial data. +func (m *metricFaasTimeouts) init() { + m.data.SetName("faas.timeouts") + m.data.SetDescription("Number of invocation timeouts") + m.data.SetUnit("{timeout}") + m.data.SetEmptySum() + m.data.Sum().SetIsMonotonic(true) + m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityDelta) + m.data.Sum().DataPoints().EnsureCapacity(m.capacity) +} + +func (m *metricFaasTimeouts) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, faasTriggerAttributeValue string) { + if !m.config.Enabled { + return + } + dp := m.data.Sum().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) + dp.Attributes().PutStr("faas.trigger", faasTriggerAttributeValue) +} + +// updateCapacity saves max length of data point slices that will be used for the slice capacity. +func (m *metricFaasTimeouts) updateCapacity() { + if m.data.Sum().DataPoints().Len() > m.capacity { + m.capacity = m.data.Sum().DataPoints().Len() + } +} + +// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. +func (m *metricFaasTimeouts) emit(metrics pmetric.MetricSlice) { + if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + m.updateCapacity() + m.data.MoveTo(metrics.AppendEmpty()) + m.init() + } +} + +func newMetricFaasTimeouts(cfg MetricConfig) metricFaasTimeouts { + m := metricFaasTimeouts{config: cfg} if cfg.Enabled { m.data = pmetric.NewMetric() m.init() @@ -107,12 +266,15 @@ func newMetricFaasColdstart(cfg MetricConfig) metricFaasColdstart { // MetricsBuilder provides an interface for scrapers to report metrics while taking care of all the transformations // required to produce metric representation defined in metadata and user config. type MetricsBuilder struct { - config MetricsBuilderConfig // config of the metrics builder. - startTime pcommon.Timestamp // start time that will be applied to all recorded data points. - metricsCapacity int // maximum observed number of metrics per resource. - metricsBuffer pmetric.Metrics // accumulates metrics data before emitting. - buildInfo component.BuildInfo // contains version information. - metricFaasColdstart metricFaasColdstart + config MetricsBuilderConfig // config of the metrics builder. + startTime pcommon.Timestamp // start time that will be applied to all recorded data points. + metricsCapacity int // maximum observed number of metrics per resource. + metricsBuffer pmetric.Metrics // accumulates metrics data before emitting. + buildInfo component.BuildInfo // contains version information. + metricFaasColdstarts metricFaasColdstarts + metricFaasErrors metricFaasErrors + metricFaasInvocations metricFaasInvocations + metricFaasTimeouts metricFaasTimeouts } // metricBuilderOption applies changes to default metrics builder. @@ -127,11 +289,14 @@ func WithStartTime(startTime pcommon.Timestamp) metricBuilderOption { func NewMetricsBuilder(mbc MetricsBuilderConfig, settings receiver.Settings, options ...metricBuilderOption) *MetricsBuilder { mb := &MetricsBuilder{ - config: mbc, - startTime: pcommon.NewTimestampFromTime(time.Now()), - metricsBuffer: pmetric.NewMetrics(), - buildInfo: settings.BuildInfo, - metricFaasColdstart: newMetricFaasColdstart(mbc.Metrics.FaasColdstart), + config: mbc, + startTime: pcommon.NewTimestampFromTime(time.Now()), + metricsBuffer: pmetric.NewMetrics(), + buildInfo: settings.BuildInfo, + metricFaasColdstarts: newMetricFaasColdstarts(mbc.Metrics.FaasColdstarts), + metricFaasErrors: newMetricFaasErrors(mbc.Metrics.FaasErrors), + metricFaasInvocations: newMetricFaasInvocations(mbc.Metrics.FaasInvocations), + metricFaasTimeouts: newMetricFaasTimeouts(mbc.Metrics.FaasTimeouts), } for _, op := range options { @@ -189,7 +354,10 @@ func (mb *MetricsBuilder) EmitForResource(rmo ...ResourceMetricsOption) { ils.Scope().SetName("github.com/open-telemetry/opentelemetry-lambda/collector/receiver/telemetryapireceiver") ils.Scope().SetVersion(mb.buildInfo.Version) ils.Metrics().EnsureCapacity(mb.metricsCapacity) - mb.metricFaasColdstart.emit(ils.Metrics()) + mb.metricFaasColdstarts.emit(ils.Metrics()) + mb.metricFaasErrors.emit(ils.Metrics()) + mb.metricFaasInvocations.emit(ils.Metrics()) + mb.metricFaasTimeouts.emit(ils.Metrics()) for _, op := range rmo { op(rm) @@ -211,13 +379,43 @@ func (mb *MetricsBuilder) Emit(rmo ...ResourceMetricsOption) pmetric.Metrics { return metrics } -// RecordFaasColdstartDataPoint adds a data point to faas.coldstart metric. -func (mb *MetricsBuilder) RecordFaasColdstartDataPoint(ts pcommon.Timestamp, inputVal string, faasTriggerAttributeValue AttributeFaasTrigger) error { +// RecordFaasColdstartsDataPoint adds a data point to faas.coldstarts metric. +func (mb *MetricsBuilder) RecordFaasColdstartsDataPoint(ts pcommon.Timestamp, inputVal string, faasTriggerAttributeValue AttributeFaasTrigger) error { + val, err := strconv.ParseInt(inputVal, 10, 64) + if err != nil { + return fmt.Errorf("failed to parse int64 for FaasColdstarts, value was %s: %w", inputVal, err) + } + mb.metricFaasColdstarts.recordDataPoint(mb.startTime, ts, val, faasTriggerAttributeValue.String()) + return nil +} + +// RecordFaasErrorsDataPoint adds a data point to faas.errors metric. +func (mb *MetricsBuilder) RecordFaasErrorsDataPoint(ts pcommon.Timestamp, inputVal string, faasTriggerAttributeValue AttributeFaasTrigger) error { + val, err := strconv.ParseInt(inputVal, 10, 64) + if err != nil { + return fmt.Errorf("failed to parse int64 for FaasErrors, value was %s: %w", inputVal, err) + } + mb.metricFaasErrors.recordDataPoint(mb.startTime, ts, val, faasTriggerAttributeValue.String()) + return nil +} + +// RecordFaasInvocationsDataPoint adds a data point to faas.invocations metric. +func (mb *MetricsBuilder) RecordFaasInvocationsDataPoint(ts pcommon.Timestamp, inputVal string, faasTriggerAttributeValue AttributeFaasTrigger) error { + val, err := strconv.ParseInt(inputVal, 10, 64) + if err != nil { + return fmt.Errorf("failed to parse int64 for FaasInvocations, value was %s: %w", inputVal, err) + } + mb.metricFaasInvocations.recordDataPoint(mb.startTime, ts, val, faasTriggerAttributeValue.String()) + return nil +} + +// RecordFaasTimeoutsDataPoint adds a data point to faas.timeouts metric. +func (mb *MetricsBuilder) RecordFaasTimeoutsDataPoint(ts pcommon.Timestamp, inputVal string, faasTriggerAttributeValue AttributeFaasTrigger) error { val, err := strconv.ParseInt(inputVal, 10, 64) if err != nil { - return fmt.Errorf("failed to parse int64 for FaasColdstart, value was %s: %w", inputVal, err) + return fmt.Errorf("failed to parse int64 for FaasTimeouts, value was %s: %w", inputVal, err) } - mb.metricFaasColdstart.recordDataPoint(mb.startTime, ts, val, faasTriggerAttributeValue.String()) + mb.metricFaasTimeouts.recordDataPoint(mb.startTime, ts, val, faasTriggerAttributeValue.String()) return nil } diff --git a/collector/receiver/telemetryapireceiver/internal/metadata/generated_metrics_test.go b/collector/receiver/telemetryapireceiver/internal/metadata/generated_metrics_test.go index 2e0a1e913c..20335f0ac0 100644 --- a/collector/receiver/telemetryapireceiver/internal/metadata/generated_metrics_test.go +++ b/collector/receiver/telemetryapireceiver/internal/metadata/generated_metrics_test.go @@ -61,7 +61,19 @@ func TestMetricsBuilder(t *testing.T) { defaultMetricsCount++ allMetricsCount++ - mb.RecordFaasColdstartDataPoint(ts, "1", AttributeFaasTriggerDatasource) + mb.RecordFaasColdstartsDataPoint(ts, "1", AttributeFaasTriggerDatasource) + + defaultMetricsCount++ + allMetricsCount++ + mb.RecordFaasErrorsDataPoint(ts, "1", AttributeFaasTriggerDatasource) + + defaultMetricsCount++ + allMetricsCount++ + mb.RecordFaasInvocationsDataPoint(ts, "1", AttributeFaasTriggerDatasource) + + defaultMetricsCount++ + allMetricsCount++ + mb.RecordFaasTimeoutsDataPoint(ts, "1", AttributeFaasTriggerDatasource) res := pcommon.NewResource() metrics := mb.Emit(WithResource(res)) @@ -85,15 +97,66 @@ func TestMetricsBuilder(t *testing.T) { validatedMetrics := make(map[string]bool) for i := 0; i < ms.Len(); i++ { switch ms.At(i).Name() { - case "faas.coldstart": - assert.False(t, validatedMetrics["faas.coldstart"], "Found a duplicate in the metrics slice: faas.coldstart") - validatedMetrics["faas.coldstart"] = true + case "faas.coldstarts": + assert.False(t, validatedMetrics["faas.coldstarts"], "Found a duplicate in the metrics slice: faas.coldstarts") + validatedMetrics["faas.coldstarts"] = true assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) assert.Equal(t, "Number of invocation cold starts", ms.At(i).Description()) assert.Equal(t, "{coldstart}", ms.At(i).Unit()) assert.Equal(t, true, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + assert.Equal(t, pmetric.AggregationTemporalityDelta, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("faas.trigger") + assert.True(t, ok) + assert.EqualValues(t, "datasource", attrVal.Str()) + case "faas.errors": + assert.False(t, validatedMetrics["faas.errors"], "Found a duplicate in the metrics slice: faas.errors") + validatedMetrics["faas.errors"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "Number of invocation errors", ms.At(i).Description()) + assert.Equal(t, "{error}", ms.At(i).Unit()) + assert.Equal(t, true, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityDelta, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("faas.trigger") + assert.True(t, ok) + assert.EqualValues(t, "datasource", attrVal.Str()) + case "faas.invocations": + assert.False(t, validatedMetrics["faas.invocations"], "Found a duplicate in the metrics slice: faas.invocations") + validatedMetrics["faas.invocations"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "Number of successful invocations", ms.At(i).Description()) + assert.Equal(t, "{invocation}", ms.At(i).Unit()) + assert.Equal(t, true, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityDelta, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("faas.trigger") + assert.True(t, ok) + assert.EqualValues(t, "datasource", attrVal.Str()) + case "faas.timeouts": + assert.False(t, validatedMetrics["faas.timeouts"], "Found a duplicate in the metrics slice: faas.timeouts") + validatedMetrics["faas.timeouts"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "Number of invocation timeouts", ms.At(i).Description()) + assert.Equal(t, "{timeout}", ms.At(i).Unit()) + assert.Equal(t, true, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityDelta, ms.At(i).Sum().AggregationTemporality()) dp := ms.At(i).Sum().DataPoints().At(0) assert.Equal(t, start, dp.StartTimestamp()) assert.Equal(t, ts, dp.Timestamp()) diff --git a/collector/receiver/telemetryapireceiver/internal/metadata/testdata/config.yaml b/collector/receiver/telemetryapireceiver/internal/metadata/testdata/config.yaml index 96fdd28191..5c2da193b8 100644 --- a/collector/receiver/telemetryapireceiver/internal/metadata/testdata/config.yaml +++ b/collector/receiver/telemetryapireceiver/internal/metadata/testdata/config.yaml @@ -1,9 +1,21 @@ default: all_set: metrics: - faas.coldstart: + faas.coldstarts: + enabled: true + faas.errors: + enabled: true + faas.invocations: + enabled: true + faas.timeouts: enabled: true none_set: metrics: - faas.coldstart: + faas.coldstarts: + enabled: false + faas.errors: + enabled: false + faas.invocations: + enabled: false + faas.timeouts: enabled: false diff --git a/collector/receiver/telemetryapireceiver/metadata.yaml b/collector/receiver/telemetryapireceiver/metadata.yaml index 55214d13c6..18ee649114 100644 --- a/collector/receiver/telemetryapireceiver/metadata.yaml +++ b/collector/receiver/telemetryapireceiver/metadata.yaml @@ -19,7 +19,7 @@ attributes: - timer metrics: - faas.coldstart: + faas.coldstarts: enabled: true description: Number of invocation cold starts unit: '{coldstart}' @@ -28,4 +28,34 @@ metrics: value_type: int input_type: string monotonic: true - aggregation_temporality: cumulative \ No newline at end of file + aggregation_temporality: delta + faas.errors: + enabled: true + description: Number of invocation errors + unit: '{error}' + attributes: [faas_trigger] + sum: + value_type: int + input_type: string + monotonic: true + aggregation_temporality: delta + faas.invocations: + enabled: true + description: Number of successful invocations + unit: '{invocation}' + attributes: [faas_trigger] + sum: + value_type: int + input_type: string + monotonic: true + aggregation_temporality: delta + faas.timeouts: + enabled: true + description: Number of invocation timeouts + unit: '{timeout}' + attributes: [faas_trigger] + sum: + value_type: int + input_type: string + monotonic: true + aggregation_temporality: delta