mirror of
https://github.com/hanzoai/telemetry.git
synced 2026-10-30 20:01:49 +00:00
This PR fixes how `mdatagen` handles deprecated metric fields in `metadata.yaml`. The metadata loader now aligns correctly with the schema and test expectations, ensuring deprecated fields are only set when explicitly defined. ## What was changed? - Updated metadata loading logic to correctly handle deprecated metric fields - Ensured deprecated fields are only set when explicitly specified - Aligned generated metadata with existing test expectations - All existing and sample `mdatagen` tests pass after this change --- ## Testing - `go test ./cmd/mdatagen/...` - Verified all sample metadata generators and internal tests pass - All `mdatagen` tests pass. --- *Related:* https://github.com/open-telemetry/opentelemetry-collector/issues/14113 N/A (internal correctness and test alignment fix) --------- Co-authored-by: Damien Mathieu <[email protected]>
120 lines
4.5 KiB
Go
120 lines
4.5 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("memory_limiter"))
|
|
set.TelemetrySettings = tt.NewTelemetrySettings()
|
|
return set
|
|
}
|
|
|
|
func AssertEqualProcessorAcceptedLogRecords(t *testing.T, tt *componenttest.Telemetry, dps []metricdata.DataPoint[int64], opts ...metricdatatest.Option) {
|
|
want := metricdata.Metrics{
|
|
Name: "otelcol_processor_accepted_log_records",
|
|
Description: "Number of log records successfully pushed into the next component in the pipeline. [Deprecated]",
|
|
Unit: "{records}",
|
|
Data: metricdata.Sum[int64]{
|
|
Temporality: metricdata.CumulativeTemporality,
|
|
IsMonotonic: true,
|
|
DataPoints: dps,
|
|
},
|
|
}
|
|
got, err := tt.GetMetric("otelcol_processor_accepted_log_records")
|
|
require.NoError(t, err)
|
|
metricdatatest.AssertEqual(t, want, got, opts...)
|
|
}
|
|
|
|
func AssertEqualProcessorAcceptedMetricPoints(t *testing.T, tt *componenttest.Telemetry, dps []metricdata.DataPoint[int64], opts ...metricdatatest.Option) {
|
|
want := metricdata.Metrics{
|
|
Name: "otelcol_processor_accepted_metric_points",
|
|
Description: "Number of metric points successfully pushed into the next component in the pipeline. [Deprecated]",
|
|
Unit: "{datapoints}",
|
|
Data: metricdata.Sum[int64]{
|
|
Temporality: metricdata.CumulativeTemporality,
|
|
IsMonotonic: true,
|
|
DataPoints: dps,
|
|
},
|
|
}
|
|
got, err := tt.GetMetric("otelcol_processor_accepted_metric_points")
|
|
require.NoError(t, err)
|
|
metricdatatest.AssertEqual(t, want, got, opts...)
|
|
}
|
|
|
|
func AssertEqualProcessorAcceptedSpans(t *testing.T, tt *componenttest.Telemetry, dps []metricdata.DataPoint[int64], opts ...metricdatatest.Option) {
|
|
want := metricdata.Metrics{
|
|
Name: "otelcol_processor_accepted_spans",
|
|
Description: "Number of spans successfully pushed into the next component in the pipeline. [Deprecated]",
|
|
Unit: "{spans}",
|
|
Data: metricdata.Sum[int64]{
|
|
Temporality: metricdata.CumulativeTemporality,
|
|
IsMonotonic: true,
|
|
DataPoints: dps,
|
|
},
|
|
}
|
|
got, err := tt.GetMetric("otelcol_processor_accepted_spans")
|
|
require.NoError(t, err)
|
|
metricdatatest.AssertEqual(t, want, got, opts...)
|
|
}
|
|
|
|
func AssertEqualProcessorRefusedLogRecords(t *testing.T, tt *componenttest.Telemetry, dps []metricdata.DataPoint[int64], opts ...metricdatatest.Option) {
|
|
want := metricdata.Metrics{
|
|
Name: "otelcol_processor_refused_log_records",
|
|
Description: "Number of log records that were rejected by the next component in the pipeline. [Deprecated]",
|
|
Unit: "{records}",
|
|
Data: metricdata.Sum[int64]{
|
|
Temporality: metricdata.CumulativeTemporality,
|
|
IsMonotonic: true,
|
|
DataPoints: dps,
|
|
},
|
|
}
|
|
got, err := tt.GetMetric("otelcol_processor_refused_log_records")
|
|
require.NoError(t, err)
|
|
metricdatatest.AssertEqual(t, want, got, opts...)
|
|
}
|
|
|
|
func AssertEqualProcessorRefusedMetricPoints(t *testing.T, tt *componenttest.Telemetry, dps []metricdata.DataPoint[int64], opts ...metricdatatest.Option) {
|
|
want := metricdata.Metrics{
|
|
Name: "otelcol_processor_refused_metric_points",
|
|
Description: "Number of metric points that were rejected by the next component in the pipeline. [Deprecated]",
|
|
Unit: "{datapoints}",
|
|
Data: metricdata.Sum[int64]{
|
|
Temporality: metricdata.CumulativeTemporality,
|
|
IsMonotonic: true,
|
|
DataPoints: dps,
|
|
},
|
|
}
|
|
got, err := tt.GetMetric("otelcol_processor_refused_metric_points")
|
|
require.NoError(t, err)
|
|
metricdatatest.AssertEqual(t, want, got, opts...)
|
|
}
|
|
|
|
func AssertEqualProcessorRefusedSpans(t *testing.T, tt *componenttest.Telemetry, dps []metricdata.DataPoint[int64], opts ...metricdatatest.Option) {
|
|
want := metricdata.Metrics{
|
|
Name: "otelcol_processor_refused_spans",
|
|
Description: "Number of spans that were rejected by the next component in the pipeline. [Deprecated]",
|
|
Unit: "{spans}",
|
|
Data: metricdata.Sum[int64]{
|
|
Temporality: metricdata.CumulativeTemporality,
|
|
IsMonotonic: true,
|
|
DataPoints: dps,
|
|
},
|
|
}
|
|
got, err := tt.GetMetric("otelcol_processor_refused_spans")
|
|
require.NoError(t, err)
|
|
metricdatatest.AssertEqual(t, want, got, opts...)
|
|
}
|