mirror of
https://github.com/hanzoai/telemetry.git
synced 2026-10-30 20:01:49 +00:00
#### Description This is to align the metric units with [OTel specification](https://opentelemetry.io/docs/specs/semconv/general/metrics/#instrument-units): > All non-units that use curly braces to annotate a quantity need to match the grammatical number of the quantity it represent. For example if measuring the number of individual requests to a process the unit would be **{request}, not {requests}**. #### Link to tracking issue Part of https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/45270 ❓ Is there a way for this change to surface to users as a breaking change? --------- Co-authored-by: Pablo Baeyens <[email protected]>
102 lines
3.8 KiB
Go
102 lines
3.8 KiB
Go
// Code generated by mdatagen. DO NOT EDIT.
|
|
|
|
package metadatatest
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"go.opentelemetry.io/otel/sdk/metric/metricdata"
|
|
"go.opentelemetry.io/otel/sdk/metric/metricdata/metricdatatest"
|
|
|
|
"go.opentelemetry.io/collector/component"
|
|
"go.opentelemetry.io/collector/component/componenttest"
|
|
"go.opentelemetry.io/collector/processor"
|
|
"go.opentelemetry.io/collector/processor/processortest"
|
|
)
|
|
|
|
func NewSettings(tt *componenttest.Telemetry) processor.Settings {
|
|
set := processortest.NewNopSettings(processortest.NopType)
|
|
set.ID = component.NewID(component.MustNewType("batch"))
|
|
set.TelemetrySettings = tt.NewTelemetrySettings()
|
|
return set
|
|
}
|
|
|
|
func AssertEqualProcessorBatchBatchSendSize(t *testing.T, tt *componenttest.Telemetry, dps []metricdata.HistogramDataPoint[int64], opts ...metricdatatest.Option) {
|
|
want := metricdata.Metrics{
|
|
Name: "otelcol_processor_batch_batch_send_size",
|
|
Description: "Number of units in the batch [Development]",
|
|
Unit: "{unit}",
|
|
Data: metricdata.Histogram[int64]{
|
|
Temporality: metricdata.CumulativeTemporality,
|
|
DataPoints: dps,
|
|
},
|
|
}
|
|
got, err := tt.GetMetric("otelcol_processor_batch_batch_send_size")
|
|
require.NoError(t, err)
|
|
metricdatatest.AssertEqual(t, want, got, opts...)
|
|
}
|
|
|
|
func AssertEqualProcessorBatchBatchSendSizeBytes(t *testing.T, tt *componenttest.Telemetry, dps []metricdata.HistogramDataPoint[int64], opts ...metricdatatest.Option) {
|
|
want := metricdata.Metrics{
|
|
Name: "otelcol_processor_batch_batch_send_size_bytes",
|
|
Description: "Number of bytes in batch that was sent. Only available on detailed level. [Development]",
|
|
Unit: "By",
|
|
Data: metricdata.Histogram[int64]{
|
|
Temporality: metricdata.CumulativeTemporality,
|
|
DataPoints: dps,
|
|
},
|
|
}
|
|
got, err := tt.GetMetric("otelcol_processor_batch_batch_send_size_bytes")
|
|
require.NoError(t, err)
|
|
metricdatatest.AssertEqual(t, want, got, opts...)
|
|
}
|
|
|
|
func AssertEqualProcessorBatchBatchSizeTriggerSend(t *testing.T, tt *componenttest.Telemetry, dps []metricdata.DataPoint[int64], opts ...metricdatatest.Option) {
|
|
want := metricdata.Metrics{
|
|
Name: "otelcol_processor_batch_batch_size_trigger_send",
|
|
Description: "Number of times the batch was sent due to a size trigger [Development]",
|
|
Unit: "{time}",
|
|
Data: metricdata.Sum[int64]{
|
|
Temporality: metricdata.CumulativeTemporality,
|
|
IsMonotonic: true,
|
|
DataPoints: dps,
|
|
},
|
|
}
|
|
got, err := tt.GetMetric("otelcol_processor_batch_batch_size_trigger_send")
|
|
require.NoError(t, err)
|
|
metricdatatest.AssertEqual(t, want, got, opts...)
|
|
}
|
|
|
|
func AssertEqualProcessorBatchMetadataCardinality(t *testing.T, tt *componenttest.Telemetry, dps []metricdata.DataPoint[int64], opts ...metricdatatest.Option) {
|
|
want := metricdata.Metrics{
|
|
Name: "otelcol_processor_batch_metadata_cardinality",
|
|
Description: "Number of distinct metadata value combinations being processed [Development]",
|
|
Unit: "{combination}",
|
|
Data: metricdata.Sum[int64]{
|
|
Temporality: metricdata.CumulativeTemporality,
|
|
IsMonotonic: false,
|
|
DataPoints: dps,
|
|
},
|
|
}
|
|
got, err := tt.GetMetric("otelcol_processor_batch_metadata_cardinality")
|
|
require.NoError(t, err)
|
|
metricdatatest.AssertEqual(t, want, got, opts...)
|
|
}
|
|
|
|
func AssertEqualProcessorBatchTimeoutTriggerSend(t *testing.T, tt *componenttest.Telemetry, dps []metricdata.DataPoint[int64], opts ...metricdatatest.Option) {
|
|
want := metricdata.Metrics{
|
|
Name: "otelcol_processor_batch_timeout_trigger_send",
|
|
Description: "Number of times the batch was sent due to a timeout trigger [Development]",
|
|
Unit: "{time}",
|
|
Data: metricdata.Sum[int64]{
|
|
Temporality: metricdata.CumulativeTemporality,
|
|
IsMonotonic: true,
|
|
DataPoints: dps,
|
|
},
|
|
}
|
|
got, err := tt.GetMetric("otelcol_processor_batch_timeout_trigger_send")
|
|
require.NoError(t, err)
|
|
metricdatatest.AssertEqual(t, want, got, opts...)
|
|
}
|