diff --git a/model/internal/cmd/pdatagen/internal/metrics_structs.go b/model/internal/cmd/pdatagen/internal/metrics_structs.go index 13058d73694..18382de9a5f 100644 --- a/model/internal/cmd/pdatagen/internal/metrics_structs.go +++ b/model/internal/cmd/pdatagen/internal/metrics_structs.go @@ -294,32 +294,14 @@ var histogramDataPoint = &messageValueStruct{ originFieldName: "Min_", originTypePrefix: "otlpmetrics.HistogramDataPoint_", testValueIdx: 0, // Double - values: []oneOfValue{ - &oneOfPrimitiveValue{ - fieldName: "Min", - fieldType: "Double", - originFieldName: "Min", - returnType: "float64", - defaultVal: "float64(0.0)", - testVal: "float64(17.13)", - }, - }, + values: []oneOfValue{minField}, }, &oneOfField{ typeName: "OptionalType", originFieldName: "Max_", originTypePrefix: "otlpmetrics.HistogramDataPoint_", testValueIdx: 0, // Double - values: []oneOfValue{ - &oneOfPrimitiveValue{ - fieldName: "Max", - fieldType: "Double", - originFieldName: "Max", - returnType: "float64", - defaultVal: "float64(0.0)", - testVal: "float64(17.13)", - }, - }, + values: []oneOfValue{maxField}, }, }, } @@ -370,6 +352,20 @@ var exponentialHistogramDataPoint = &messageValueStruct{ }, exemplarsField, dataPointFlagsField, + &oneOfField{ + typeName: "OptionalType", + originFieldName: "Min_", + originTypePrefix: "otlpmetrics.ExponentialHistogramDataPoint_", + testValueIdx: 0, // Double + values: []oneOfValue{minField}, + }, + &oneOfField{ + typeName: "OptionalType", + originFieldName: "Max_", + originTypePrefix: "otlpmetrics.ExponentialHistogramDataPoint_", + testValueIdx: 0, // Double + values: []oneOfValue{maxField}, + }, }, } @@ -556,3 +552,21 @@ var dataPointFlagsField = &primitiveTypedField{ defaultVal: "MetricDataPointFlagsNone", testVal: "MetricDataPointFlagsNone", } + +var minField = &oneOfPrimitiveValue{ + fieldName: "Min", + fieldType: "Double", + originFieldName: "Min", + returnType: "float64", + defaultVal: "float64(0.0)", + testVal: "float64(17.13)", +} + +var maxField = &oneOfPrimitiveValue{ + fieldName: "Max", + fieldType: "Double", + originFieldName: "Max", + returnType: "float64", + defaultVal: "float64(0.0)", + testVal: "float64(17.13)", +} diff --git a/model/pdata/generated_metrics.go b/model/pdata/generated_metrics.go index b759e338e24..bf7e75e73fe 100644 --- a/model/pdata/generated_metrics.go +++ b/model/pdata/generated_metrics.go @@ -1765,6 +1765,50 @@ func (ms ExponentialHistogramDataPoint) SetFlags(v MetricDataPointFlags) { (*ms.orig).Flags = uint32(v) } +// Min_Type returns the type of the min_ for this ExponentialHistogramDataPoint. +// Calling this function on zero-initialized ExponentialHistogramDataPoint will cause a panic. +func (ms ExponentialHistogramDataPoint) Min_Type() OptionalType { + switch ms.orig.Min_.(type) { + case *otlpmetrics.ExponentialHistogramDataPoint_Min: + return OptionalTypeDouble + } + return OptionalTypeNone +} + +// Min returns the min associated with this ExponentialHistogramDataPoint. +func (ms ExponentialHistogramDataPoint) Min() float64 { + return (*ms.orig).GetMin() +} + +// SetMin replaces the min associated with this ExponentialHistogramDataPoint. +func (ms ExponentialHistogramDataPoint) SetMin(v float64) { + (*ms.orig).Min_ = &otlpmetrics.ExponentialHistogramDataPoint_Min{ + Min: v, + } +} + +// Max_Type returns the type of the max_ for this ExponentialHistogramDataPoint. +// Calling this function on zero-initialized ExponentialHistogramDataPoint will cause a panic. +func (ms ExponentialHistogramDataPoint) Max_Type() OptionalType { + switch ms.orig.Max_.(type) { + case *otlpmetrics.ExponentialHistogramDataPoint_Max: + return OptionalTypeDouble + } + return OptionalTypeNone +} + +// Max returns the max associated with this ExponentialHistogramDataPoint. +func (ms ExponentialHistogramDataPoint) Max() float64 { + return (*ms.orig).GetMax() +} + +// SetMax replaces the max associated with this ExponentialHistogramDataPoint. +func (ms ExponentialHistogramDataPoint) SetMax(v float64) { + (*ms.orig).Max_ = &otlpmetrics.ExponentialHistogramDataPoint_Max{ + Max: v, + } +} + // CopyTo copies all properties from the current struct to the dest. func (ms ExponentialHistogramDataPoint) CopyTo(dest ExponentialHistogramDataPoint) { ms.Attributes().CopyTo(dest.Attributes()) @@ -1778,6 +1822,16 @@ func (ms ExponentialHistogramDataPoint) CopyTo(dest ExponentialHistogramDataPoin ms.Negative().CopyTo(dest.Negative()) ms.Exemplars().CopyTo(dest.Exemplars()) dest.SetFlags(ms.Flags()) + switch ms.Min_Type() { + case OptionalTypeDouble: + dest.SetMin(ms.Min()) + } + + switch ms.Max_Type() { + case OptionalTypeDouble: + dest.SetMax(ms.Max()) + } + } // Buckets are a set of bucket counts, encoded in a contiguous array of counts. diff --git a/model/pdata/generated_metrics_test.go b/model/pdata/generated_metrics_test.go index b4618370058..18ffa71fc4a 100644 --- a/model/pdata/generated_metrics_test.go +++ b/model/pdata/generated_metrics_test.go @@ -1334,6 +1334,38 @@ func TestExponentialHistogramDataPoint_Flags(t *testing.T) { assert.EqualValues(t, testValFlags, ms.Flags()) } +func TestExponentialHistogramDataPointMin_Type(t *testing.T) { + tv := NewExponentialHistogramDataPoint() + assert.Equal(t, OptionalTypeNone, tv.Min_Type()) + assert.Equal(t, "", OptionalType(1000).String()) + tv.SetMin(float64(17.13)) + assert.Equal(t, OptionalTypeDouble, tv.Min_Type()) +} + +func TestExponentialHistogramDataPoint_Min(t *testing.T) { + ms := NewExponentialHistogramDataPoint() + assert.EqualValues(t, float64(0.0), ms.Min()) + testValMin := float64(17.13) + ms.SetMin(testValMin) + assert.EqualValues(t, testValMin, ms.Min()) +} + +func TestExponentialHistogramDataPointMax_Type(t *testing.T) { + tv := NewExponentialHistogramDataPoint() + assert.Equal(t, OptionalTypeNone, tv.Max_Type()) + assert.Equal(t, "", OptionalType(1000).String()) + tv.SetMax(float64(17.13)) + assert.Equal(t, OptionalTypeDouble, tv.Max_Type()) +} + +func TestExponentialHistogramDataPoint_Max(t *testing.T) { + ms := NewExponentialHistogramDataPoint() + assert.EqualValues(t, float64(0.0), ms.Max()) + testValMax := float64(17.13) + ms.SetMax(testValMax) + assert.EqualValues(t, testValMax, ms.Max()) +} + func TestBuckets_MoveTo(t *testing.T) { ms := generateTestBuckets() dest := NewBuckets() @@ -2086,6 +2118,8 @@ func fillTestExponentialHistogramDataPoint(tv ExponentialHistogramDataPoint) { fillTestBuckets(tv.Negative()) fillTestExemplarSlice(tv.Exemplars()) tv.SetFlags(MetricDataPointFlagsNone) + tv.SetMin(float64(17.13)) + tv.SetMax(float64(17.13)) } func generateTestBuckets() Buckets {