diff --git a/CHANGELOG.md b/CHANGELOG.md index 202859e4e98..45154704f1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,8 @@ - Deprecate `pcommon.NewValueBytesEmpty` in favor of `pcommon.NewValueBytes` that now has the same signature. (#6105) - Deprecate `pmetric.MetricDataType` and related constants in favor of `pmetric.MetricType`. (#6127) - Deprecate `pmetric.Metric.DataType()` in favor of `pmetric.Metric.Type()`. (#6127) +- Deprecate `pmetric.NumberDataPoint.[Set]?[Int|Double]Val()` in favor of `pmetric.NumberDataPoint.[Set]?[Int|Double]Value()`. (#6134) +- Deprecate `pmetric.Exemplar.[Set]?[Int|Double]Val()` in favor of `pmetric.Exemplar.[Set]?[Int|Double]Value()`. (#6134) ### 💡 Enhancements 💡 diff --git a/exporter/loggingexporter/internal/otlptext/databuffer.go b/exporter/loggingexporter/internal/otlptext/databuffer.go index 44ecd45425f..162174024b5 100644 --- a/exporter/loggingexporter/internal/otlptext/databuffer.go +++ b/exporter/loggingexporter/internal/otlptext/databuffer.go @@ -102,9 +102,9 @@ func (b *dataBuffer) logNumberDataPoints(ps pmetric.NumberDataPointSlice) { b.logEntry("Timestamp: %s", p.Timestamp()) switch p.ValueType() { case pmetric.NumberDataPointValueTypeInt: - b.logEntry("Value: %d", p.IntVal()) + b.logEntry("Value: %d", p.IntValue()) case pmetric.NumberDataPointValueTypeDouble: - b.logEntry("Value: %f", p.DoubleVal()) + b.logEntry("Value: %f", p.DoubleValue()) } } } diff --git a/internal/testdata/metric.go b/internal/testdata/metric.go index 2c74179b412..eaec3478700 100644 --- a/internal/testdata/metric.go +++ b/internal/testdata/metric.go @@ -121,12 +121,12 @@ func initGaugeIntMetric(im pmetric.Metric) { initMetricAttributes1(idp0.Attributes()) idp0.SetStartTimestamp(metricStartTimestamp) idp0.SetTimestamp(metricTimestamp) - idp0.SetIntVal(123) + idp0.SetIntValue(123) idp1 := idps.AppendEmpty() initMetricAttributes2(idp1.Attributes()) idp1.SetStartTimestamp(metricStartTimestamp) idp1.SetTimestamp(metricTimestamp) - idp1.SetIntVal(456) + idp1.SetIntValue(456) } func initGaugeDoubleMetric(im pmetric.Metric) { @@ -137,12 +137,12 @@ func initGaugeDoubleMetric(im pmetric.Metric) { initMetricAttributes12(idp0.Attributes()) idp0.SetStartTimestamp(metricStartTimestamp) idp0.SetTimestamp(metricTimestamp) - idp0.SetDoubleVal(1.23) + idp0.SetDoubleValue(1.23) idp1 := idps.AppendEmpty() initMetricAttributes13(idp1.Attributes()) idp1.SetStartTimestamp(metricStartTimestamp) idp1.SetTimestamp(metricTimestamp) - idp1.SetDoubleVal(4.56) + idp1.SetDoubleValue(4.56) } func initSumIntMetric(im pmetric.Metric) { @@ -153,12 +153,12 @@ func initSumIntMetric(im pmetric.Metric) { initMetricAttributes1(idp0.Attributes()) idp0.SetStartTimestamp(metricStartTimestamp) idp0.SetTimestamp(metricTimestamp) - idp0.SetIntVal(123) + idp0.SetIntValue(123) idp1 := idps.AppendEmpty() initMetricAttributes2(idp1.Attributes()) idp1.SetStartTimestamp(metricStartTimestamp) idp1.SetTimestamp(metricTimestamp) - idp1.SetIntVal(456) + idp1.SetIntValue(456) } func initSumDoubleMetric(dm pmetric.Metric) { @@ -169,13 +169,13 @@ func initSumDoubleMetric(dm pmetric.Metric) { initMetricAttributes12(ddp0.Attributes()) ddp0.SetStartTimestamp(metricStartTimestamp) ddp0.SetTimestamp(metricTimestamp) - ddp0.SetDoubleVal(1.23) + ddp0.SetDoubleValue(1.23) ddp1 := ddps.AppendEmpty() initMetricAttributes13(ddp1.Attributes()) ddp1.SetStartTimestamp(metricStartTimestamp) ddp1.SetTimestamp(metricTimestamp) - ddp1.SetDoubleVal(4.56) + ddp1.SetDoubleValue(4.56) } func initHistogramMetric(hm pmetric.Metric) { @@ -200,7 +200,7 @@ func initHistogramMetric(hm pmetric.Metric) { hdp1.BucketCounts().FromRaw([]uint64{0, 1}) exemplar := hdp1.Exemplars().AppendEmpty() exemplar.SetTimestamp(metricExemplarTimestamp) - exemplar.SetDoubleVal(15) + exemplar.SetDoubleValue(15) initMetricExemplarAttributes(exemplar.FilteredAttributes()) hdp1.ExplicitBounds().FromRaw([]float64{1}) } @@ -254,7 +254,7 @@ func initExponentialHistogramMetric(hm pmetric.Metric) { exemplar := hdp1.Exemplars().AppendEmpty() exemplar.SetTimestamp(metricExemplarTimestamp) - exemplar.SetDoubleVal(15) + exemplar.SetDoubleValue(15) initMetricExemplarAttributes(exemplar.FilteredAttributes()) } diff --git a/pdata/internal/cmd/pdatagen/internal/base_fields.go b/pdata/internal/cmd/pdatagen/internal/base_fields.go index f1a2578fa76..595abcf1bba 100644 --- a/pdata/internal/cmd/pdatagen/internal/base_fields.go +++ b/pdata/internal/cmd/pdatagen/internal/base_fields.go @@ -111,23 +111,23 @@ func Test${structName}_CopyTo_${fieldName}(t *testing.T) { const copyToValueOneOfMessageTemplate = ` case ${typeName}: ms.${fieldName}().CopyTo(dest.SetEmpty${fieldName}())` -const accessorsOneOfPrimitiveTemplate = `// ${fieldName} returns the ${lowerFieldName} associated with this ${structName}. -func (ms ${structName}) ${fieldName}() ${returnType} { +const accessorsOneOfPrimitiveTemplate = `// ${accessorFieldName} returns the ${lowerFieldName} associated with this ${structName}. +func (ms ${structName}) ${accessorFieldName}() ${returnType} { return ms.getOrig().Get${originFieldName}() } -// Set${fieldName} replaces the ${lowerFieldName} associated with this ${structName}. -func (ms ${structName}) Set${fieldName}(v ${returnType}) { +// Set${accessorFieldName} replaces the ${lowerFieldName} associated with this ${structName}. +func (ms ${structName}) Set${accessorFieldName}(v ${returnType}) { ms.getOrig().${originOneOfFieldName} = &${originStructType}{ ${originFieldName}: v, } }` -const accessorsOneOfPrimitiveTestTemplate = `func Test${structName}_${fieldName}(t *testing.T) { +const accessorsOneOfPrimitiveTestTemplate = `func Test${structName}_${accessorFieldName}(t *testing.T) { ms := New${structName}() - assert.Equal(t, ${defaultVal}, ms.${fieldName}()) - ms.Set${fieldName}(${testValue}) - assert.Equal(t, ${testValue}, ms.${fieldName}()) + assert.Equal(t, ${defaultVal}, ms.${accessorFieldName}()) + ms.Set${accessorFieldName}(${testValue}) + assert.Equal(t, ${testValue}, ms.${accessorFieldName}()) assert.Equal(t, ${typeName}, ms.${originOneOfTypeFuncName}()) }` @@ -603,7 +603,6 @@ type oneOfValue interface { type oneOfPrimitiveValue struct { fieldName string - fieldType string defaultVal string testVal string returnType string @@ -615,8 +614,8 @@ func (opv *oneOfPrimitiveValue) generateAccessors(ms baseStruct, of *oneOfField, switch name { case "structName": return ms.getName() - case "fieldName": - return opv.fieldName + case "accessorFieldName": + return opv.accessorFieldName(of) case "lowerFieldName": return strings.ToLower(opv.fieldName) case "returnType": @@ -643,14 +642,14 @@ func (opv *oneOfPrimitiveValue) generateTests(ms baseStruct, of *oneOfField, sb return opv.defaultVal case "packageName": return "" - case "fieldName": - return opv.fieldName + case "accessorFieldName": + return opv.accessorFieldName(of) case "testValue": return opv.testVal case "originOneOfTypeFuncName": return of.typeFuncName() case "typeName": - return of.typeName + opv.fieldType + return of.typeName + opv.fieldName default: panic(name) } @@ -658,18 +657,25 @@ func (opv *oneOfPrimitiveValue) generateTests(ms baseStruct, of *oneOfField, sb sb.WriteString("\n") } +func (opv *oneOfPrimitiveValue) accessorFieldName(of *oneOfField) string { + if of.omitOriginFieldNameInNames { + return opv.fieldName + } + return opv.fieldName + of.originFieldName +} + func (opv *oneOfPrimitiveValue) generateSetWithTestValue(of *oneOfField, sb *strings.Builder) { sb.WriteString("\ttv.orig." + of.originFieldName + " = &" + of.originTypePrefix + opv.originFieldName + "{" + opv.originFieldName + ":" + opv.testVal + "}") } func (opv *oneOfPrimitiveValue) generateCopyToValue(of *oneOfField, sb *strings.Builder) { - sb.WriteString("\tcase " + of.typeName + opv.fieldType + ":\n") - sb.WriteString("\tdest.Set" + opv.fieldName + "(ms." + opv.fieldName + "())\n") + sb.WriteString("\tcase " + of.typeName + opv.fieldName + ":\n") + sb.WriteString("\tdest.Set" + opv.accessorFieldName(of) + "(ms." + opv.accessorFieldName(of) + "())\n") } func (opv *oneOfPrimitiveValue) generateTypeSwitchCase(of *oneOfField, sb *strings.Builder) { sb.WriteString("\tcase *" + of.originTypePrefix + opv.originFieldName + ":\n") - sb.WriteString("\t\treturn " + of.typeName + opv.fieldType + "\n") + sb.WriteString("\t\treturn " + of.typeName + opv.fieldName + "\n") } var _ oneOfValue = (*oneOfPrimitiveValue)(nil) diff --git a/pdata/internal/cmd/pdatagen/internal/metrics_structs.go b/pdata/internal/cmd/pdatagen/internal/metrics_structs.go index 9e9d8a144dc..c9a07ec9cad 100644 --- a/pdata/internal/cmd/pdatagen/internal/metrics_structs.go +++ b/pdata/internal/cmd/pdatagen/internal/metrics_structs.go @@ -258,16 +258,14 @@ var numberDataPoint = &messageValueStruct{ testValueIdx: 0, // Double values: []oneOfValue{ &oneOfPrimitiveValue{ - fieldName: "DoubleVal", - fieldType: "Double", + fieldName: "Double", originFieldName: "AsDouble", returnType: "float64", defaultVal: "float64(0.0)", testVal: "float64(17.13)", }, &oneOfPrimitiveValue{ - fieldName: "IntVal", - fieldType: "Int", + fieldName: "Int", originFieldName: "AsInt", returnType: "int64", defaultVal: "int64(0)", @@ -464,20 +462,18 @@ var exemplar = &messageValueStruct{ testValueIdx: 1, // Int values: []oneOfValue{ &oneOfPrimitiveValue{ - fieldName: "DoubleVal", + fieldName: "Double", originFieldName: "AsDouble", returnType: "float64", defaultVal: "float64(0.0)", testVal: "float64(17.13)", - fieldType: "Double", }, &oneOfPrimitiveValue{ - fieldName: "IntVal", + fieldName: "Int", originFieldName: "AsInt", returnType: "int64", defaultVal: "int64(0)", testVal: "int64(17)", - fieldType: "Int", }, }, }, diff --git a/pdata/pmetric/generated_metrics.go b/pdata/pmetric/generated_metrics.go index 83477e38ed9..d2df193b7b8 100644 --- a/pdata/pmetric/generated_metrics.go +++ b/pdata/pmetric/generated_metrics.go @@ -1263,25 +1263,25 @@ func (ms NumberDataPoint) ValueType() NumberDataPointValueType { return NumberDataPointValueTypeNone } -// DoubleVal returns the doubleval associated with this NumberDataPoint. -func (ms NumberDataPoint) DoubleVal() float64 { +// DoubleValue returns the double associated with this NumberDataPoint. +func (ms NumberDataPoint) DoubleValue() float64 { return ms.getOrig().GetAsDouble() } -// SetDoubleVal replaces the doubleval associated with this NumberDataPoint. -func (ms NumberDataPoint) SetDoubleVal(v float64) { +// SetDoubleValue replaces the double associated with this NumberDataPoint. +func (ms NumberDataPoint) SetDoubleValue(v float64) { ms.getOrig().Value = &otlpmetrics.NumberDataPoint_AsDouble{ AsDouble: v, } } -// IntVal returns the intval associated with this NumberDataPoint. -func (ms NumberDataPoint) IntVal() int64 { +// IntValue returns the int associated with this NumberDataPoint. +func (ms NumberDataPoint) IntValue() int64 { return ms.getOrig().GetAsInt() } -// SetIntVal replaces the intval associated with this NumberDataPoint. -func (ms NumberDataPoint) SetIntVal(v int64) { +// SetIntValue replaces the int associated with this NumberDataPoint. +func (ms NumberDataPoint) SetIntValue(v int64) { ms.getOrig().Value = &otlpmetrics.NumberDataPoint_AsInt{ AsInt: v, } @@ -1309,9 +1309,9 @@ func (ms NumberDataPoint) CopyTo(dest NumberDataPoint) { dest.SetTimestamp(ms.Timestamp()) switch ms.ValueType() { case NumberDataPointValueTypeDouble: - dest.SetDoubleVal(ms.DoubleVal()) + dest.SetDoubleValue(ms.DoubleValue()) case NumberDataPointValueTypeInt: - dest.SetIntVal(ms.IntVal()) + dest.SetIntValue(ms.IntValue()) } ms.Exemplars().CopyTo(dest.Exemplars()) @@ -2628,25 +2628,25 @@ func (ms Exemplar) ValueType() ExemplarValueType { return ExemplarValueTypeNone } -// DoubleVal returns the doubleval associated with this Exemplar. -func (ms Exemplar) DoubleVal() float64 { +// DoubleValue returns the double associated with this Exemplar. +func (ms Exemplar) DoubleValue() float64 { return ms.getOrig().GetAsDouble() } -// SetDoubleVal replaces the doubleval associated with this Exemplar. -func (ms Exemplar) SetDoubleVal(v float64) { +// SetDoubleValue replaces the double associated with this Exemplar. +func (ms Exemplar) SetDoubleValue(v float64) { ms.getOrig().Value = &otlpmetrics.Exemplar_AsDouble{ AsDouble: v, } } -// IntVal returns the intval associated with this Exemplar. -func (ms Exemplar) IntVal() int64 { +// IntValue returns the int associated with this Exemplar. +func (ms Exemplar) IntValue() int64 { return ms.getOrig().GetAsInt() } -// SetIntVal replaces the intval associated with this Exemplar. -func (ms Exemplar) SetIntVal(v int64) { +// SetIntValue replaces the int associated with this Exemplar. +func (ms Exemplar) SetIntValue(v int64) { ms.getOrig().Value = &otlpmetrics.Exemplar_AsInt{ AsInt: v, } @@ -2682,9 +2682,9 @@ func (ms Exemplar) CopyTo(dest Exemplar) { dest.SetTimestamp(ms.Timestamp()) switch ms.ValueType() { case ExemplarValueTypeDouble: - dest.SetDoubleVal(ms.DoubleVal()) + dest.SetDoubleValue(ms.DoubleValue()) case ExemplarValueTypeInt: - dest.SetIntVal(ms.IntVal()) + dest.SetIntValue(ms.IntValue()) } ms.FilteredAttributes().CopyTo(dest.FilteredAttributes()) diff --git a/pdata/pmetric/generated_metrics_test.go b/pdata/pmetric/generated_metrics_test.go index 6937988a2e8..ab25934440b 100644 --- a/pdata/pmetric/generated_metrics_test.go +++ b/pdata/pmetric/generated_metrics_test.go @@ -865,19 +865,19 @@ func TestNumberDataPoint_ValueType(t *testing.T) { assert.Equal(t, NumberDataPointValueTypeNone, tv.ValueType()) } -func TestNumberDataPoint_DoubleVal(t *testing.T) { +func TestNumberDataPoint_DoubleValue(t *testing.T) { ms := NewNumberDataPoint() - assert.Equal(t, float64(0.0), ms.DoubleVal()) - ms.SetDoubleVal(float64(17.13)) - assert.Equal(t, float64(17.13), ms.DoubleVal()) + assert.Equal(t, float64(0.0), ms.DoubleValue()) + ms.SetDoubleValue(float64(17.13)) + assert.Equal(t, float64(17.13), ms.DoubleValue()) assert.Equal(t, NumberDataPointValueTypeDouble, ms.ValueType()) } -func TestNumberDataPoint_IntVal(t *testing.T) { +func TestNumberDataPoint_IntValue(t *testing.T) { ms := NewNumberDataPoint() - assert.Equal(t, int64(0), ms.IntVal()) - ms.SetIntVal(int64(17)) - assert.Equal(t, int64(17), ms.IntVal()) + assert.Equal(t, int64(0), ms.IntValue()) + ms.SetIntValue(int64(17)) + assert.Equal(t, int64(17), ms.IntValue()) assert.Equal(t, NumberDataPointValueTypeInt, ms.ValueType()) } @@ -1810,19 +1810,19 @@ func TestExemplar_ValueType(t *testing.T) { assert.Equal(t, ExemplarValueTypeNone, tv.ValueType()) } -func TestExemplar_DoubleVal(t *testing.T) { +func TestExemplar_DoubleValue(t *testing.T) { ms := NewExemplar() - assert.Equal(t, float64(0.0), ms.DoubleVal()) - ms.SetDoubleVal(float64(17.13)) - assert.Equal(t, float64(17.13), ms.DoubleVal()) + assert.Equal(t, float64(0.0), ms.DoubleValue()) + ms.SetDoubleValue(float64(17.13)) + assert.Equal(t, float64(17.13), ms.DoubleValue()) assert.Equal(t, ExemplarValueTypeDouble, ms.ValueType()) } -func TestExemplar_IntVal(t *testing.T) { +func TestExemplar_IntValue(t *testing.T) { ms := NewExemplar() - assert.Equal(t, int64(0), ms.IntVal()) - ms.SetIntVal(int64(17)) - assert.Equal(t, int64(17), ms.IntVal()) + assert.Equal(t, int64(0), ms.IntValue()) + ms.SetIntValue(int64(17)) + assert.Equal(t, int64(17), ms.IntValue()) assert.Equal(t, ExemplarValueTypeInt, ms.ValueType()) } diff --git a/pdata/pmetric/json_test.go b/pdata/pmetric/json_test.go index 92d9f10c29a..b85bd02424c 100644 --- a/pdata/pmetric/json_test.go +++ b/pdata/pmetric/json_test.go @@ -81,14 +81,14 @@ var metricsSumOTLPFull = func() Metrics { sum.SetIsMonotonic(true) datapoint := sum.DataPoints().AppendEmpty() datapoint.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now())) - datapoint.SetIntVal(100) + datapoint.SetIntValue(100) datapoint.Attributes().PutString("string", "value") datapoint.Attributes().PutBool("bool", true) datapoint.Attributes().PutInt("int", 1) datapoint.Attributes().PutDouble("double", 1.1) datapoint.Attributes().PutEmptyBytes("bytes").FromRaw([]byte("foo")) exemplar := datapoint.Exemplars().AppendEmpty() - exemplar.SetDoubleVal(99.3) + exemplar.SetDoubleValue(99.3) exemplar.SetTimestamp(pcommon.NewTimestampFromTime(time.Now())) traceID := pcommon.TraceID([16]byte{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10}) spanID := pcommon.SpanID([8]byte{0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18}) @@ -120,14 +120,14 @@ var metricsGaugeOTLPFull = func() Metrics { gauge := gaugeMetric.SetEmptyGauge() datapoint := gauge.DataPoints().AppendEmpty() datapoint.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now())) - datapoint.SetDoubleVal(10.2) + datapoint.SetDoubleValue(10.2) datapoint.Attributes().PutString("string", "value") datapoint.Attributes().PutBool("bool", true) datapoint.Attributes().PutInt("int", 1) datapoint.Attributes().PutDouble("double", 1.1) datapoint.Attributes().PutEmptyBytes("bytes").FromRaw([]byte("foo")) exemplar := datapoint.Exemplars().AppendEmpty() - exemplar.SetDoubleVal(99.3) + exemplar.SetDoubleValue(99.3) exemplar.SetTimestamp(pcommon.NewTimestampFromTime(time.Now())) traceID := pcommon.TraceID([16]byte{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10}) spanID := pcommon.SpanID([8]byte{0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18}) @@ -170,7 +170,7 @@ var metricsHistogramOTLPFull = func() Metrics { datapoint.BucketCounts().FromRaw([]uint64{1, 1, 2}) datapoint.ExplicitBounds().FromRaw([]float64{10, 100}) exemplar := datapoint.Exemplars().AppendEmpty() - exemplar.SetDoubleVal(99.3) + exemplar.SetDoubleValue(99.3) exemplar.SetTimestamp(pcommon.NewTimestampFromTime(time.Now())) datapoint.SetMin(float64(time.Now().Unix())) traceID := pcommon.TraceID([16]byte{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10}) @@ -216,7 +216,7 @@ var metricsExponentialHistogramOTLPFull = func() Metrics { datapoint.Positive().BucketCounts().FromRaw([]uint64{1, 1, 2}) datapoint.Positive().SetOffset(2) exemplar := datapoint.Exemplars().AppendEmpty() - exemplar.SetDoubleVal(99.3) + exemplar.SetDoubleValue(99.3) exemplar.SetTimestamp(pcommon.NewTimestampFromTime(time.Now())) datapoint.SetMin(float64(time.Now().Unix())) traceID := pcommon.TraceID([16]byte{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10}) diff --git a/pdata/pmetric/metrics.go b/pdata/pmetric/metrics.go index 746d211aa9d..056851cf2b1 100644 --- a/pdata/pmetric/metrics.go +++ b/pdata/pmetric/metrics.go @@ -236,3 +236,43 @@ func (ot OptionalType) String() string { } return "" } + +// Deprecated: [v0.61.0] use NumberDataPoint.DoubleValue(). +func (ms NumberDataPoint) DoubleVal() float64 { + return ms.DoubleValue() +} + +// Deprecated: [v0.61.0] use NumberDataPoint.SetDoubleValue(). +func (ms NumberDataPoint) SetDoubleVal(v float64) { + ms.SetDoubleValue(v) +} + +// Deprecated: [v0.61.0] use NumberDataPoint.IntValue(). +func (ms NumberDataPoint) IntVal() int64 { + return ms.IntValue() +} + +// Deprecated: [v0.61.0] use NumberDataPoint.SetIntValue(). +func (ms NumberDataPoint) SetIntVal(v int64) { + ms.SetIntValue(v) +} + +// Deprecated: [v0.61.0] use Exemplar.DoubleValue(). +func (ms Exemplar) DoubleVal() float64 { + return ms.DoubleValue() +} + +// Deprecated: [v0.61.0] use Exemplar.SetDoubleValue(). +func (ms Exemplar) SetDoubleVal(v float64) { + ms.SetDoubleValue(v) +} + +// Deprecated: [v0.61.0] use Exemplar.IntValue(). +func (ms Exemplar) IntVal() int64 { + return ms.IntValue() +} + +// Deprecated: [v0.61.0] use Exemplar.SetIntValue(). +func (ms Exemplar) SetIntVal(v int64) { + ms.SetIntValue(v) +} diff --git a/pdata/pmetric/metrics_test.go b/pdata/pmetric/metrics_test.go index 777c52f5fa7..737c78fea01 100644 --- a/pdata/pmetric/metrics_test.go +++ b/pdata/pmetric/metrics_test.go @@ -262,12 +262,12 @@ func TestOtlpToInternalReadOnly(t *testing.T) { // First point assert.EqualValues(t, startTime, gaugeDataPoints.At(0).StartTimestamp()) assert.EqualValues(t, endTime, gaugeDataPoints.At(0).Timestamp()) - assert.EqualValues(t, 123.1, gaugeDataPoints.At(0).DoubleVal()) + assert.EqualValues(t, 123.1, gaugeDataPoints.At(0).DoubleValue()) assert.EqualValues(t, map[string]interface{}{"key0": "value0"}, gaugeDataPoints.At(0).Attributes().AsRaw()) // Second point assert.EqualValues(t, startTime, gaugeDataPoints.At(1).StartTimestamp()) assert.EqualValues(t, endTime, gaugeDataPoints.At(1).Timestamp()) - assert.EqualValues(t, 456.1, gaugeDataPoints.At(1).DoubleVal()) + assert.EqualValues(t, 456.1, gaugeDataPoints.At(1).DoubleValue()) assert.EqualValues(t, map[string]interface{}{"key1": "value1"}, gaugeDataPoints.At(1).Attributes().AsRaw()) // Check double metric @@ -283,12 +283,12 @@ func TestOtlpToInternalReadOnly(t *testing.T) { // First point assert.EqualValues(t, startTime, sumDataPoints.At(0).StartTimestamp()) assert.EqualValues(t, endTime, sumDataPoints.At(0).Timestamp()) - assert.EqualValues(t, 123.1, sumDataPoints.At(0).DoubleVal()) + assert.EqualValues(t, 123.1, sumDataPoints.At(0).DoubleValue()) assert.EqualValues(t, map[string]interface{}{"key0": "value0"}, sumDataPoints.At(0).Attributes().AsRaw()) // Second point assert.EqualValues(t, startTime, sumDataPoints.At(1).StartTimestamp()) assert.EqualValues(t, endTime, sumDataPoints.At(1).Timestamp()) - assert.EqualValues(t, 456.1, sumDataPoints.At(1).DoubleVal()) + assert.EqualValues(t, 456.1, sumDataPoints.At(1).DoubleValue()) assert.EqualValues(t, map[string]interface{}{"key1": "value1"}, sumDataPoints.At(1).Attributes().AsRaw()) // Check histogram metric @@ -380,8 +380,8 @@ func TestOtlpToFromInternalGaugeMutating(t *testing.T) { assert.EqualValues(t, startTime+1, gaugeDataPoints.At(0).StartTimestamp()) gaugeDataPoints.At(0).SetTimestamp(pcommon.Timestamp(endTime + 1)) assert.EqualValues(t, endTime+1, gaugeDataPoints.At(0).Timestamp()) - gaugeDataPoints.At(0).SetDoubleVal(124.1) - assert.EqualValues(t, 124.1, gaugeDataPoints.At(0).DoubleVal()) + gaugeDataPoints.At(0).SetDoubleValue(124.1) + assert.EqualValues(t, 124.1, gaugeDataPoints.At(0).DoubleValue()) gaugeDataPoints.At(0).Attributes().Remove("key0") gaugeDataPoints.At(0).Attributes().PutString("k", "v") assert.EqualValues(t, newAttributes, gaugeDataPoints.At(0).Attributes().AsRaw()) @@ -463,8 +463,8 @@ func TestOtlpToFromInternalSumMutating(t *testing.T) { assert.EqualValues(t, startTime+1, doubleDataPoints.At(0).StartTimestamp()) doubleDataPoints.At(0).SetTimestamp(pcommon.Timestamp(endTime + 1)) assert.EqualValues(t, endTime+1, doubleDataPoints.At(0).Timestamp()) - doubleDataPoints.At(0).SetDoubleVal(124.1) - assert.EqualValues(t, 124.1, doubleDataPoints.At(0).DoubleVal()) + doubleDataPoints.At(0).SetDoubleValue(124.1) + assert.EqualValues(t, 124.1, doubleDataPoints.At(0).DoubleValue()) doubleDataPoints.At(0).Attributes().Remove("key0") doubleDataPoints.At(0).Attributes().PutString("k", "v") assert.EqualValues(t, newAttributes, doubleDataPoints.At(0).Attributes().AsRaw()) diff --git a/pdata/pmetric/pb_test.go b/pdata/pmetric/pb_test.go index a5146d64566..7aea0c0f56a 100644 --- a/pdata/pmetric/pb_test.go +++ b/pdata/pmetric/pb_test.go @@ -89,7 +89,7 @@ func generateBenchmarkMetrics(metricsCount int) Metrics { idp := im.SetEmptySum().DataPoints().AppendEmpty() idp.SetStartTimestamp(startTime) idp.SetTimestamp(endTime) - idp.SetIntVal(123) + idp.SetIntValue(123) } return md }