Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecation of pdata methods following OTLP v0.15.0 #5076

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,22 @@
- Deprecate UnmarshalJSON[Traces|Metrics|Logs][Reques|Response] in favor of `UnmarshalJSON`.
- Deprecate [Traces|Metrics|Logs][Reques|Response].Marshal in favor of `MarshalProto`.
- Deprecate UnmarshalJSON[Traces|Metrics|Logs][Reques|Response] in favor of `UnmarshalProto`.

- Deprecating following pdata methods/types following OTLP v0.15.0 upgrade (#5076):
- InstrumentationLibrary is now InstrumentationScope
- NewInstrumentationLibrary is now NewInstrumentationScope
- InstrumentationLibraryLogsSlice is now ScopeLogsSlice
- NewInstrumentationLibraryLogsSlice is now NewScopeLogsSlice
- InstrumentationLibraryLogs is now ScopeLogs
- NewInstrumentationLibraryLogs is now NewScopeLogs
- InstrumentationLibraryMetricsSlice is now ScopeMetricsSlice
- NewInstrumentationLibraryMetricsSlice is now NewScopeMetricsSlice
- InstrumentationLibraryMetrics is now ScopeMetrics
- NewInstrumentationLibraryMetrics is now NewScopeMetrics
- InstrumentationLibrarySpansSlice is now ScopeSpansSlice
- NewInstrumentationLibrarySpansSlice is now NewScopeSpansSlice
- InstrumentationLibrarySpans is now ScopeSpans
- NewInstrumentationLibrarySpans is now NewScopeSpans

### 💡 Enhancements 💡

- Change outcome of `pdata.Metric.<Gauge|Sum|Histogram|ExponentialHistogram>()` functions misuse.
Expand Down
2 changes: 1 addition & 1 deletion docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ With the modified configuration if you re-run the test above the log output shou
2020-11-11T04:08:17.344Z DEBUG loggingexporter/logging_exporter.go:353 ResourceSpans #0
bogdandrutu marked this conversation as resolved.
Show resolved Hide resolved
Resource labels:
-> service.name: STRING(api)
InstrumentationLibrarySpans #0
ScopeSpans #0
Span #0
Trace ID : 5982fe77008310cc80f1da5e10147519
Parent ID : 90394f6bcffb5d13
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func newTraces(numTraces int, numSpans int) pdata.Traces {

for i := 0; i < numTraces; i++ {
traceID := pdata.NewTraceID([16]byte{1, 2, 3, byte(i)})
ils := batch.InstrumentationLibrarySpans().AppendEmpty()
ils := batch.ScopeSpans().AppendEmpty()
for j := 0; j < numSpans; j++ {
span := ils.Spans().AppendEmpty()
span.SetTraceID(traceID)
Expand Down
2 changes: 1 addition & 1 deletion exporter/exporterhelper/traces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func checkRecordedMetricsForTracesExporter(t *testing.T, te component.TracesExpo

func generateTraceTraffic(t *testing.T, tracer trace.Tracer, te component.TracesExporter, numRequests int, wantError error) {
td := pdata.NewTraces()
td.ResourceSpans().AppendEmpty().InstrumentationLibrarySpans().AppendEmpty().Spans().AppendEmpty()
td.ResourceSpans().AppendEmpty().ScopeSpans().AppendEmpty().Spans().AppendEmpty()
ctx, span := tracer.Start(context.Background(), fakeTraceParentSpanName)
defer span.End()
for i := 0; i < numRequests; i++ {
Expand Down
8 changes: 4 additions & 4 deletions exporter/otlphttpexporter/otlp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func TestIssue_4221(t *testing.T) {
require.NoError(t, err)
tr := otlpgrpc.NewTracesRequest()
require.NoError(t, tr.UnmarshalProto(unbase64Data))
span := tr.Traces().ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans().At(0)
span := tr.Traces().ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(0)
assert.Equal(t, "4303853f086f4f8c86cf198b6551df84", span.TraceID().HexString())
assert.Equal(t, "e5513c32795c41b9", span.SpanID().HexString())
}))
Expand All @@ -269,9 +269,9 @@ func TestIssue_4221(t *testing.T) {
rms := md.ResourceSpans().AppendEmpty()
rms.Resource().Attributes().UpsertString("service.name", "uop.stage-eu-1")
rms.Resource().Attributes().UpsertString("outsystems.module.version", "903386")
ils := rms.InstrumentationLibrarySpans().AppendEmpty()
ils.InstrumentationLibrary().SetName("uop_canaries")
ils.InstrumentationLibrary().SetVersion("1")
ils := rms.ScopeSpans().AppendEmpty()
ils.Scope().SetName("uop_canaries")
ils.Scope().SetVersion("1")
span := ils.Spans().AppendEmpty()

var traceIDBytes [16]byte
Expand Down
4 changes: 2 additions & 2 deletions internal/otlptext/databuffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ func (b *dataBuffer) logAttributes(label string, m pdata.Map) {
})
}

func (b *dataBuffer) logInstrumentationLibrary(il pdata.InstrumentationLibrary) {
func (b *dataBuffer) logInstrumentationScope(il pdata.InstrumentationScope) {
b.logEntry(
"InstrumentationLibrary %s %s",
"InstrumentationScope %s %s",
il.Name(),
il.Version())
}
Expand Down
8 changes: 4 additions & 4 deletions internal/otlptext/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ func (textLogsMarshaler) MarshalLogs(ld pdata.Logs) ([]byte, error) {
rl := rls.At(i)
buf.logEntry("Resource SchemaURL: %s", rl.SchemaUrl())
buf.logAttributes("Resource labels", rl.Resource().Attributes())
ills := rl.InstrumentationLibraryLogs()
ills := rl.ScopeLogs()
for j := 0; j < ills.Len(); j++ {
buf.logEntry("InstrumentationLibraryLogs #%d", j)
buf.logEntry("ScopeLogs #%d", j)
ils := ills.At(j)
buf.logEntry("InstrumentationLibraryLogs SchemaURL: %s", ils.SchemaUrl())
buf.logInstrumentationLibrary(ils.InstrumentationLibrary())
buf.logEntry("ScopeLogs SchemaURL: %s", ils.SchemaUrl())
buf.logInstrumentationScope(ils.Scope())

logs := ils.LogRecords()
for k := 0; k < logs.Len(); k++ {
Expand Down
8 changes: 4 additions & 4 deletions internal/otlptext/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ func (textMetricsMarshaler) MarshalMetrics(md pdata.Metrics) ([]byte, error) {
rm := rms.At(i)
buf.logEntry("Resource SchemaURL: %s", rm.SchemaUrl())
buf.logAttributes("Resource labels", rm.Resource().Attributes())
ilms := rm.InstrumentationLibraryMetrics()
ilms := rm.ScopeMetrics()
for j := 0; j < ilms.Len(); j++ {
buf.logEntry("InstrumentationLibraryMetrics #%d", j)
buf.logEntry("ScopeMetrics #%d", j)
ilm := ilms.At(j)
buf.logEntry("InstrumentationLibraryMetrics SchemaURL: %s", ilm.SchemaUrl())
buf.logInstrumentationLibrary(ilm.InstrumentationLibrary())
buf.logEntry("ScopeMetrics SchemaURL: %s", ilm.SchemaUrl())
buf.logInstrumentationScope(ilm.Scope())
metrics := ilm.Metrics()
for k := 0; k < metrics.Len(); k++ {
buf.logEntry("Metric #%d", k)
Expand Down
8 changes: 4 additions & 4 deletions internal/otlptext/traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ func (textTracesMarshaler) MarshalTraces(td pdata.Traces) ([]byte, error) {
rs := rss.At(i)
buf.logEntry("Resource SchemaURL: %s", rs.SchemaUrl())
buf.logAttributes("Resource labels", rs.Resource().Attributes())
ilss := rs.InstrumentationLibrarySpans()
ilss := rs.ScopeSpans()
for j := 0; j < ilss.Len(); j++ {
buf.logEntry("InstrumentationLibrarySpans #%d", j)
buf.logEntry("ScopeSpans #%d", j)
ils := ilss.At(j)
buf.logEntry("InstrumentationLibrarySpans SchemaURL: %s", ils.SchemaUrl())
buf.logInstrumentationLibrary(ils.InstrumentationLibrary())
buf.logEntry("ScopeSpans SchemaURL: %s", ils.SchemaUrl())
buf.logInstrumentationScope(ils.Scope())

spans := ils.Spans()
for k := 0; k < spans.Len(); k++ {
Expand Down
12 changes: 6 additions & 6 deletions internal/testdata/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ func GenerateLogsNoLogRecords() pdata.Logs {
func GenerateLogsOneEmptyLogRecord() pdata.Logs {
ld := GenerateLogsNoLogRecords()
rs0 := ld.ResourceLogs().At(0)
rs0.InstrumentationLibraryLogs().AppendEmpty().LogRecords().AppendEmpty()
rs0.ScopeLogs().AppendEmpty().LogRecords().AppendEmpty()
return ld
}

func GenerateLogsOneLogRecord() pdata.Logs {
ld := GenerateLogsOneEmptyLogRecord()
fillLogOne(ld.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords().At(0))
fillLogOne(ld.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(0))
return ld
}

func GenerateLogsTwoLogRecordsSameResource() pdata.Logs {
ld := GenerateLogsOneEmptyLogRecord()
logs := ld.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords()
logs := ld.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords()
fillLogOne(logs.At(0))
fillLogTwo(logs.AppendEmpty())
return ld
Expand All @@ -62,12 +62,12 @@ func GenerateLogsTwoLogRecordsSameResourceOneDifferent() pdata.Logs {
ld := pdata.NewLogs()
rl0 := ld.ResourceLogs().AppendEmpty()
initResource1(rl0.Resource())
logs := rl0.InstrumentationLibraryLogs().AppendEmpty().LogRecords()
logs := rl0.ScopeLogs().AppendEmpty().LogRecords()
fillLogOne(logs.AppendEmpty())
fillLogTwo(logs.AppendEmpty())
rl1 := ld.ResourceLogs().AppendEmpty()
initResource2(rl1.Resource())
fillLogThree(rl1.InstrumentationLibraryLogs().AppendEmpty().LogRecords().AppendEmpty())
fillLogThree(rl1.ScopeLogs().AppendEmpty().LogRecords().AppendEmpty())
return ld
}
func fillLogOne(log pdata.LogRecord) {
Expand Down Expand Up @@ -109,7 +109,7 @@ func fillLogThree(log pdata.LogRecord) {

func GenerateLogsManyLogRecordsSameResource(count int) pdata.Logs {
ld := GenerateLogsOneEmptyLogRecord()
logs := ld.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords()
logs := ld.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords()
logs.EnsureCapacity(count)
for i := 0; i < count; i++ {
var l pdata.LogRecord
Expand Down
28 changes: 14 additions & 14 deletions internal/testdata/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,30 +54,30 @@ func GenerateMetricsNoLibraries() pdata.Metrics {
return md
}

func GenerateMetricsOneEmptyInstrumentationLibrary() pdata.Metrics {
func GenerateMetricsOneEmptyInstrumentationScope() pdata.Metrics {
md := GenerateMetricsNoLibraries()
md.ResourceMetrics().At(0).InstrumentationLibraryMetrics().AppendEmpty()
md.ResourceMetrics().At(0).ScopeMetrics().AppendEmpty()
return md
}

func GenerateMetricsOneMetric() pdata.Metrics {
md := GenerateMetricsOneEmptyInstrumentationLibrary()
rm0ils0 := md.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0)
md := GenerateMetricsOneEmptyInstrumentationScope()
rm0ils0 := md.ResourceMetrics().At(0).ScopeMetrics().At(0)
initSumIntMetric(rm0ils0.Metrics().AppendEmpty())
return md
}

func GenerateMetricsTwoMetrics() pdata.Metrics {
md := GenerateMetricsOneEmptyInstrumentationLibrary()
rm0ils0 := md.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0)
md := GenerateMetricsOneEmptyInstrumentationScope()
rm0ils0 := md.ResourceMetrics().At(0).ScopeMetrics().At(0)
initSumIntMetric(rm0ils0.Metrics().AppendEmpty())
initSumIntMetric(rm0ils0.Metrics().AppendEmpty())
return md
}

func GenerateMetricsAllTypesEmptyDataPoint() pdata.Metrics {
md := GenerateMetricsOneEmptyInstrumentationLibrary()
ilm0 := md.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0)
md := GenerateMetricsOneEmptyInstrumentationScope()
ilm0 := md.ResourceMetrics().At(0).ScopeMetrics().At(0)
ms := ilm0.Metrics()

doubleGauge := ms.AppendEmpty()
Expand All @@ -102,16 +102,16 @@ func GenerateMetricsAllTypesEmptyDataPoint() pdata.Metrics {
}

func GenerateMetricsMetricTypeInvalid() pdata.Metrics {
md := GenerateMetricsOneEmptyInstrumentationLibrary()
ilm0 := md.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0)
md := GenerateMetricsOneEmptyInstrumentationScope()
ilm0 := md.ResourceMetrics().At(0).ScopeMetrics().At(0)
initMetric(ilm0.Metrics().AppendEmpty(), TestSumIntMetricName, pdata.MetricDataTypeNone)
return md
}

func GeneratMetricsAllTypesWithSampleDatapoints() pdata.Metrics {
md := GenerateMetricsOneEmptyInstrumentationLibrary()
md := GenerateMetricsOneEmptyInstrumentationScope()

ilm := md.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0)
ilm := md.ResourceMetrics().At(0).ScopeMetrics().At(0)
ms := ilm.Metrics()
initGaugeIntMetric(ms.AppendEmpty())
initGaugeDoubleMetric(ms.AppendEmpty())
Expand Down Expand Up @@ -307,8 +307,8 @@ func initMetric(m pdata.Metric, name string, ty pdata.MetricDataType) {
}

func GenerateMetricsManyMetricsSameResource(metricsCount int) pdata.Metrics {
md := GenerateMetricsOneEmptyInstrumentationLibrary()
rs0ilm0 := md.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0)
md := GenerateMetricsOneEmptyInstrumentationScope()
rs0ilm0 := md.ResourceMetrics().At(0).ScopeMetrics().At(0)
rs0ilm0.Metrics().EnsureCapacity(metricsCount)
for i := 0; i < metricsCount; i++ {
initSumIntMetric(rs0ilm0.Metrics().AppendEmpty())
Expand Down
20 changes: 10 additions & 10 deletions internal/testdata/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,22 @@ func GenerateTracesNoLibraries() pdata.Traces {
return td
}

func GenerateTracesOneEmptyInstrumentationLibrary() pdata.Traces {
func GenerateTracesOneEmptyInstrumentationScope() pdata.Traces {
td := GenerateTracesNoLibraries()
td.ResourceSpans().At(0).InstrumentationLibrarySpans().AppendEmpty()
td.ResourceSpans().At(0).ScopeSpans().AppendEmpty()
return td
}

func GenerateTracesOneSpan() pdata.Traces {
td := GenerateTracesOneEmptyInstrumentationLibrary()
rs0ils0 := td.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0)
td := GenerateTracesOneEmptyInstrumentationScope()
rs0ils0 := td.ResourceSpans().At(0).ScopeSpans().At(0)
fillSpanOne(rs0ils0.Spans().AppendEmpty())
return td
}

func GenerateTracesTwoSpansSameResource() pdata.Traces {
td := GenerateTracesOneEmptyInstrumentationLibrary()
rs0ils0 := td.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0)
td := GenerateTracesOneEmptyInstrumentationScope()
rs0ils0 := td.ResourceSpans().At(0).ScopeSpans().At(0)
fillSpanOne(rs0ils0.Spans().AppendEmpty())
fillSpanTwo(rs0ils0.Spans().AppendEmpty())
return td
Expand All @@ -69,19 +69,19 @@ func GenerateTracesTwoSpansSameResourceOneDifferent() pdata.Traces {
td := pdata.NewTraces()
rs0 := td.ResourceSpans().AppendEmpty()
initResource1(rs0.Resource())
rs0ils0 := rs0.InstrumentationLibrarySpans().AppendEmpty()
rs0ils0 := rs0.ScopeSpans().AppendEmpty()
fillSpanOne(rs0ils0.Spans().AppendEmpty())
fillSpanTwo(rs0ils0.Spans().AppendEmpty())
rs1 := td.ResourceSpans().AppendEmpty()
initResource2(rs1.Resource())
rs1ils0 := rs1.InstrumentationLibrarySpans().AppendEmpty()
rs1ils0 := rs1.ScopeSpans().AppendEmpty()
fillSpanThree(rs1ils0.Spans().AppendEmpty())
return td
}

func GenerateTracesManySpansSameResource(spanCount int) pdata.Traces {
td := GenerateTracesOneEmptyInstrumentationLibrary()
rs0ils0 := td.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0)
td := GenerateTracesOneEmptyInstrumentationScope()
rs0ils0 := td.ResourceSpans().At(0).ScopeSpans().At(0)
rs0ils0.Spans().EnsureCapacity(spanCount)
for i := 0; i < spanCount; i++ {
fillSpanOne(rs0ils0.Spans().AppendEmpty())
Expand Down
14 changes: 7 additions & 7 deletions model/internal/cmd/pdatagen/internal/common_structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ var commonFile = &File{
`otlpcommon "go.opentelemetry.io/collector/model/internal/data/protogen/common/v1"`,
},
structs: []baseStruct{
instrumentationLibrary,
scope,
attributeValueSlice,
},
}

var instrumentationLibrary = &messageValueStruct{
structName: "InstrumentationLibrary",
description: "// InstrumentationLibrary is a message representing the instrumentation library information.",
var scope = &messageValueStruct{
structName: "InstrumentationScope",
description: "// Scope is a message representing the instrumentation library information.",
originFullName: "otlpcommon.InstrumentationScope",
fields: []baseField{
nameField,
Expand All @@ -57,10 +57,10 @@ var mapStruct = &sliceOfPtrs{

var attributeKeyValue = &messageValueStruct{}

var instrumentationLibraryField = &messageValueField{
fieldName: "InstrumentationLibrary",
var scopeField = &messageValueField{
fieldName: "Scope",
originFieldName: "Scope",
returnMessage: instrumentationLibrary,
returnMessage: scope,
}

var startTimeField = &primitiveTypedField{
Expand Down
22 changes: 11 additions & 11 deletions model/internal/cmd/pdatagen/internal/log_structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ var logFile = &File{
structs: []baseStruct{
resourceLogsSlice,
resourceLogs,
instrumentationLibraryLogsSlice,
instrumentationLibraryLogs,
scopeLogsSlice,
scopeLogs,
logSlice,
logRecord,
},
Expand All @@ -51,24 +51,24 @@ var resourceLogs = &messageValueStruct{
resourceField,
schemaURLField,
&sliceField{
fieldName: "InstrumentationLibraryLogs",
fieldName: "ScopeLogs",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need to work with deprecated field InstrumentationLibraryLogs. I assume the field will be added back in #5085

originFieldName: "ScopeLogs",
returnSlice: instrumentationLibraryLogsSlice,
returnSlice: scopeLogsSlice,
},
},
}

var instrumentationLibraryLogsSlice = &sliceOfPtrs{
structName: "InstrumentationLibraryLogsSlice",
element: instrumentationLibraryLogs,
var scopeLogsSlice = &sliceOfPtrs{
structName: "ScopeLogsSlice",
element: scopeLogs,
}

var instrumentationLibraryLogs = &messageValueStruct{
structName: "InstrumentationLibraryLogs",
description: "// InstrumentationLibraryLogs is a collection of logs from a LibraryInstrumentation.",
var scopeLogs = &messageValueStruct{
structName: "ScopeLogs",
description: "// ScopeLogs is a collection of logs from a LibraryInstrumentation.",
originFullName: "otlplogs.ScopeLogs",
fields: []baseField{
instrumentationLibraryField,
scopeField,
schemaURLField,
&sliceField{
fieldName: "LogRecords",
Expand Down
Loading