Skip to content

Commit 642a8e0

Browse files
author
alrex
authored
update OTLP to v0.8.0 (#3572)
* update proto to v0.8.0 * regenerate protos using 0.8.0 * update uses of DoubleGauge, DoubleSum, DoubleHistogram, DoubleSummary, DoubleDataPoint, DoubleHistogramDataPoint, DoubleSummaryDataPoint, DoubleExemplar * update ExemplarSlice to use []*otlpmetrics.Exemplar * suppress deprecation warnings for metrics * update pdatagen generator code to support AsDouble fields * run make genpdata
1 parent fdb85b3 commit 642a8e0

File tree

12 files changed

+979
-654
lines changed

12 files changed

+979
-654
lines changed

.golangci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ issues:
134134
- text: "or a comment on this block"
135135
linters:
136136
- revive
137+
# disabling to suppress deprecation warnings when updating OTLP to v0.8.0
138+
# in support of breaking up the work into more manageable PRs
139+
- path: pdata/metrics.go
140+
linters:
141+
- staticcheck
142+
- path: pdata/metrics_test.go
143+
linters:
144+
- staticcheck
137145

138146
# The list of ids of default excludes to include or disable. By default it's empty.
139147
# See the list of default excludes here https://golangci-lint.run/usage/configuration.

cmd/pdatagen/internal/base_fields.go

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@ func (ms ${structName}) Set${fieldName}(v ${returnType}) {
5353
(*ms.orig).${originFieldName} = v
5454
}`
5555

56+
const accessorsPrimitiveAsDoubleTemplate = `// ${fieldName} returns the ${lowerFieldName} associated with this ${structName}.
57+
func (ms ${structName}) ${fieldName}() ${returnType} {
58+
return (*ms.orig).GetAsDouble()
59+
}
60+
61+
// Set${fieldName} replaces the ${lowerFieldName} associated with this ${structName}.
62+
func (ms ${structName}) Set${fieldName}(v ${returnType}) {
63+
(*ms.orig).${originFieldName} = &${originFullName}_AsDouble{
64+
AsDouble: v,
65+
}
66+
}`
67+
5668
const accessorsPrimitiveTestTemplate = `func Test${structName}_${fieldName}(t *testing.T) {
5769
ms := New${structName}()
5870
assert.EqualValues(t, ${defaultVal}, ms.${fieldName}())
@@ -393,3 +405,60 @@ func (one oneofField) generateCopyToValue(sb *strings.Builder) {
393405
}
394406

395407
var _ baseField = (*oneofField)(nil)
408+
409+
type primitiveAsDoubleField struct {
410+
originFullName string
411+
fieldName string
412+
originFieldName string
413+
returnType string
414+
defaultVal string
415+
testVal string
416+
}
417+
418+
func (pf *primitiveAsDoubleField) generateAccessors(ms baseStruct, sb *strings.Builder) {
419+
sb.WriteString(os.Expand(accessorsPrimitiveAsDoubleTemplate, func(name string) string {
420+
switch name {
421+
case "structName":
422+
return ms.getName()
423+
case "fieldName":
424+
return pf.fieldName
425+
case "lowerFieldName":
426+
return strings.ToLower(pf.fieldName)
427+
case "returnType":
428+
return pf.returnType
429+
case "originFieldName":
430+
return pf.originFieldName
431+
case "originFullName":
432+
return pf.originFullName
433+
default:
434+
panic(name)
435+
}
436+
}))
437+
}
438+
439+
func (pf *primitiveAsDoubleField) generateAccessorsTest(ms baseStruct, sb *strings.Builder) {
440+
sb.WriteString(os.Expand(accessorsPrimitiveTestTemplate, func(name string) string {
441+
switch name {
442+
case "structName":
443+
return ms.getName()
444+
case "defaultVal":
445+
return pf.defaultVal
446+
case "fieldName":
447+
return pf.fieldName
448+
case "testValue":
449+
return pf.testVal
450+
default:
451+
panic(name)
452+
}
453+
}))
454+
}
455+
456+
func (pf *primitiveAsDoubleField) generateSetWithTestValue(sb *strings.Builder) {
457+
sb.WriteString("\ttv.Set" + pf.fieldName + "(" + pf.testVal + ")")
458+
}
459+
460+
func (pf *primitiveAsDoubleField) generateCopyToValue(sb *strings.Builder) {
461+
sb.WriteString("\tdest.Set" + pf.fieldName + "(ms." + pf.fieldName + "())")
462+
}
463+
464+
var _ baseField = (*primitiveField)(nil)

cmd/pdatagen/internal/metrics_structs.go

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ var intGauge = &messageValueStruct{
143143
var doubleGauge = &messageValueStruct{
144144
structName: "DoubleGauge",
145145
description: "// DoubleGauge represents the type of a double scalar metric that always exports the \"current value\" for every data point.",
146-
originFullName: "otlpmetrics.DoubleGauge",
146+
originFullName: "otlpmetrics.Gauge",
147147
fields: []baseField{
148148
&sliceField{
149149
fieldName: "DataPoints",
@@ -171,7 +171,7 @@ var intSum = &messageValueStruct{
171171
var doubleSum = &messageValueStruct{
172172
structName: "DoubleSum",
173173
description: "// DoubleSum represents the type of a numeric double scalar metric that is calculated as a sum of all reported measurements over a time interval.",
174-
originFullName: "otlpmetrics.DoubleSum",
174+
originFullName: "otlpmetrics.Sum",
175175
fields: []baseField{
176176
aggregationTemporalityField,
177177
isMonotonicField,
@@ -200,7 +200,7 @@ var intHistogram = &messageValueStruct{
200200
var histogram = &messageValueStruct{
201201
structName: "Histogram",
202202
description: "// Histogram represents the type of a metric that is calculated by aggregating as a Histogram of all reported measurements over a time interval.",
203-
originFullName: "otlpmetrics.DoubleHistogram",
203+
originFullName: "otlpmetrics.Histogram",
204204
fields: []baseField{
205205
aggregationTemporalityField,
206206
&sliceField{
@@ -214,7 +214,7 @@ var histogram = &messageValueStruct{
214214
var summary = &messageValueStruct{
215215
structName: "Summary",
216216
description: "// Summary represents the type of a metric that is calculated by aggregating as a Summary of all reported double measurements over a time interval.",
217-
originFullName: "otlpmetrics.DoubleSummary",
217+
originFullName: "otlpmetrics.Summary",
218218
fields: []baseField{
219219
&sliceField{
220220
fieldName: "DataPoints",
@@ -250,12 +250,19 @@ var doubleDataPointSlice = &sliceOfPtrs{
250250
var doubleDataPoint = &messageValueStruct{
251251
structName: "DoubleDataPoint",
252252
description: "// DoubleDataPoint is a single data point in a timeseries that describes the time-varying value of a double metric.",
253-
originFullName: "otlpmetrics.DoubleDataPoint",
253+
originFullName: "otlpmetrics.NumberDataPoint",
254254
fields: []baseField{
255255
labelsField,
256256
startTimeField,
257257
timeField,
258-
valueFloat64Field,
258+
&primitiveAsDoubleField{
259+
originFullName: "otlpmetrics.NumberDataPoint",
260+
fieldName: "Value",
261+
originFieldName: "Value",
262+
returnType: "float64",
263+
defaultVal: "float64(0.0)",
264+
testVal: "float64(17.13)",
265+
},
259266
exemplarsField,
260267
},
261268
}
@@ -289,7 +296,7 @@ var histogramDataPointSlice = &sliceOfPtrs{
289296
var histogramDataPoint = &messageValueStruct{
290297
structName: "HistogramDataPoint",
291298
description: "// HistogramDataPoint is a single data point in a timeseries that describes the time-varying values of a Histogram of values.",
292-
originFullName: "otlpmetrics.DoubleHistogramDataPoint",
299+
originFullName: "otlpmetrics.HistogramDataPoint",
293300
fields: []baseField{
294301
labelsField,
295302
startTimeField,
@@ -310,7 +317,7 @@ var summaryDataPointSlice = &sliceOfPtrs{
310317
var summaryDataPoint = &messageValueStruct{
311318
structName: "SummaryDataPoint",
312319
description: "// SummaryDataPoint is a single data point in a timeseries that describes the time-varying values of a Summary of double values.",
313-
originFullName: "otlpmetrics.DoubleSummaryDataPoint",
320+
originFullName: "otlpmetrics.SummaryDataPoint",
314321
fields: []baseField{
315322
labelsField,
316323
startTimeField,
@@ -333,7 +340,7 @@ var quantileValuesSlice = &sliceOfPtrs{
333340
var quantileValues = &messageValueStruct{
334341
structName: "ValueAtQuantile",
335342
description: "// ValueAtQuantile is a quantile value within a Summary data point.",
336-
originFullName: "otlpmetrics.DoubleSummaryDataPoint_ValueAtQuantile",
343+
originFullName: "otlpmetrics.SummaryDataPoint_ValueAtQuantile",
337344
fields: []baseField{
338345
quantileField,
339346
valueFloat64Field,
@@ -363,7 +370,7 @@ var intExemplar = &messageValueStruct{
363370
},
364371
}
365372

366-
var exemplarSlice = &sliceOfValues{
373+
var exemplarSlice = &sliceOfPtrs{
367374
structName: "ExemplarSlice",
368375
element: exemplar,
369376
}
@@ -374,10 +381,17 @@ var exemplar = &messageValueStruct{
374381
"// Exemplars also hold information about the environment when the measurement was recorded,\n" +
375382
"// for example the span and trace ID of the active span when the exemplar was recorded.",
376383

377-
originFullName: "otlpmetrics.DoubleExemplar",
384+
originFullName: "otlpmetrics.Exemplar",
378385
fields: []baseField{
379386
timeField,
380-
valueFloat64Field,
387+
&primitiveAsDoubleField{
388+
originFullName: "otlpmetrics.Exemplar",
389+
fieldName: "Value",
390+
originFieldName: "Value",
391+
returnType: "float64",
392+
defaultVal: "float64(0.0)",
393+
testVal: "float64(17.13)",
394+
},
381395
&sliceField{
382396
fieldName: "FilteredLabels",
383397
originFieldName: "FilteredLabels",

model/internal/data/protogen/common/v1/common.pb.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

model/internal/data/protogen/logs/v1/logs.pb.go

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)