diff --git a/CHANGELOG.md b/CHANGELOG.md index 739c3156a46..3c923736727 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,7 +42,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.()` functions misuse. diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 732b21bb398..1a63eec7ee5 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -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 Resource labels: -> service.name: STRING(api) -InstrumentationLibrarySpans #0 +ScopeSpans #0 Span #0 Trace ID : 5982fe77008310cc80f1da5e10147519 Parent ID : 90394f6bcffb5d13 diff --git a/exporter/exporterhelper/internal/persistent_queue_test.go b/exporter/exporterhelper/internal/persistent_queue_test.go index 77705f319af..f94a4b35aa4 100644 --- a/exporter/exporterhelper/internal/persistent_queue_test.go +++ b/exporter/exporterhelper/internal/persistent_queue_test.go @@ -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) diff --git a/exporter/exporterhelper/traces_test.go b/exporter/exporterhelper/traces_test.go index f27c6026d38..efa81c908c9 100644 --- a/exporter/exporterhelper/traces_test.go +++ b/exporter/exporterhelper/traces_test.go @@ -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++ { diff --git a/exporter/otlphttpexporter/otlp_test.go b/exporter/otlphttpexporter/otlp_test.go index 6259ef93726..d4391d5a1df 100644 --- a/exporter/otlphttpexporter/otlp_test.go +++ b/exporter/otlphttpexporter/otlp_test.go @@ -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()) })) @@ -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 diff --git a/internal/otlptext/databuffer.go b/internal/otlptext/databuffer.go index a5811fa98b7..356e26b91ab 100644 --- a/internal/otlptext/databuffer.go +++ b/internal/otlptext/databuffer.go @@ -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()) } diff --git a/internal/otlptext/logs.go b/internal/otlptext/logs.go index 1eaaf994ff1..f68e3c90a05 100644 --- a/internal/otlptext/logs.go +++ b/internal/otlptext/logs.go @@ -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++ { diff --git a/internal/otlptext/metrics.go b/internal/otlptext/metrics.go index 66e97b5a20b..4e3d5e69b14 100644 --- a/internal/otlptext/metrics.go +++ b/internal/otlptext/metrics.go @@ -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) diff --git a/internal/otlptext/traces.go b/internal/otlptext/traces.go index 64cb891eb81..7eb86f3c0df 100644 --- a/internal/otlptext/traces.go +++ b/internal/otlptext/traces.go @@ -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++ { diff --git a/internal/testdata/log.go b/internal/testdata/log.go index fec1688f92d..01167385829 100644 --- a/internal/testdata/log.go +++ b/internal/testdata/log.go @@ -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 @@ -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) { @@ -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 diff --git a/internal/testdata/metric.go b/internal/testdata/metric.go index 335cb4a5709..4fc2fe1e4cb 100644 --- a/internal/testdata/metric.go +++ b/internal/testdata/metric.go @@ -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() @@ -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()) @@ -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()) diff --git a/internal/testdata/trace.go b/internal/testdata/trace.go index 9077ea0cd3e..e96207c6d63 100644 --- a/internal/testdata/trace.go +++ b/internal/testdata/trace.go @@ -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 @@ -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()) diff --git a/model/internal/cmd/pdatagen/internal/common_structs.go b/model/internal/cmd/pdatagen/internal/common_structs.go index 364f32b1543..5b9f85386e0 100644 --- a/model/internal/cmd/pdatagen/internal/common_structs.go +++ b/model/internal/cmd/pdatagen/internal/common_structs.go @@ -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, @@ -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{ diff --git a/model/internal/cmd/pdatagen/internal/log_structs.go b/model/internal/cmd/pdatagen/internal/log_structs.go index 8ef56693c38..d743cbcaa59 100644 --- a/model/internal/cmd/pdatagen/internal/log_structs.go +++ b/model/internal/cmd/pdatagen/internal/log_structs.go @@ -31,8 +31,8 @@ var logFile = &File{ structs: []baseStruct{ resourceLogsSlice, resourceLogs, - instrumentationLibraryLogsSlice, - instrumentationLibraryLogs, + scopeLogsSlice, + scopeLogs, logSlice, logRecord, }, @@ -51,24 +51,24 @@ var resourceLogs = &messageValueStruct{ resourceField, schemaURLField, &sliceField{ - fieldName: "InstrumentationLibraryLogs", + fieldName: "ScopeLogs", 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", diff --git a/model/internal/cmd/pdatagen/internal/metrics_structs.go b/model/internal/cmd/pdatagen/internal/metrics_structs.go index 21a3104fb46..37c3be39f09 100644 --- a/model/internal/cmd/pdatagen/internal/metrics_structs.go +++ b/model/internal/cmd/pdatagen/internal/metrics_structs.go @@ -31,8 +31,8 @@ var metricsFile = &File{ structs: []baseStruct{ resourceMetricsSlice, resourceMetrics, - instrumentationLibraryMetricsSlice, - instrumentationLibraryMetrics, + scopeMetricsSlice, + scopeMetrics, metricSlice, metric, gauge, @@ -69,24 +69,24 @@ var resourceMetrics = &messageValueStruct{ resourceField, schemaURLField, &sliceField{ - fieldName: "InstrumentationLibraryMetrics", + fieldName: "ScopeMetrics", originFieldName: "ScopeMetrics", - returnSlice: instrumentationLibraryMetricsSlice, + returnSlice: scopeMetricsSlice, }, }, } -var instrumentationLibraryMetricsSlice = &sliceOfPtrs{ - structName: "InstrumentationLibraryMetricsSlice", - element: instrumentationLibraryMetrics, +var scopeMetricsSlice = &sliceOfPtrs{ + structName: "ScopeMetricsSlice", + element: scopeMetrics, } -var instrumentationLibraryMetrics = &messageValueStruct{ - structName: "InstrumentationLibraryMetrics", - description: "// InstrumentationLibraryMetrics is a collection of metrics from a LibraryInstrumentation.", +var scopeMetrics = &messageValueStruct{ + structName: "ScopeMetrics", + description: "// ScopeMetrics is a collection of metrics from a LibraryInstrumentation.", originFullName: "otlpmetrics.ScopeMetrics", fields: []baseField{ - instrumentationLibraryField, + scopeField, schemaURLField, &sliceField{ fieldName: "Metrics", diff --git a/model/internal/cmd/pdatagen/internal/trace_structs.go b/model/internal/cmd/pdatagen/internal/trace_structs.go index b773487aab4..b88fe7a8e5d 100644 --- a/model/internal/cmd/pdatagen/internal/trace_structs.go +++ b/model/internal/cmd/pdatagen/internal/trace_structs.go @@ -31,8 +31,8 @@ var traceFile = &File{ structs: []baseStruct{ resourceSpansSlice, resourceSpans, - instrumentationLibrarySpansSlice, - instrumentationLibrarySpans, + scopeSpansSlice, + scopeSpans, spanSlice, span, spanEventSlice, @@ -56,24 +56,24 @@ var resourceSpans = &messageValueStruct{ resourceField, schemaURLField, &sliceField{ - fieldName: "InstrumentationLibrarySpans", + fieldName: "ScopeSpans", originFieldName: "ScopeSpans", - returnSlice: instrumentationLibrarySpansSlice, + returnSlice: scopeSpansSlice, }, }, } -var instrumentationLibrarySpansSlice = &sliceOfPtrs{ - structName: "InstrumentationLibrarySpansSlice", - element: instrumentationLibrarySpans, +var scopeSpansSlice = &sliceOfPtrs{ + structName: "ScopeSpansSlice", + element: scopeSpans, } -var instrumentationLibrarySpans = &messageValueStruct{ - structName: "InstrumentationLibrarySpans", - description: "// InstrumentationLibrarySpans is a collection of spans from a LibraryInstrumentation.", +var scopeSpans = &messageValueStruct{ + structName: "ScopeSpans", + description: "// ScopeSpans is a collection of spans from a LibraryInstrumentation.", originFullName: "otlptrace.ScopeSpans", fields: []baseField{ - instrumentationLibraryField, + scopeField, schemaURLField, &sliceField{ fieldName: "Spans", diff --git a/model/internal/pdata/generated_common.go b/model/internal/pdata/generated_common.go index 51b6ceb368d..66178f416a7 100644 --- a/model/internal/pdata/generated_common.go +++ b/model/internal/pdata/generated_common.go @@ -21,58 +21,58 @@ import ( otlpcommon "go.opentelemetry.io/collector/model/internal/data/protogen/common/v1" ) -// InstrumentationLibrary is a message representing the instrumentation library information. +// Scope is a message representing the instrumentation library information. // // This is a reference type, if passed by value and callee modifies it the // caller will see the modification. // -// Must use NewInstrumentationLibrary function to create new instances. +// Must use NewInstrumentationScope function to create new instances. // Important: zero-initialized instance is not valid for use. -type InstrumentationLibrary struct { +type InstrumentationScope struct { orig *otlpcommon.InstrumentationScope } -func newInstrumentationLibrary(orig *otlpcommon.InstrumentationScope) InstrumentationLibrary { - return InstrumentationLibrary{orig: orig} +func newInstrumentationScope(orig *otlpcommon.InstrumentationScope) InstrumentationScope { + return InstrumentationScope{orig: orig} } -// NewInstrumentationLibrary creates a new empty InstrumentationLibrary. +// NewInstrumentationScope creates a new empty InstrumentationScope. // // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. -func NewInstrumentationLibrary() InstrumentationLibrary { - return newInstrumentationLibrary(&otlpcommon.InstrumentationScope{}) +func NewInstrumentationScope() InstrumentationScope { + return newInstrumentationScope(&otlpcommon.InstrumentationScope{}) } // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value -func (ms InstrumentationLibrary) MoveTo(dest InstrumentationLibrary) { +func (ms InstrumentationScope) MoveTo(dest InstrumentationScope) { *dest.orig = *ms.orig *ms.orig = otlpcommon.InstrumentationScope{} } -// Name returns the name associated with this InstrumentationLibrary. -func (ms InstrumentationLibrary) Name() string { +// Name returns the name associated with this InstrumentationScope. +func (ms InstrumentationScope) Name() string { return (*ms.orig).Name } -// SetName replaces the name associated with this InstrumentationLibrary. -func (ms InstrumentationLibrary) SetName(v string) { +// SetName replaces the name associated with this InstrumentationScope. +func (ms InstrumentationScope) SetName(v string) { (*ms.orig).Name = v } -// Version returns the version associated with this InstrumentationLibrary. -func (ms InstrumentationLibrary) Version() string { +// Version returns the version associated with this InstrumentationScope. +func (ms InstrumentationScope) Version() string { return (*ms.orig).Version } -// SetVersion replaces the version associated with this InstrumentationLibrary. -func (ms InstrumentationLibrary) SetVersion(v string) { +// SetVersion replaces the version associated with this InstrumentationScope. +func (ms InstrumentationScope) SetVersion(v string) { (*ms.orig).Version = v } // CopyTo copies all properties from the current struct to the dest. -func (ms InstrumentationLibrary) CopyTo(dest InstrumentationLibrary) { +func (ms InstrumentationScope) CopyTo(dest InstrumentationScope) { dest.SetName(ms.Name()) dest.SetVersion(ms.Version()) } diff --git a/model/internal/pdata/generated_common_test.go b/model/internal/pdata/generated_common_test.go index 6d07af48e25..7705646f377 100644 --- a/model/internal/pdata/generated_common_test.go +++ b/model/internal/pdata/generated_common_test.go @@ -25,30 +25,30 @@ import ( otlpcommon "go.opentelemetry.io/collector/model/internal/data/protogen/common/v1" ) -func TestInstrumentationLibrary_MoveTo(t *testing.T) { - ms := generateTestInstrumentationLibrary() - dest := NewInstrumentationLibrary() +func TestInstrumentationScope_MoveTo(t *testing.T) { + ms := generateTestInstrumentationScope() + dest := NewInstrumentationScope() ms.MoveTo(dest) - assert.EqualValues(t, NewInstrumentationLibrary(), ms) - assert.EqualValues(t, generateTestInstrumentationLibrary(), dest) + assert.EqualValues(t, NewInstrumentationScope(), ms) + assert.EqualValues(t, generateTestInstrumentationScope(), dest) } -func TestInstrumentationLibrary_CopyTo(t *testing.T) { - ms := NewInstrumentationLibrary() - generateTestInstrumentationLibrary().CopyTo(ms) - assert.EqualValues(t, generateTestInstrumentationLibrary(), ms) +func TestInstrumentationScope_CopyTo(t *testing.T) { + ms := NewInstrumentationScope() + generateTestInstrumentationScope().CopyTo(ms) + assert.EqualValues(t, generateTestInstrumentationScope(), ms) } -func TestInstrumentationLibrary_Name(t *testing.T) { - ms := NewInstrumentationLibrary() +func TestInstrumentationScope_Name(t *testing.T) { + ms := NewInstrumentationScope() assert.EqualValues(t, "", ms.Name()) testValName := "test_name" ms.SetName(testValName) assert.EqualValues(t, testValName, ms.Name()) } -func TestInstrumentationLibrary_Version(t *testing.T) { - ms := NewInstrumentationLibrary() +func TestInstrumentationScope_Version(t *testing.T) { + ms := NewInstrumentationScope() assert.EqualValues(t, "", ms.Version()) testValVersion := "test_version" ms.SetVersion(testValVersion) @@ -156,13 +156,13 @@ func TestSlice_RemoveIf(t *testing.T) { assert.Equal(t, 5, filtered.Len()) } -func generateTestInstrumentationLibrary() InstrumentationLibrary { - tv := NewInstrumentationLibrary() - fillTestInstrumentationLibrary(tv) +func generateTestInstrumentationScope() InstrumentationScope { + tv := NewInstrumentationScope() + fillTestInstrumentationScope(tv) return tv } -func fillTestInstrumentationLibrary(tv InstrumentationLibrary) { +func fillTestInstrumentationScope(tv InstrumentationScope) { tv.SetName("test_name") tv.SetVersion("test_version") } diff --git a/model/internal/pdata/generated_log.go b/model/internal/pdata/generated_log.go index 89da87209d5..1dc55017e63 100644 --- a/model/internal/pdata/generated_log.go +++ b/model/internal/pdata/generated_log.go @@ -205,46 +205,46 @@ func (ms ResourceLogs) SetSchemaUrl(v string) { (*ms.orig).SchemaUrl = v } -// InstrumentationLibraryLogs returns the ScopeLogs associated with this ResourceLogs. -func (ms ResourceLogs) InstrumentationLibraryLogs() InstrumentationLibraryLogsSlice { - return newInstrumentationLibraryLogsSlice(&(*ms.orig).ScopeLogs) +// ScopeLogs returns the ScopeLogs associated with this ResourceLogs. +func (ms ResourceLogs) ScopeLogs() ScopeLogsSlice { + return newScopeLogsSlice(&(*ms.orig).ScopeLogs) } // CopyTo copies all properties from the current struct to the dest. func (ms ResourceLogs) CopyTo(dest ResourceLogs) { ms.Resource().CopyTo(dest.Resource()) dest.SetSchemaUrl(ms.SchemaUrl()) - ms.InstrumentationLibraryLogs().CopyTo(dest.InstrumentationLibraryLogs()) + ms.ScopeLogs().CopyTo(dest.ScopeLogs()) } -// InstrumentationLibraryLogsSlice logically represents a slice of InstrumentationLibraryLogs. +// ScopeLogsSlice logically represents a slice of ScopeLogs. // // This is a reference type. If passed by value and callee modifies it, the // caller will see the modification. // -// Must use NewInstrumentationLibraryLogsSlice function to create new instances. +// Must use NewScopeLogsSlice function to create new instances. // Important: zero-initialized instance is not valid for use. -type InstrumentationLibraryLogsSlice struct { +type ScopeLogsSlice struct { // orig points to the slice otlplogs.ScopeLogs field contained somewhere else. // We use pointer-to-slice to be able to modify it in functions like EnsureCapacity. orig *[]*otlplogs.ScopeLogs } -func newInstrumentationLibraryLogsSlice(orig *[]*otlplogs.ScopeLogs) InstrumentationLibraryLogsSlice { - return InstrumentationLibraryLogsSlice{orig} +func newScopeLogsSlice(orig *[]*otlplogs.ScopeLogs) ScopeLogsSlice { + return ScopeLogsSlice{orig} } -// NewInstrumentationLibraryLogsSlice creates a InstrumentationLibraryLogsSlice with 0 elements. +// NewScopeLogsSlice creates a ScopeLogsSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. -func NewInstrumentationLibraryLogsSlice() InstrumentationLibraryLogsSlice { +func NewScopeLogsSlice() ScopeLogsSlice { orig := []*otlplogs.ScopeLogs(nil) - return InstrumentationLibraryLogsSlice{&orig} + return ScopeLogsSlice{&orig} } // Len returns the number of elements in the slice. // -// Returns "0" for a newly instance created with "NewInstrumentationLibraryLogsSlice()". -func (es InstrumentationLibraryLogsSlice) Len() int { +// Returns "0" for a newly instance created with "NewScopeLogsSlice()". +func (es ScopeLogsSlice) Len() int { return len(*es.orig) } @@ -255,18 +255,18 @@ func (es InstrumentationLibraryLogsSlice) Len() int { // e := es.At(i) // ... // Do something with the element // } -func (es InstrumentationLibraryLogsSlice) At(ix int) InstrumentationLibraryLogs { - return newInstrumentationLibraryLogs((*es.orig)[ix]) +func (es ScopeLogsSlice) At(ix int) ScopeLogs { + return newScopeLogs((*es.orig)[ix]) } // CopyTo copies all elements from the current slice to the dest. -func (es InstrumentationLibraryLogsSlice) CopyTo(dest InstrumentationLibraryLogsSlice) { +func (es ScopeLogsSlice) CopyTo(dest ScopeLogsSlice) { srcLen := es.Len() destCap := cap(*dest.orig) if srcLen <= destCap { (*dest.orig) = (*dest.orig)[:srcLen:destCap] for i := range *es.orig { - newInstrumentationLibraryLogs((*es.orig)[i]).CopyTo(newInstrumentationLibraryLogs((*dest.orig)[i])) + newScopeLogs((*es.orig)[i]).CopyTo(newScopeLogs((*dest.orig)[i])) } return } @@ -274,7 +274,7 @@ func (es InstrumentationLibraryLogsSlice) CopyTo(dest InstrumentationLibraryLogs wrappers := make([]*otlplogs.ScopeLogs, srcLen) for i := range *es.orig { wrappers[i] = &origs[i] - newInstrumentationLibraryLogs((*es.orig)[i]).CopyTo(newInstrumentationLibraryLogs(wrappers[i])) + newScopeLogs((*es.orig)[i]).CopyTo(newScopeLogs(wrappers[i])) } *dest.orig = wrappers } @@ -283,14 +283,14 @@ func (es InstrumentationLibraryLogsSlice) CopyTo(dest InstrumentationLibraryLogs // 1. If the newCap <= cap then no change in capacity. // 2. If the newCap > cap then the slice capacity will be expanded to equal newCap. // -// Here is how a new InstrumentationLibraryLogsSlice can be initialized: -// es := NewInstrumentationLibraryLogsSlice() +// Here is how a new ScopeLogsSlice can be initialized: +// es := NewScopeLogsSlice() // es.EnsureCapacity(4) // for i := 0; i < 4; i++ { // e := es.AppendEmpty() // // Here should set all the values for e. // } -func (es InstrumentationLibraryLogsSlice) EnsureCapacity(newCap int) { +func (es ScopeLogsSlice) EnsureCapacity(newCap int) { oldCap := cap(*es.orig) if newCap <= oldCap { return @@ -301,30 +301,30 @@ func (es InstrumentationLibraryLogsSlice) EnsureCapacity(newCap int) { *es.orig = newOrig } -// AppendEmpty will append to the end of the slice an empty InstrumentationLibraryLogs. -// It returns the newly added InstrumentationLibraryLogs. -func (es InstrumentationLibraryLogsSlice) AppendEmpty() InstrumentationLibraryLogs { +// AppendEmpty will append to the end of the slice an empty ScopeLogs. +// It returns the newly added ScopeLogs. +func (es ScopeLogsSlice) AppendEmpty() ScopeLogs { *es.orig = append(*es.orig, &otlplogs.ScopeLogs{}) return es.At(es.Len() - 1) } -// Sort sorts the InstrumentationLibraryLogs elements within InstrumentationLibraryLogsSlice given the -// provided less function so that two instances of InstrumentationLibraryLogsSlice +// Sort sorts the ScopeLogs elements within ScopeLogsSlice given the +// provided less function so that two instances of ScopeLogsSlice // can be compared. // // Returns the same instance to allow nicer code like: -// lessFunc := func(a, b InstrumentationLibraryLogs) bool { +// lessFunc := func(a, b ScopeLogs) bool { // return a.Name() < b.Name() // choose any comparison here // } // assert.EqualValues(t, expected.Sort(lessFunc), actual.Sort(lessFunc)) -func (es InstrumentationLibraryLogsSlice) Sort(less func(a, b InstrumentationLibraryLogs) bool) InstrumentationLibraryLogsSlice { +func (es ScopeLogsSlice) Sort(less func(a, b ScopeLogs) bool) ScopeLogsSlice { sort.SliceStable(*es.orig, func(i, j int) bool { return less(es.At(i), es.At(j)) }) return es } // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. -func (es InstrumentationLibraryLogsSlice) MoveAndAppendTo(dest InstrumentationLibraryLogsSlice) { +func (es ScopeLogsSlice) MoveAndAppendTo(dest ScopeLogsSlice) { if *dest.orig == nil { // We can simply move the entire vector and avoid any allocations. *dest.orig = *es.orig @@ -336,7 +336,7 @@ func (es InstrumentationLibraryLogsSlice) MoveAndAppendTo(dest InstrumentationLi // RemoveIf calls f sequentially for each element present in the slice. // If f returns true, the element is removed from the slice. -func (es InstrumentationLibraryLogsSlice) RemoveIf(f func(InstrumentationLibraryLogs) bool) { +func (es ScopeLogsSlice) RemoveIf(f func(ScopeLogs) bool) { newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { @@ -354,59 +354,59 @@ func (es InstrumentationLibraryLogsSlice) RemoveIf(f func(InstrumentationLibrary *es.orig = (*es.orig)[:newLen] } -// InstrumentationLibraryLogs is a collection of logs from a LibraryInstrumentation. +// ScopeLogs is a collection of logs from a LibraryInstrumentation. // // This is a reference type, if passed by value and callee modifies it the // caller will see the modification. // -// Must use NewInstrumentationLibraryLogs function to create new instances. +// Must use NewScopeLogs function to create new instances. // Important: zero-initialized instance is not valid for use. -type InstrumentationLibraryLogs struct { +type ScopeLogs struct { orig *otlplogs.ScopeLogs } -func newInstrumentationLibraryLogs(orig *otlplogs.ScopeLogs) InstrumentationLibraryLogs { - return InstrumentationLibraryLogs{orig: orig} +func newScopeLogs(orig *otlplogs.ScopeLogs) ScopeLogs { + return ScopeLogs{orig: orig} } -// NewInstrumentationLibraryLogs creates a new empty InstrumentationLibraryLogs. +// NewScopeLogs creates a new empty ScopeLogs. // // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. -func NewInstrumentationLibraryLogs() InstrumentationLibraryLogs { - return newInstrumentationLibraryLogs(&otlplogs.ScopeLogs{}) +func NewScopeLogs() ScopeLogs { + return newScopeLogs(&otlplogs.ScopeLogs{}) } // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value -func (ms InstrumentationLibraryLogs) MoveTo(dest InstrumentationLibraryLogs) { +func (ms ScopeLogs) MoveTo(dest ScopeLogs) { *dest.orig = *ms.orig *ms.orig = otlplogs.ScopeLogs{} } -// InstrumentationLibrary returns the instrumentationlibrary associated with this InstrumentationLibraryLogs. -func (ms InstrumentationLibraryLogs) InstrumentationLibrary() InstrumentationLibrary { - return newInstrumentationLibrary(&(*ms.orig).Scope) +// Scope returns the scope associated with this ScopeLogs. +func (ms ScopeLogs) Scope() InstrumentationScope { + return newInstrumentationScope(&(*ms.orig).Scope) } -// SchemaUrl returns the schemaurl associated with this InstrumentationLibraryLogs. -func (ms InstrumentationLibraryLogs) SchemaUrl() string { +// SchemaUrl returns the schemaurl associated with this ScopeLogs. +func (ms ScopeLogs) SchemaUrl() string { return (*ms.orig).SchemaUrl } -// SetSchemaUrl replaces the schemaurl associated with this InstrumentationLibraryLogs. -func (ms InstrumentationLibraryLogs) SetSchemaUrl(v string) { +// SetSchemaUrl replaces the schemaurl associated with this ScopeLogs. +func (ms ScopeLogs) SetSchemaUrl(v string) { (*ms.orig).SchemaUrl = v } -// LogRecords returns the LogRecords associated with this InstrumentationLibraryLogs. -func (ms InstrumentationLibraryLogs) LogRecords() LogRecordSlice { +// LogRecords returns the LogRecords associated with this ScopeLogs. +func (ms ScopeLogs) LogRecords() LogRecordSlice { return newLogRecordSlice(&(*ms.orig).LogRecords) } // CopyTo copies all properties from the current struct to the dest. -func (ms InstrumentationLibraryLogs) CopyTo(dest InstrumentationLibraryLogs) { - ms.InstrumentationLibrary().CopyTo(dest.InstrumentationLibrary()) +func (ms ScopeLogs) CopyTo(dest ScopeLogs) { + ms.Scope().CopyTo(dest.Scope()) dest.SetSchemaUrl(ms.SchemaUrl()) ms.LogRecords().CopyTo(dest.LogRecords()) } diff --git a/model/internal/pdata/generated_log_test.go b/model/internal/pdata/generated_log_test.go index dc4dd96e839..b93907c4de1 100644 --- a/model/internal/pdata/generated_log_test.go +++ b/model/internal/pdata/generated_log_test.go @@ -163,49 +163,49 @@ func TestResourceLogs_SchemaUrl(t *testing.T) { assert.EqualValues(t, testValSchemaUrl, ms.SchemaUrl()) } -func TestResourceLogs_InstrumentationLibraryLogs(t *testing.T) { +func TestResourceLogs_ScopeLogs(t *testing.T) { ms := NewResourceLogs() - assert.EqualValues(t, NewInstrumentationLibraryLogsSlice(), ms.InstrumentationLibraryLogs()) - fillTestInstrumentationLibraryLogsSlice(ms.InstrumentationLibraryLogs()) - testValInstrumentationLibraryLogs := generateTestInstrumentationLibraryLogsSlice() - assert.EqualValues(t, testValInstrumentationLibraryLogs, ms.InstrumentationLibraryLogs()) + assert.EqualValues(t, NewScopeLogsSlice(), ms.ScopeLogs()) + fillTestScopeLogsSlice(ms.ScopeLogs()) + testValScopeLogs := generateTestScopeLogsSlice() + assert.EqualValues(t, testValScopeLogs, ms.ScopeLogs()) } -func TestInstrumentationLibraryLogsSlice(t *testing.T) { - es := NewInstrumentationLibraryLogsSlice() +func TestScopeLogsSlice(t *testing.T) { + es := NewScopeLogsSlice() assert.EqualValues(t, 0, es.Len()) - es = newInstrumentationLibraryLogsSlice(&[]*otlplogs.ScopeLogs{}) + es = newScopeLogsSlice(&[]*otlplogs.ScopeLogs{}) assert.EqualValues(t, 0, es.Len()) es.EnsureCapacity(7) - emptyVal := newInstrumentationLibraryLogs(&otlplogs.ScopeLogs{}) - testVal := generateTestInstrumentationLibraryLogs() + emptyVal := newScopeLogs(&otlplogs.ScopeLogs{}) + testVal := generateTestScopeLogs() assert.EqualValues(t, 7, cap(*es.orig)) for i := 0; i < es.Len(); i++ { el := es.AppendEmpty() assert.EqualValues(t, emptyVal, el) - fillTestInstrumentationLibraryLogs(el) + fillTestScopeLogs(el) assert.EqualValues(t, testVal, el) } } -func TestInstrumentationLibraryLogsSlice_CopyTo(t *testing.T) { - dest := NewInstrumentationLibraryLogsSlice() +func TestScopeLogsSlice_CopyTo(t *testing.T) { + dest := NewScopeLogsSlice() // Test CopyTo to empty - NewInstrumentationLibraryLogsSlice().CopyTo(dest) - assert.EqualValues(t, NewInstrumentationLibraryLogsSlice(), dest) + NewScopeLogsSlice().CopyTo(dest) + assert.EqualValues(t, NewScopeLogsSlice(), dest) // Test CopyTo larger slice - generateTestInstrumentationLibraryLogsSlice().CopyTo(dest) - assert.EqualValues(t, generateTestInstrumentationLibraryLogsSlice(), dest) + generateTestScopeLogsSlice().CopyTo(dest) + assert.EqualValues(t, generateTestScopeLogsSlice(), dest) // Test CopyTo same size slice - generateTestInstrumentationLibraryLogsSlice().CopyTo(dest) - assert.EqualValues(t, generateTestInstrumentationLibraryLogsSlice(), dest) + generateTestScopeLogsSlice().CopyTo(dest) + assert.EqualValues(t, generateTestScopeLogsSlice(), dest) } -func TestInstrumentationLibraryLogsSlice_EnsureCapacity(t *testing.T) { - es := generateTestInstrumentationLibraryLogsSlice() +func TestScopeLogsSlice_EnsureCapacity(t *testing.T) { + es := generateTestScopeLogsSlice() // Test ensure smaller capacity. const ensureSmallLen = 4 expectedEs := make(map[*otlplogs.ScopeLogs]bool) @@ -238,24 +238,24 @@ func TestInstrumentationLibraryLogsSlice_EnsureCapacity(t *testing.T) { assert.EqualValues(t, expectedEs, foundEs) } -func TestInstrumentationLibraryLogsSlice_MoveAndAppendTo(t *testing.T) { +func TestScopeLogsSlice_MoveAndAppendTo(t *testing.T) { // Test MoveAndAppendTo to empty - expectedSlice := generateTestInstrumentationLibraryLogsSlice() - dest := NewInstrumentationLibraryLogsSlice() - src := generateTestInstrumentationLibraryLogsSlice() + expectedSlice := generateTestScopeLogsSlice() + dest := NewScopeLogsSlice() + src := generateTestScopeLogsSlice() src.MoveAndAppendTo(dest) - assert.EqualValues(t, generateTestInstrumentationLibraryLogsSlice(), dest) + assert.EqualValues(t, generateTestScopeLogsSlice(), dest) assert.EqualValues(t, 0, src.Len()) assert.EqualValues(t, expectedSlice.Len(), dest.Len()) // Test MoveAndAppendTo empty slice src.MoveAndAppendTo(dest) - assert.EqualValues(t, generateTestInstrumentationLibraryLogsSlice(), dest) + assert.EqualValues(t, generateTestScopeLogsSlice(), dest) assert.EqualValues(t, 0, src.Len()) assert.EqualValues(t, expectedSlice.Len(), dest.Len()) // Test MoveAndAppendTo not empty slice - generateTestInstrumentationLibraryLogsSlice().MoveAndAppendTo(dest) + generateTestScopeLogsSlice().MoveAndAppendTo(dest) assert.EqualValues(t, 2*expectedSlice.Len(), dest.Len()) for i := 0; i < expectedSlice.Len(); i++ { assert.EqualValues(t, expectedSlice.At(i), dest.At(i)) @@ -263,54 +263,54 @@ func TestInstrumentationLibraryLogsSlice_MoveAndAppendTo(t *testing.T) { } } -func TestInstrumentationLibraryLogsSlice_RemoveIf(t *testing.T) { +func TestScopeLogsSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice - emptySlice := NewInstrumentationLibraryLogsSlice() - emptySlice.RemoveIf(func(el InstrumentationLibraryLogs) bool { + emptySlice := NewScopeLogsSlice() + emptySlice.RemoveIf(func(el ScopeLogs) bool { t.Fail() return false }) // Test RemoveIf - filtered := generateTestInstrumentationLibraryLogsSlice() + filtered := generateTestScopeLogsSlice() pos := 0 - filtered.RemoveIf(func(el InstrumentationLibraryLogs) bool { + filtered.RemoveIf(func(el ScopeLogs) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } -func TestInstrumentationLibraryLogs_MoveTo(t *testing.T) { - ms := generateTestInstrumentationLibraryLogs() - dest := NewInstrumentationLibraryLogs() +func TestScopeLogs_MoveTo(t *testing.T) { + ms := generateTestScopeLogs() + dest := NewScopeLogs() ms.MoveTo(dest) - assert.EqualValues(t, NewInstrumentationLibraryLogs(), ms) - assert.EqualValues(t, generateTestInstrumentationLibraryLogs(), dest) + assert.EqualValues(t, NewScopeLogs(), ms) + assert.EqualValues(t, generateTestScopeLogs(), dest) } -func TestInstrumentationLibraryLogs_CopyTo(t *testing.T) { - ms := NewInstrumentationLibraryLogs() - generateTestInstrumentationLibraryLogs().CopyTo(ms) - assert.EqualValues(t, generateTestInstrumentationLibraryLogs(), ms) +func TestScopeLogs_CopyTo(t *testing.T) { + ms := NewScopeLogs() + generateTestScopeLogs().CopyTo(ms) + assert.EqualValues(t, generateTestScopeLogs(), ms) } -func TestInstrumentationLibraryLogs_InstrumentationLibrary(t *testing.T) { - ms := NewInstrumentationLibraryLogs() - fillTestInstrumentationLibrary(ms.InstrumentationLibrary()) - assert.EqualValues(t, generateTestInstrumentationLibrary(), ms.InstrumentationLibrary()) +func TestScopeLogs_Scope(t *testing.T) { + ms := NewScopeLogs() + fillTestInstrumentationScope(ms.Scope()) + assert.EqualValues(t, generateTestInstrumentationScope(), ms.Scope()) } -func TestInstrumentationLibraryLogs_SchemaUrl(t *testing.T) { - ms := NewInstrumentationLibraryLogs() +func TestScopeLogs_SchemaUrl(t *testing.T) { + ms := NewScopeLogs() assert.EqualValues(t, "", ms.SchemaUrl()) testValSchemaUrl := "https://opentelemetry.io/schemas/1.5.0" ms.SetSchemaUrl(testValSchemaUrl) assert.EqualValues(t, testValSchemaUrl, ms.SchemaUrl()) } -func TestInstrumentationLibraryLogs_LogRecords(t *testing.T) { - ms := NewInstrumentationLibraryLogs() +func TestScopeLogs_LogRecords(t *testing.T) { + ms := NewScopeLogs() assert.EqualValues(t, NewLogRecordSlice(), ms.LogRecords()) fillTestLogRecordSlice(ms.LogRecords()) testValLogRecords := generateTestLogRecordSlice() @@ -542,31 +542,31 @@ func generateTestResourceLogs() ResourceLogs { func fillTestResourceLogs(tv ResourceLogs) { fillTestResource(tv.Resource()) tv.SetSchemaUrl("https://opentelemetry.io/schemas/1.5.0") - fillTestInstrumentationLibraryLogsSlice(tv.InstrumentationLibraryLogs()) + fillTestScopeLogsSlice(tv.ScopeLogs()) } -func generateTestInstrumentationLibraryLogsSlice() InstrumentationLibraryLogsSlice { - tv := NewInstrumentationLibraryLogsSlice() - fillTestInstrumentationLibraryLogsSlice(tv) +func generateTestScopeLogsSlice() ScopeLogsSlice { + tv := NewScopeLogsSlice() + fillTestScopeLogsSlice(tv) return tv } -func fillTestInstrumentationLibraryLogsSlice(tv InstrumentationLibraryLogsSlice) { +func fillTestScopeLogsSlice(tv ScopeLogsSlice) { l := 7 tv.EnsureCapacity(l) for i := 0; i < l; i++ { - fillTestInstrumentationLibraryLogs(tv.AppendEmpty()) + fillTestScopeLogs(tv.AppendEmpty()) } } -func generateTestInstrumentationLibraryLogs() InstrumentationLibraryLogs { - tv := NewInstrumentationLibraryLogs() - fillTestInstrumentationLibraryLogs(tv) +func generateTestScopeLogs() ScopeLogs { + tv := NewScopeLogs() + fillTestScopeLogs(tv) return tv } -func fillTestInstrumentationLibraryLogs(tv InstrumentationLibraryLogs) { - fillTestInstrumentationLibrary(tv.InstrumentationLibrary()) +func fillTestScopeLogs(tv ScopeLogs) { + fillTestInstrumentationScope(tv.Scope()) tv.SetSchemaUrl("https://opentelemetry.io/schemas/1.5.0") fillTestLogRecordSlice(tv.LogRecords()) } diff --git a/model/internal/pdata/generated_metrics.go b/model/internal/pdata/generated_metrics.go index a4ddb24f26a..89e50f0afc0 100644 --- a/model/internal/pdata/generated_metrics.go +++ b/model/internal/pdata/generated_metrics.go @@ -205,46 +205,46 @@ func (ms ResourceMetrics) SetSchemaUrl(v string) { (*ms.orig).SchemaUrl = v } -// InstrumentationLibraryMetrics returns the ScopeMetrics associated with this ResourceMetrics. -func (ms ResourceMetrics) InstrumentationLibraryMetrics() InstrumentationLibraryMetricsSlice { - return newInstrumentationLibraryMetricsSlice(&(*ms.orig).ScopeMetrics) +// ScopeMetrics returns the ScopeMetrics associated with this ResourceMetrics. +func (ms ResourceMetrics) ScopeMetrics() ScopeMetricsSlice { + return newScopeMetricsSlice(&(*ms.orig).ScopeMetrics) } // CopyTo copies all properties from the current struct to the dest. func (ms ResourceMetrics) CopyTo(dest ResourceMetrics) { ms.Resource().CopyTo(dest.Resource()) dest.SetSchemaUrl(ms.SchemaUrl()) - ms.InstrumentationLibraryMetrics().CopyTo(dest.InstrumentationLibraryMetrics()) + ms.ScopeMetrics().CopyTo(dest.ScopeMetrics()) } -// InstrumentationLibraryMetricsSlice logically represents a slice of InstrumentationLibraryMetrics. +// ScopeMetricsSlice logically represents a slice of ScopeMetrics. // // This is a reference type. If passed by value and callee modifies it, the // caller will see the modification. // -// Must use NewInstrumentationLibraryMetricsSlice function to create new instances. +// Must use NewScopeMetricsSlice function to create new instances. // Important: zero-initialized instance is not valid for use. -type InstrumentationLibraryMetricsSlice struct { +type ScopeMetricsSlice struct { // orig points to the slice otlpmetrics.ScopeMetrics field contained somewhere else. // We use pointer-to-slice to be able to modify it in functions like EnsureCapacity. orig *[]*otlpmetrics.ScopeMetrics } -func newInstrumentationLibraryMetricsSlice(orig *[]*otlpmetrics.ScopeMetrics) InstrumentationLibraryMetricsSlice { - return InstrumentationLibraryMetricsSlice{orig} +func newScopeMetricsSlice(orig *[]*otlpmetrics.ScopeMetrics) ScopeMetricsSlice { + return ScopeMetricsSlice{orig} } -// NewInstrumentationLibraryMetricsSlice creates a InstrumentationLibraryMetricsSlice with 0 elements. +// NewScopeMetricsSlice creates a ScopeMetricsSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. -func NewInstrumentationLibraryMetricsSlice() InstrumentationLibraryMetricsSlice { +func NewScopeMetricsSlice() ScopeMetricsSlice { orig := []*otlpmetrics.ScopeMetrics(nil) - return InstrumentationLibraryMetricsSlice{&orig} + return ScopeMetricsSlice{&orig} } // Len returns the number of elements in the slice. // -// Returns "0" for a newly instance created with "NewInstrumentationLibraryMetricsSlice()". -func (es InstrumentationLibraryMetricsSlice) Len() int { +// Returns "0" for a newly instance created with "NewScopeMetricsSlice()". +func (es ScopeMetricsSlice) Len() int { return len(*es.orig) } @@ -255,18 +255,18 @@ func (es InstrumentationLibraryMetricsSlice) Len() int { // e := es.At(i) // ... // Do something with the element // } -func (es InstrumentationLibraryMetricsSlice) At(ix int) InstrumentationLibraryMetrics { - return newInstrumentationLibraryMetrics((*es.orig)[ix]) +func (es ScopeMetricsSlice) At(ix int) ScopeMetrics { + return newScopeMetrics((*es.orig)[ix]) } // CopyTo copies all elements from the current slice to the dest. -func (es InstrumentationLibraryMetricsSlice) CopyTo(dest InstrumentationLibraryMetricsSlice) { +func (es ScopeMetricsSlice) CopyTo(dest ScopeMetricsSlice) { srcLen := es.Len() destCap := cap(*dest.orig) if srcLen <= destCap { (*dest.orig) = (*dest.orig)[:srcLen:destCap] for i := range *es.orig { - newInstrumentationLibraryMetrics((*es.orig)[i]).CopyTo(newInstrumentationLibraryMetrics((*dest.orig)[i])) + newScopeMetrics((*es.orig)[i]).CopyTo(newScopeMetrics((*dest.orig)[i])) } return } @@ -274,7 +274,7 @@ func (es InstrumentationLibraryMetricsSlice) CopyTo(dest InstrumentationLibraryM wrappers := make([]*otlpmetrics.ScopeMetrics, srcLen) for i := range *es.orig { wrappers[i] = &origs[i] - newInstrumentationLibraryMetrics((*es.orig)[i]).CopyTo(newInstrumentationLibraryMetrics(wrappers[i])) + newScopeMetrics((*es.orig)[i]).CopyTo(newScopeMetrics(wrappers[i])) } *dest.orig = wrappers } @@ -283,14 +283,14 @@ func (es InstrumentationLibraryMetricsSlice) CopyTo(dest InstrumentationLibraryM // 1. If the newCap <= cap then no change in capacity. // 2. If the newCap > cap then the slice capacity will be expanded to equal newCap. // -// Here is how a new InstrumentationLibraryMetricsSlice can be initialized: -// es := NewInstrumentationLibraryMetricsSlice() +// Here is how a new ScopeMetricsSlice can be initialized: +// es := NewScopeMetricsSlice() // es.EnsureCapacity(4) // for i := 0; i < 4; i++ { // e := es.AppendEmpty() // // Here should set all the values for e. // } -func (es InstrumentationLibraryMetricsSlice) EnsureCapacity(newCap int) { +func (es ScopeMetricsSlice) EnsureCapacity(newCap int) { oldCap := cap(*es.orig) if newCap <= oldCap { return @@ -301,30 +301,30 @@ func (es InstrumentationLibraryMetricsSlice) EnsureCapacity(newCap int) { *es.orig = newOrig } -// AppendEmpty will append to the end of the slice an empty InstrumentationLibraryMetrics. -// It returns the newly added InstrumentationLibraryMetrics. -func (es InstrumentationLibraryMetricsSlice) AppendEmpty() InstrumentationLibraryMetrics { +// AppendEmpty will append to the end of the slice an empty ScopeMetrics. +// It returns the newly added ScopeMetrics. +func (es ScopeMetricsSlice) AppendEmpty() ScopeMetrics { *es.orig = append(*es.orig, &otlpmetrics.ScopeMetrics{}) return es.At(es.Len() - 1) } -// Sort sorts the InstrumentationLibraryMetrics elements within InstrumentationLibraryMetricsSlice given the -// provided less function so that two instances of InstrumentationLibraryMetricsSlice +// Sort sorts the ScopeMetrics elements within ScopeMetricsSlice given the +// provided less function so that two instances of ScopeMetricsSlice // can be compared. // // Returns the same instance to allow nicer code like: -// lessFunc := func(a, b InstrumentationLibraryMetrics) bool { +// lessFunc := func(a, b ScopeMetrics) bool { // return a.Name() < b.Name() // choose any comparison here // } // assert.EqualValues(t, expected.Sort(lessFunc), actual.Sort(lessFunc)) -func (es InstrumentationLibraryMetricsSlice) Sort(less func(a, b InstrumentationLibraryMetrics) bool) InstrumentationLibraryMetricsSlice { +func (es ScopeMetricsSlice) Sort(less func(a, b ScopeMetrics) bool) ScopeMetricsSlice { sort.SliceStable(*es.orig, func(i, j int) bool { return less(es.At(i), es.At(j)) }) return es } // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. -func (es InstrumentationLibraryMetricsSlice) MoveAndAppendTo(dest InstrumentationLibraryMetricsSlice) { +func (es ScopeMetricsSlice) MoveAndAppendTo(dest ScopeMetricsSlice) { if *dest.orig == nil { // We can simply move the entire vector and avoid any allocations. *dest.orig = *es.orig @@ -336,7 +336,7 @@ func (es InstrumentationLibraryMetricsSlice) MoveAndAppendTo(dest Instrumentatio // RemoveIf calls f sequentially for each element present in the slice. // If f returns true, the element is removed from the slice. -func (es InstrumentationLibraryMetricsSlice) RemoveIf(f func(InstrumentationLibraryMetrics) bool) { +func (es ScopeMetricsSlice) RemoveIf(f func(ScopeMetrics) bool) { newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { @@ -354,59 +354,59 @@ func (es InstrumentationLibraryMetricsSlice) RemoveIf(f func(InstrumentationLibr *es.orig = (*es.orig)[:newLen] } -// InstrumentationLibraryMetrics is a collection of metrics from a LibraryInstrumentation. +// ScopeMetrics is a collection of metrics from a LibraryInstrumentation. // // This is a reference type, if passed by value and callee modifies it the // caller will see the modification. // -// Must use NewInstrumentationLibraryMetrics function to create new instances. +// Must use NewScopeMetrics function to create new instances. // Important: zero-initialized instance is not valid for use. -type InstrumentationLibraryMetrics struct { +type ScopeMetrics struct { orig *otlpmetrics.ScopeMetrics } -func newInstrumentationLibraryMetrics(orig *otlpmetrics.ScopeMetrics) InstrumentationLibraryMetrics { - return InstrumentationLibraryMetrics{orig: orig} +func newScopeMetrics(orig *otlpmetrics.ScopeMetrics) ScopeMetrics { + return ScopeMetrics{orig: orig} } -// NewInstrumentationLibraryMetrics creates a new empty InstrumentationLibraryMetrics. +// NewScopeMetrics creates a new empty ScopeMetrics. // // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. -func NewInstrumentationLibraryMetrics() InstrumentationLibraryMetrics { - return newInstrumentationLibraryMetrics(&otlpmetrics.ScopeMetrics{}) +func NewScopeMetrics() ScopeMetrics { + return newScopeMetrics(&otlpmetrics.ScopeMetrics{}) } // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value -func (ms InstrumentationLibraryMetrics) MoveTo(dest InstrumentationLibraryMetrics) { +func (ms ScopeMetrics) MoveTo(dest ScopeMetrics) { *dest.orig = *ms.orig *ms.orig = otlpmetrics.ScopeMetrics{} } -// InstrumentationLibrary returns the instrumentationlibrary associated with this InstrumentationLibraryMetrics. -func (ms InstrumentationLibraryMetrics) InstrumentationLibrary() InstrumentationLibrary { - return newInstrumentationLibrary(&(*ms.orig).Scope) +// Scope returns the scope associated with this ScopeMetrics. +func (ms ScopeMetrics) Scope() InstrumentationScope { + return newInstrumentationScope(&(*ms.orig).Scope) } -// SchemaUrl returns the schemaurl associated with this InstrumentationLibraryMetrics. -func (ms InstrumentationLibraryMetrics) SchemaUrl() string { +// SchemaUrl returns the schemaurl associated with this ScopeMetrics. +func (ms ScopeMetrics) SchemaUrl() string { return (*ms.orig).SchemaUrl } -// SetSchemaUrl replaces the schemaurl associated with this InstrumentationLibraryMetrics. -func (ms InstrumentationLibraryMetrics) SetSchemaUrl(v string) { +// SetSchemaUrl replaces the schemaurl associated with this ScopeMetrics. +func (ms ScopeMetrics) SetSchemaUrl(v string) { (*ms.orig).SchemaUrl = v } -// Metrics returns the Metrics associated with this InstrumentationLibraryMetrics. -func (ms InstrumentationLibraryMetrics) Metrics() MetricSlice { +// Metrics returns the Metrics associated with this ScopeMetrics. +func (ms ScopeMetrics) Metrics() MetricSlice { return newMetricSlice(&(*ms.orig).Metrics) } // CopyTo copies all properties from the current struct to the dest. -func (ms InstrumentationLibraryMetrics) CopyTo(dest InstrumentationLibraryMetrics) { - ms.InstrumentationLibrary().CopyTo(dest.InstrumentationLibrary()) +func (ms ScopeMetrics) CopyTo(dest ScopeMetrics) { + ms.Scope().CopyTo(dest.Scope()) dest.SetSchemaUrl(ms.SchemaUrl()) ms.Metrics().CopyTo(dest.Metrics()) } diff --git a/model/internal/pdata/generated_metrics_test.go b/model/internal/pdata/generated_metrics_test.go index 5c2edc9aec2..c379bb937c4 100644 --- a/model/internal/pdata/generated_metrics_test.go +++ b/model/internal/pdata/generated_metrics_test.go @@ -163,49 +163,49 @@ func TestResourceMetrics_SchemaUrl(t *testing.T) { assert.EqualValues(t, testValSchemaUrl, ms.SchemaUrl()) } -func TestResourceMetrics_InstrumentationLibraryMetrics(t *testing.T) { +func TestResourceMetrics_ScopeMetrics(t *testing.T) { ms := NewResourceMetrics() - assert.EqualValues(t, NewInstrumentationLibraryMetricsSlice(), ms.InstrumentationLibraryMetrics()) - fillTestInstrumentationLibraryMetricsSlice(ms.InstrumentationLibraryMetrics()) - testValInstrumentationLibraryMetrics := generateTestInstrumentationLibraryMetricsSlice() - assert.EqualValues(t, testValInstrumentationLibraryMetrics, ms.InstrumentationLibraryMetrics()) + assert.EqualValues(t, NewScopeMetricsSlice(), ms.ScopeMetrics()) + fillTestScopeMetricsSlice(ms.ScopeMetrics()) + testValScopeMetrics := generateTestScopeMetricsSlice() + assert.EqualValues(t, testValScopeMetrics, ms.ScopeMetrics()) } -func TestInstrumentationLibraryMetricsSlice(t *testing.T) { - es := NewInstrumentationLibraryMetricsSlice() +func TestScopeMetricsSlice(t *testing.T) { + es := NewScopeMetricsSlice() assert.EqualValues(t, 0, es.Len()) - es = newInstrumentationLibraryMetricsSlice(&[]*otlpmetrics.ScopeMetrics{}) + es = newScopeMetricsSlice(&[]*otlpmetrics.ScopeMetrics{}) assert.EqualValues(t, 0, es.Len()) es.EnsureCapacity(7) - emptyVal := newInstrumentationLibraryMetrics(&otlpmetrics.ScopeMetrics{}) - testVal := generateTestInstrumentationLibraryMetrics() + emptyVal := newScopeMetrics(&otlpmetrics.ScopeMetrics{}) + testVal := generateTestScopeMetrics() assert.EqualValues(t, 7, cap(*es.orig)) for i := 0; i < es.Len(); i++ { el := es.AppendEmpty() assert.EqualValues(t, emptyVal, el) - fillTestInstrumentationLibraryMetrics(el) + fillTestScopeMetrics(el) assert.EqualValues(t, testVal, el) } } -func TestInstrumentationLibraryMetricsSlice_CopyTo(t *testing.T) { - dest := NewInstrumentationLibraryMetricsSlice() +func TestScopeMetricsSlice_CopyTo(t *testing.T) { + dest := NewScopeMetricsSlice() // Test CopyTo to empty - NewInstrumentationLibraryMetricsSlice().CopyTo(dest) - assert.EqualValues(t, NewInstrumentationLibraryMetricsSlice(), dest) + NewScopeMetricsSlice().CopyTo(dest) + assert.EqualValues(t, NewScopeMetricsSlice(), dest) // Test CopyTo larger slice - generateTestInstrumentationLibraryMetricsSlice().CopyTo(dest) - assert.EqualValues(t, generateTestInstrumentationLibraryMetricsSlice(), dest) + generateTestScopeMetricsSlice().CopyTo(dest) + assert.EqualValues(t, generateTestScopeMetricsSlice(), dest) // Test CopyTo same size slice - generateTestInstrumentationLibraryMetricsSlice().CopyTo(dest) - assert.EqualValues(t, generateTestInstrumentationLibraryMetricsSlice(), dest) + generateTestScopeMetricsSlice().CopyTo(dest) + assert.EqualValues(t, generateTestScopeMetricsSlice(), dest) } -func TestInstrumentationLibraryMetricsSlice_EnsureCapacity(t *testing.T) { - es := generateTestInstrumentationLibraryMetricsSlice() +func TestScopeMetricsSlice_EnsureCapacity(t *testing.T) { + es := generateTestScopeMetricsSlice() // Test ensure smaller capacity. const ensureSmallLen = 4 expectedEs := make(map[*otlpmetrics.ScopeMetrics]bool) @@ -238,24 +238,24 @@ func TestInstrumentationLibraryMetricsSlice_EnsureCapacity(t *testing.T) { assert.EqualValues(t, expectedEs, foundEs) } -func TestInstrumentationLibraryMetricsSlice_MoveAndAppendTo(t *testing.T) { +func TestScopeMetricsSlice_MoveAndAppendTo(t *testing.T) { // Test MoveAndAppendTo to empty - expectedSlice := generateTestInstrumentationLibraryMetricsSlice() - dest := NewInstrumentationLibraryMetricsSlice() - src := generateTestInstrumentationLibraryMetricsSlice() + expectedSlice := generateTestScopeMetricsSlice() + dest := NewScopeMetricsSlice() + src := generateTestScopeMetricsSlice() src.MoveAndAppendTo(dest) - assert.EqualValues(t, generateTestInstrumentationLibraryMetricsSlice(), dest) + assert.EqualValues(t, generateTestScopeMetricsSlice(), dest) assert.EqualValues(t, 0, src.Len()) assert.EqualValues(t, expectedSlice.Len(), dest.Len()) // Test MoveAndAppendTo empty slice src.MoveAndAppendTo(dest) - assert.EqualValues(t, generateTestInstrumentationLibraryMetricsSlice(), dest) + assert.EqualValues(t, generateTestScopeMetricsSlice(), dest) assert.EqualValues(t, 0, src.Len()) assert.EqualValues(t, expectedSlice.Len(), dest.Len()) // Test MoveAndAppendTo not empty slice - generateTestInstrumentationLibraryMetricsSlice().MoveAndAppendTo(dest) + generateTestScopeMetricsSlice().MoveAndAppendTo(dest) assert.EqualValues(t, 2*expectedSlice.Len(), dest.Len()) for i := 0; i < expectedSlice.Len(); i++ { assert.EqualValues(t, expectedSlice.At(i), dest.At(i)) @@ -263,54 +263,54 @@ func TestInstrumentationLibraryMetricsSlice_MoveAndAppendTo(t *testing.T) { } } -func TestInstrumentationLibraryMetricsSlice_RemoveIf(t *testing.T) { +func TestScopeMetricsSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice - emptySlice := NewInstrumentationLibraryMetricsSlice() - emptySlice.RemoveIf(func(el InstrumentationLibraryMetrics) bool { + emptySlice := NewScopeMetricsSlice() + emptySlice.RemoveIf(func(el ScopeMetrics) bool { t.Fail() return false }) // Test RemoveIf - filtered := generateTestInstrumentationLibraryMetricsSlice() + filtered := generateTestScopeMetricsSlice() pos := 0 - filtered.RemoveIf(func(el InstrumentationLibraryMetrics) bool { + filtered.RemoveIf(func(el ScopeMetrics) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } -func TestInstrumentationLibraryMetrics_MoveTo(t *testing.T) { - ms := generateTestInstrumentationLibraryMetrics() - dest := NewInstrumentationLibraryMetrics() +func TestScopeMetrics_MoveTo(t *testing.T) { + ms := generateTestScopeMetrics() + dest := NewScopeMetrics() ms.MoveTo(dest) - assert.EqualValues(t, NewInstrumentationLibraryMetrics(), ms) - assert.EqualValues(t, generateTestInstrumentationLibraryMetrics(), dest) + assert.EqualValues(t, NewScopeMetrics(), ms) + assert.EqualValues(t, generateTestScopeMetrics(), dest) } -func TestInstrumentationLibraryMetrics_CopyTo(t *testing.T) { - ms := NewInstrumentationLibraryMetrics() - generateTestInstrumentationLibraryMetrics().CopyTo(ms) - assert.EqualValues(t, generateTestInstrumentationLibraryMetrics(), ms) +func TestScopeMetrics_CopyTo(t *testing.T) { + ms := NewScopeMetrics() + generateTestScopeMetrics().CopyTo(ms) + assert.EqualValues(t, generateTestScopeMetrics(), ms) } -func TestInstrumentationLibraryMetrics_InstrumentationLibrary(t *testing.T) { - ms := NewInstrumentationLibraryMetrics() - fillTestInstrumentationLibrary(ms.InstrumentationLibrary()) - assert.EqualValues(t, generateTestInstrumentationLibrary(), ms.InstrumentationLibrary()) +func TestScopeMetrics_Scope(t *testing.T) { + ms := NewScopeMetrics() + fillTestInstrumentationScope(ms.Scope()) + assert.EqualValues(t, generateTestInstrumentationScope(), ms.Scope()) } -func TestInstrumentationLibraryMetrics_SchemaUrl(t *testing.T) { - ms := NewInstrumentationLibraryMetrics() +func TestScopeMetrics_SchemaUrl(t *testing.T) { + ms := NewScopeMetrics() assert.EqualValues(t, "", ms.SchemaUrl()) testValSchemaUrl := "https://opentelemetry.io/schemas/1.5.0" ms.SetSchemaUrl(testValSchemaUrl) assert.EqualValues(t, testValSchemaUrl, ms.SchemaUrl()) } -func TestInstrumentationLibraryMetrics_Metrics(t *testing.T) { - ms := NewInstrumentationLibraryMetrics() +func TestScopeMetrics_Metrics(t *testing.T) { + ms := NewScopeMetrics() assert.EqualValues(t, NewMetricSlice(), ms.Metrics()) fillTestMetricSlice(ms.Metrics()) testValMetrics := generateTestMetricSlice() @@ -1853,31 +1853,31 @@ func generateTestResourceMetrics() ResourceMetrics { func fillTestResourceMetrics(tv ResourceMetrics) { fillTestResource(tv.Resource()) tv.SetSchemaUrl("https://opentelemetry.io/schemas/1.5.0") - fillTestInstrumentationLibraryMetricsSlice(tv.InstrumentationLibraryMetrics()) + fillTestScopeMetricsSlice(tv.ScopeMetrics()) } -func generateTestInstrumentationLibraryMetricsSlice() InstrumentationLibraryMetricsSlice { - tv := NewInstrumentationLibraryMetricsSlice() - fillTestInstrumentationLibraryMetricsSlice(tv) +func generateTestScopeMetricsSlice() ScopeMetricsSlice { + tv := NewScopeMetricsSlice() + fillTestScopeMetricsSlice(tv) return tv } -func fillTestInstrumentationLibraryMetricsSlice(tv InstrumentationLibraryMetricsSlice) { +func fillTestScopeMetricsSlice(tv ScopeMetricsSlice) { l := 7 tv.EnsureCapacity(l) for i := 0; i < l; i++ { - fillTestInstrumentationLibraryMetrics(tv.AppendEmpty()) + fillTestScopeMetrics(tv.AppendEmpty()) } } -func generateTestInstrumentationLibraryMetrics() InstrumentationLibraryMetrics { - tv := NewInstrumentationLibraryMetrics() - fillTestInstrumentationLibraryMetrics(tv) +func generateTestScopeMetrics() ScopeMetrics { + tv := NewScopeMetrics() + fillTestScopeMetrics(tv) return tv } -func fillTestInstrumentationLibraryMetrics(tv InstrumentationLibraryMetrics) { - fillTestInstrumentationLibrary(tv.InstrumentationLibrary()) +func fillTestScopeMetrics(tv ScopeMetrics) { + fillTestInstrumentationScope(tv.Scope()) tv.SetSchemaUrl("https://opentelemetry.io/schemas/1.5.0") fillTestMetricSlice(tv.Metrics()) } diff --git a/model/internal/pdata/generated_trace.go b/model/internal/pdata/generated_trace.go index 0166e86ce36..61555f03a05 100644 --- a/model/internal/pdata/generated_trace.go +++ b/model/internal/pdata/generated_trace.go @@ -205,46 +205,46 @@ func (ms ResourceSpans) SetSchemaUrl(v string) { (*ms.orig).SchemaUrl = v } -// InstrumentationLibrarySpans returns the ScopeSpans associated with this ResourceSpans. -func (ms ResourceSpans) InstrumentationLibrarySpans() InstrumentationLibrarySpansSlice { - return newInstrumentationLibrarySpansSlice(&(*ms.orig).ScopeSpans) +// ScopeSpans returns the ScopeSpans associated with this ResourceSpans. +func (ms ResourceSpans) ScopeSpans() ScopeSpansSlice { + return newScopeSpansSlice(&(*ms.orig).ScopeSpans) } // CopyTo copies all properties from the current struct to the dest. func (ms ResourceSpans) CopyTo(dest ResourceSpans) { ms.Resource().CopyTo(dest.Resource()) dest.SetSchemaUrl(ms.SchemaUrl()) - ms.InstrumentationLibrarySpans().CopyTo(dest.InstrumentationLibrarySpans()) + ms.ScopeSpans().CopyTo(dest.ScopeSpans()) } -// InstrumentationLibrarySpansSlice logically represents a slice of InstrumentationLibrarySpans. +// ScopeSpansSlice logically represents a slice of ScopeSpans. // // This is a reference type. If passed by value and callee modifies it, the // caller will see the modification. // -// Must use NewInstrumentationLibrarySpansSlice function to create new instances. +// Must use NewScopeSpansSlice function to create new instances. // Important: zero-initialized instance is not valid for use. -type InstrumentationLibrarySpansSlice struct { +type ScopeSpansSlice struct { // orig points to the slice otlptrace.ScopeSpans field contained somewhere else. // We use pointer-to-slice to be able to modify it in functions like EnsureCapacity. orig *[]*otlptrace.ScopeSpans } -func newInstrumentationLibrarySpansSlice(orig *[]*otlptrace.ScopeSpans) InstrumentationLibrarySpansSlice { - return InstrumentationLibrarySpansSlice{orig} +func newScopeSpansSlice(orig *[]*otlptrace.ScopeSpans) ScopeSpansSlice { + return ScopeSpansSlice{orig} } -// NewInstrumentationLibrarySpansSlice creates a InstrumentationLibrarySpansSlice with 0 elements. +// NewScopeSpansSlice creates a ScopeSpansSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. -func NewInstrumentationLibrarySpansSlice() InstrumentationLibrarySpansSlice { +func NewScopeSpansSlice() ScopeSpansSlice { orig := []*otlptrace.ScopeSpans(nil) - return InstrumentationLibrarySpansSlice{&orig} + return ScopeSpansSlice{&orig} } // Len returns the number of elements in the slice. // -// Returns "0" for a newly instance created with "NewInstrumentationLibrarySpansSlice()". -func (es InstrumentationLibrarySpansSlice) Len() int { +// Returns "0" for a newly instance created with "NewScopeSpansSlice()". +func (es ScopeSpansSlice) Len() int { return len(*es.orig) } @@ -255,18 +255,18 @@ func (es InstrumentationLibrarySpansSlice) Len() int { // e := es.At(i) // ... // Do something with the element // } -func (es InstrumentationLibrarySpansSlice) At(ix int) InstrumentationLibrarySpans { - return newInstrumentationLibrarySpans((*es.orig)[ix]) +func (es ScopeSpansSlice) At(ix int) ScopeSpans { + return newScopeSpans((*es.orig)[ix]) } // CopyTo copies all elements from the current slice to the dest. -func (es InstrumentationLibrarySpansSlice) CopyTo(dest InstrumentationLibrarySpansSlice) { +func (es ScopeSpansSlice) CopyTo(dest ScopeSpansSlice) { srcLen := es.Len() destCap := cap(*dest.orig) if srcLen <= destCap { (*dest.orig) = (*dest.orig)[:srcLen:destCap] for i := range *es.orig { - newInstrumentationLibrarySpans((*es.orig)[i]).CopyTo(newInstrumentationLibrarySpans((*dest.orig)[i])) + newScopeSpans((*es.orig)[i]).CopyTo(newScopeSpans((*dest.orig)[i])) } return } @@ -274,7 +274,7 @@ func (es InstrumentationLibrarySpansSlice) CopyTo(dest InstrumentationLibrarySpa wrappers := make([]*otlptrace.ScopeSpans, srcLen) for i := range *es.orig { wrappers[i] = &origs[i] - newInstrumentationLibrarySpans((*es.orig)[i]).CopyTo(newInstrumentationLibrarySpans(wrappers[i])) + newScopeSpans((*es.orig)[i]).CopyTo(newScopeSpans(wrappers[i])) } *dest.orig = wrappers } @@ -283,14 +283,14 @@ func (es InstrumentationLibrarySpansSlice) CopyTo(dest InstrumentationLibrarySpa // 1. If the newCap <= cap then no change in capacity. // 2. If the newCap > cap then the slice capacity will be expanded to equal newCap. // -// Here is how a new InstrumentationLibrarySpansSlice can be initialized: -// es := NewInstrumentationLibrarySpansSlice() +// Here is how a new ScopeSpansSlice can be initialized: +// es := NewScopeSpansSlice() // es.EnsureCapacity(4) // for i := 0; i < 4; i++ { // e := es.AppendEmpty() // // Here should set all the values for e. // } -func (es InstrumentationLibrarySpansSlice) EnsureCapacity(newCap int) { +func (es ScopeSpansSlice) EnsureCapacity(newCap int) { oldCap := cap(*es.orig) if newCap <= oldCap { return @@ -301,30 +301,30 @@ func (es InstrumentationLibrarySpansSlice) EnsureCapacity(newCap int) { *es.orig = newOrig } -// AppendEmpty will append to the end of the slice an empty InstrumentationLibrarySpans. -// It returns the newly added InstrumentationLibrarySpans. -func (es InstrumentationLibrarySpansSlice) AppendEmpty() InstrumentationLibrarySpans { +// AppendEmpty will append to the end of the slice an empty ScopeSpans. +// It returns the newly added ScopeSpans. +func (es ScopeSpansSlice) AppendEmpty() ScopeSpans { *es.orig = append(*es.orig, &otlptrace.ScopeSpans{}) return es.At(es.Len() - 1) } -// Sort sorts the InstrumentationLibrarySpans elements within InstrumentationLibrarySpansSlice given the -// provided less function so that two instances of InstrumentationLibrarySpansSlice +// Sort sorts the ScopeSpans elements within ScopeSpansSlice given the +// provided less function so that two instances of ScopeSpansSlice // can be compared. // // Returns the same instance to allow nicer code like: -// lessFunc := func(a, b InstrumentationLibrarySpans) bool { +// lessFunc := func(a, b ScopeSpans) bool { // return a.Name() < b.Name() // choose any comparison here // } // assert.EqualValues(t, expected.Sort(lessFunc), actual.Sort(lessFunc)) -func (es InstrumentationLibrarySpansSlice) Sort(less func(a, b InstrumentationLibrarySpans) bool) InstrumentationLibrarySpansSlice { +func (es ScopeSpansSlice) Sort(less func(a, b ScopeSpans) bool) ScopeSpansSlice { sort.SliceStable(*es.orig, func(i, j int) bool { return less(es.At(i), es.At(j)) }) return es } // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. -func (es InstrumentationLibrarySpansSlice) MoveAndAppendTo(dest InstrumentationLibrarySpansSlice) { +func (es ScopeSpansSlice) MoveAndAppendTo(dest ScopeSpansSlice) { if *dest.orig == nil { // We can simply move the entire vector and avoid any allocations. *dest.orig = *es.orig @@ -336,7 +336,7 @@ func (es InstrumentationLibrarySpansSlice) MoveAndAppendTo(dest InstrumentationL // RemoveIf calls f sequentially for each element present in the slice. // If f returns true, the element is removed from the slice. -func (es InstrumentationLibrarySpansSlice) RemoveIf(f func(InstrumentationLibrarySpans) bool) { +func (es ScopeSpansSlice) RemoveIf(f func(ScopeSpans) bool) { newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { @@ -354,59 +354,59 @@ func (es InstrumentationLibrarySpansSlice) RemoveIf(f func(InstrumentationLibrar *es.orig = (*es.orig)[:newLen] } -// InstrumentationLibrarySpans is a collection of spans from a LibraryInstrumentation. +// ScopeSpans is a collection of spans from a LibraryInstrumentation. // // This is a reference type, if passed by value and callee modifies it the // caller will see the modification. // -// Must use NewInstrumentationLibrarySpans function to create new instances. +// Must use NewScopeSpans function to create new instances. // Important: zero-initialized instance is not valid for use. -type InstrumentationLibrarySpans struct { +type ScopeSpans struct { orig *otlptrace.ScopeSpans } -func newInstrumentationLibrarySpans(orig *otlptrace.ScopeSpans) InstrumentationLibrarySpans { - return InstrumentationLibrarySpans{orig: orig} +func newScopeSpans(orig *otlptrace.ScopeSpans) ScopeSpans { + return ScopeSpans{orig: orig} } -// NewInstrumentationLibrarySpans creates a new empty InstrumentationLibrarySpans. +// NewScopeSpans creates a new empty ScopeSpans. // // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. -func NewInstrumentationLibrarySpans() InstrumentationLibrarySpans { - return newInstrumentationLibrarySpans(&otlptrace.ScopeSpans{}) +func NewScopeSpans() ScopeSpans { + return newScopeSpans(&otlptrace.ScopeSpans{}) } // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value -func (ms InstrumentationLibrarySpans) MoveTo(dest InstrumentationLibrarySpans) { +func (ms ScopeSpans) MoveTo(dest ScopeSpans) { *dest.orig = *ms.orig *ms.orig = otlptrace.ScopeSpans{} } -// InstrumentationLibrary returns the instrumentationlibrary associated with this InstrumentationLibrarySpans. -func (ms InstrumentationLibrarySpans) InstrumentationLibrary() InstrumentationLibrary { - return newInstrumentationLibrary(&(*ms.orig).Scope) +// Scope returns the scope associated with this ScopeSpans. +func (ms ScopeSpans) Scope() InstrumentationScope { + return newInstrumentationScope(&(*ms.orig).Scope) } -// SchemaUrl returns the schemaurl associated with this InstrumentationLibrarySpans. -func (ms InstrumentationLibrarySpans) SchemaUrl() string { +// SchemaUrl returns the schemaurl associated with this ScopeSpans. +func (ms ScopeSpans) SchemaUrl() string { return (*ms.orig).SchemaUrl } -// SetSchemaUrl replaces the schemaurl associated with this InstrumentationLibrarySpans. -func (ms InstrumentationLibrarySpans) SetSchemaUrl(v string) { +// SetSchemaUrl replaces the schemaurl associated with this ScopeSpans. +func (ms ScopeSpans) SetSchemaUrl(v string) { (*ms.orig).SchemaUrl = v } -// Spans returns the Spans associated with this InstrumentationLibrarySpans. -func (ms InstrumentationLibrarySpans) Spans() SpanSlice { +// Spans returns the Spans associated with this ScopeSpans. +func (ms ScopeSpans) Spans() SpanSlice { return newSpanSlice(&(*ms.orig).Spans) } // CopyTo copies all properties from the current struct to the dest. -func (ms InstrumentationLibrarySpans) CopyTo(dest InstrumentationLibrarySpans) { - ms.InstrumentationLibrary().CopyTo(dest.InstrumentationLibrary()) +func (ms ScopeSpans) CopyTo(dest ScopeSpans) { + ms.Scope().CopyTo(dest.Scope()) dest.SetSchemaUrl(ms.SchemaUrl()) ms.Spans().CopyTo(dest.Spans()) } diff --git a/model/internal/pdata/generated_trace_test.go b/model/internal/pdata/generated_trace_test.go index d60c00ff663..e3cb138d3e9 100644 --- a/model/internal/pdata/generated_trace_test.go +++ b/model/internal/pdata/generated_trace_test.go @@ -163,49 +163,49 @@ func TestResourceSpans_SchemaUrl(t *testing.T) { assert.EqualValues(t, testValSchemaUrl, ms.SchemaUrl()) } -func TestResourceSpans_InstrumentationLibrarySpans(t *testing.T) { +func TestResourceSpans_ScopeSpans(t *testing.T) { ms := NewResourceSpans() - assert.EqualValues(t, NewInstrumentationLibrarySpansSlice(), ms.InstrumentationLibrarySpans()) - fillTestInstrumentationLibrarySpansSlice(ms.InstrumentationLibrarySpans()) - testValInstrumentationLibrarySpans := generateTestInstrumentationLibrarySpansSlice() - assert.EqualValues(t, testValInstrumentationLibrarySpans, ms.InstrumentationLibrarySpans()) + assert.EqualValues(t, NewScopeSpansSlice(), ms.ScopeSpans()) + fillTestScopeSpansSlice(ms.ScopeSpans()) + testValScopeSpans := generateTestScopeSpansSlice() + assert.EqualValues(t, testValScopeSpans, ms.ScopeSpans()) } -func TestInstrumentationLibrarySpansSlice(t *testing.T) { - es := NewInstrumentationLibrarySpansSlice() +func TestScopeSpansSlice(t *testing.T) { + es := NewScopeSpansSlice() assert.EqualValues(t, 0, es.Len()) - es = newInstrumentationLibrarySpansSlice(&[]*otlptrace.ScopeSpans{}) + es = newScopeSpansSlice(&[]*otlptrace.ScopeSpans{}) assert.EqualValues(t, 0, es.Len()) es.EnsureCapacity(7) - emptyVal := newInstrumentationLibrarySpans(&otlptrace.ScopeSpans{}) - testVal := generateTestInstrumentationLibrarySpans() + emptyVal := newScopeSpans(&otlptrace.ScopeSpans{}) + testVal := generateTestScopeSpans() assert.EqualValues(t, 7, cap(*es.orig)) for i := 0; i < es.Len(); i++ { el := es.AppendEmpty() assert.EqualValues(t, emptyVal, el) - fillTestInstrumentationLibrarySpans(el) + fillTestScopeSpans(el) assert.EqualValues(t, testVal, el) } } -func TestInstrumentationLibrarySpansSlice_CopyTo(t *testing.T) { - dest := NewInstrumentationLibrarySpansSlice() +func TestScopeSpansSlice_CopyTo(t *testing.T) { + dest := NewScopeSpansSlice() // Test CopyTo to empty - NewInstrumentationLibrarySpansSlice().CopyTo(dest) - assert.EqualValues(t, NewInstrumentationLibrarySpansSlice(), dest) + NewScopeSpansSlice().CopyTo(dest) + assert.EqualValues(t, NewScopeSpansSlice(), dest) // Test CopyTo larger slice - generateTestInstrumentationLibrarySpansSlice().CopyTo(dest) - assert.EqualValues(t, generateTestInstrumentationLibrarySpansSlice(), dest) + generateTestScopeSpansSlice().CopyTo(dest) + assert.EqualValues(t, generateTestScopeSpansSlice(), dest) // Test CopyTo same size slice - generateTestInstrumentationLibrarySpansSlice().CopyTo(dest) - assert.EqualValues(t, generateTestInstrumentationLibrarySpansSlice(), dest) + generateTestScopeSpansSlice().CopyTo(dest) + assert.EqualValues(t, generateTestScopeSpansSlice(), dest) } -func TestInstrumentationLibrarySpansSlice_EnsureCapacity(t *testing.T) { - es := generateTestInstrumentationLibrarySpansSlice() +func TestScopeSpansSlice_EnsureCapacity(t *testing.T) { + es := generateTestScopeSpansSlice() // Test ensure smaller capacity. const ensureSmallLen = 4 expectedEs := make(map[*otlptrace.ScopeSpans]bool) @@ -238,24 +238,24 @@ func TestInstrumentationLibrarySpansSlice_EnsureCapacity(t *testing.T) { assert.EqualValues(t, expectedEs, foundEs) } -func TestInstrumentationLibrarySpansSlice_MoveAndAppendTo(t *testing.T) { +func TestScopeSpansSlice_MoveAndAppendTo(t *testing.T) { // Test MoveAndAppendTo to empty - expectedSlice := generateTestInstrumentationLibrarySpansSlice() - dest := NewInstrumentationLibrarySpansSlice() - src := generateTestInstrumentationLibrarySpansSlice() + expectedSlice := generateTestScopeSpansSlice() + dest := NewScopeSpansSlice() + src := generateTestScopeSpansSlice() src.MoveAndAppendTo(dest) - assert.EqualValues(t, generateTestInstrumentationLibrarySpansSlice(), dest) + assert.EqualValues(t, generateTestScopeSpansSlice(), dest) assert.EqualValues(t, 0, src.Len()) assert.EqualValues(t, expectedSlice.Len(), dest.Len()) // Test MoveAndAppendTo empty slice src.MoveAndAppendTo(dest) - assert.EqualValues(t, generateTestInstrumentationLibrarySpansSlice(), dest) + assert.EqualValues(t, generateTestScopeSpansSlice(), dest) assert.EqualValues(t, 0, src.Len()) assert.EqualValues(t, expectedSlice.Len(), dest.Len()) // Test MoveAndAppendTo not empty slice - generateTestInstrumentationLibrarySpansSlice().MoveAndAppendTo(dest) + generateTestScopeSpansSlice().MoveAndAppendTo(dest) assert.EqualValues(t, 2*expectedSlice.Len(), dest.Len()) for i := 0; i < expectedSlice.Len(); i++ { assert.EqualValues(t, expectedSlice.At(i), dest.At(i)) @@ -263,54 +263,54 @@ func TestInstrumentationLibrarySpansSlice_MoveAndAppendTo(t *testing.T) { } } -func TestInstrumentationLibrarySpansSlice_RemoveIf(t *testing.T) { +func TestScopeSpansSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice - emptySlice := NewInstrumentationLibrarySpansSlice() - emptySlice.RemoveIf(func(el InstrumentationLibrarySpans) bool { + emptySlice := NewScopeSpansSlice() + emptySlice.RemoveIf(func(el ScopeSpans) bool { t.Fail() return false }) // Test RemoveIf - filtered := generateTestInstrumentationLibrarySpansSlice() + filtered := generateTestScopeSpansSlice() pos := 0 - filtered.RemoveIf(func(el InstrumentationLibrarySpans) bool { + filtered.RemoveIf(func(el ScopeSpans) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } -func TestInstrumentationLibrarySpans_MoveTo(t *testing.T) { - ms := generateTestInstrumentationLibrarySpans() - dest := NewInstrumentationLibrarySpans() +func TestScopeSpans_MoveTo(t *testing.T) { + ms := generateTestScopeSpans() + dest := NewScopeSpans() ms.MoveTo(dest) - assert.EqualValues(t, NewInstrumentationLibrarySpans(), ms) - assert.EqualValues(t, generateTestInstrumentationLibrarySpans(), dest) + assert.EqualValues(t, NewScopeSpans(), ms) + assert.EqualValues(t, generateTestScopeSpans(), dest) } -func TestInstrumentationLibrarySpans_CopyTo(t *testing.T) { - ms := NewInstrumentationLibrarySpans() - generateTestInstrumentationLibrarySpans().CopyTo(ms) - assert.EqualValues(t, generateTestInstrumentationLibrarySpans(), ms) +func TestScopeSpans_CopyTo(t *testing.T) { + ms := NewScopeSpans() + generateTestScopeSpans().CopyTo(ms) + assert.EqualValues(t, generateTestScopeSpans(), ms) } -func TestInstrumentationLibrarySpans_InstrumentationLibrary(t *testing.T) { - ms := NewInstrumentationLibrarySpans() - fillTestInstrumentationLibrary(ms.InstrumentationLibrary()) - assert.EqualValues(t, generateTestInstrumentationLibrary(), ms.InstrumentationLibrary()) +func TestScopeSpans_Scope(t *testing.T) { + ms := NewScopeSpans() + fillTestInstrumentationScope(ms.Scope()) + assert.EqualValues(t, generateTestInstrumentationScope(), ms.Scope()) } -func TestInstrumentationLibrarySpans_SchemaUrl(t *testing.T) { - ms := NewInstrumentationLibrarySpans() +func TestScopeSpans_SchemaUrl(t *testing.T) { + ms := NewScopeSpans() assert.EqualValues(t, "", ms.SchemaUrl()) testValSchemaUrl := "https://opentelemetry.io/schemas/1.5.0" ms.SetSchemaUrl(testValSchemaUrl) assert.EqualValues(t, testValSchemaUrl, ms.SchemaUrl()) } -func TestInstrumentationLibrarySpans_Spans(t *testing.T) { - ms := NewInstrumentationLibrarySpans() +func TestScopeSpans_Spans(t *testing.T) { + ms := NewScopeSpans() assert.EqualValues(t, NewSpanSlice(), ms.Spans()) fillTestSpanSlice(ms.Spans()) testValSpans := generateTestSpanSlice() @@ -932,31 +932,31 @@ func generateTestResourceSpans() ResourceSpans { func fillTestResourceSpans(tv ResourceSpans) { fillTestResource(tv.Resource()) tv.SetSchemaUrl("https://opentelemetry.io/schemas/1.5.0") - fillTestInstrumentationLibrarySpansSlice(tv.InstrumentationLibrarySpans()) + fillTestScopeSpansSlice(tv.ScopeSpans()) } -func generateTestInstrumentationLibrarySpansSlice() InstrumentationLibrarySpansSlice { - tv := NewInstrumentationLibrarySpansSlice() - fillTestInstrumentationLibrarySpansSlice(tv) +func generateTestScopeSpansSlice() ScopeSpansSlice { + tv := NewScopeSpansSlice() + fillTestScopeSpansSlice(tv) return tv } -func fillTestInstrumentationLibrarySpansSlice(tv InstrumentationLibrarySpansSlice) { +func fillTestScopeSpansSlice(tv ScopeSpansSlice) { l := 7 tv.EnsureCapacity(l) for i := 0; i < l; i++ { - fillTestInstrumentationLibrarySpans(tv.AppendEmpty()) + fillTestScopeSpans(tv.AppendEmpty()) } } -func generateTestInstrumentationLibrarySpans() InstrumentationLibrarySpans { - tv := NewInstrumentationLibrarySpans() - fillTestInstrumentationLibrarySpans(tv) +func generateTestScopeSpans() ScopeSpans { + tv := NewScopeSpans() + fillTestScopeSpans(tv) return tv } -func fillTestInstrumentationLibrarySpans(tv InstrumentationLibrarySpans) { - fillTestInstrumentationLibrary(tv.InstrumentationLibrary()) +func fillTestScopeSpans(tv ScopeSpans) { + fillTestInstrumentationScope(tv.Scope()) tv.SetSchemaUrl("https://opentelemetry.io/schemas/1.5.0") fillTestSpanSlice(tv.Spans()) } diff --git a/model/internal/pdata/logs.go b/model/internal/pdata/logs.go index 2f8e7942f8a..18c3626c6b8 100644 --- a/model/internal/pdata/logs.go +++ b/model/internal/pdata/logs.go @@ -70,7 +70,7 @@ func (ld Logs) LogRecordCount() int { rss := ld.ResourceLogs() for i := 0; i < rss.Len(); i++ { rs := rss.At(i) - ill := rs.InstrumentationLibraryLogs() + ill := rs.ScopeLogs() for i := 0; i < ill.Len(); i++ { logs := ill.At(i) logCount += logs.LogRecords().Len() @@ -117,3 +117,13 @@ const ( // String returns the string representation of the SeverityNumber. func (sn SeverityNumber) String() string { return otlplogs.SeverityNumber(sn).String() } + +// Deprecated: [v0.48.0] Use ScopeLogs instead. +func (ms ResourceLogs) InstrumentationLibraryLogs() ScopeLogsSlice { + return ms.ScopeLogs() +} + +// Deprecated: [v0.48.0] Use Scope instead. +func (ms ScopeLogs) InstrumentationLibrary() InstrumentationScope { + return ms.Scope() +} diff --git a/model/internal/pdata/logs_test.go b/model/internal/pdata/logs_test.go index df614f7ffd2..d846209e0fd 100644 --- a/model/internal/pdata/logs_test.go +++ b/model/internal/pdata/logs_test.go @@ -32,7 +32,7 @@ func TestLogRecordCount(t *testing.T) { rl := logs.ResourceLogs().AppendEmpty() assert.EqualValues(t, 0, logs.LogRecordCount()) - ill := rl.InstrumentationLibraryLogs().AppendEmpty() + ill := rl.ScopeLogs().AppendEmpty() assert.EqualValues(t, 0, logs.LogRecordCount()) ill.LogRecords().AppendEmpty() @@ -40,8 +40,8 @@ func TestLogRecordCount(t *testing.T) { rms := logs.ResourceLogs() rms.EnsureCapacity(3) - rms.AppendEmpty().InstrumentationLibraryLogs().AppendEmpty() - illl := rms.AppendEmpty().InstrumentationLibraryLogs().AppendEmpty().LogRecords() + rms.AppendEmpty().ScopeLogs().AppendEmpty() + illl := rms.AppendEmpty().ScopeLogs().AppendEmpty().LogRecords() for i := 0; i < 5; i++ { illl.AppendEmpty() } diff --git a/model/internal/pdata/metrics.go b/model/internal/pdata/metrics.go index 1ce076c4900..dd857195194 100644 --- a/model/internal/pdata/metrics.go +++ b/model/internal/pdata/metrics.go @@ -75,7 +75,7 @@ func (md Metrics) MetricCount() int { rms := md.ResourceMetrics() for i := 0; i < rms.Len(); i++ { rm := rms.At(i) - ilms := rm.InstrumentationLibraryMetrics() + ilms := rm.ScopeMetrics() for j := 0; j < ilms.Len(); j++ { ilm := ilms.At(j) metricCount += ilm.Metrics().Len() @@ -89,7 +89,7 @@ func (md Metrics) DataPointCount() (dataPointCount int) { rms := md.ResourceMetrics() for i := 0; i < rms.Len(); i++ { rm := rms.At(i) - ilms := rm.InstrumentationLibraryMetrics() + ilms := rm.ScopeMetrics() for j := 0; j < ilms.Len(); j++ { ilm := ilms.At(j) ms := ilm.Metrics() @@ -258,3 +258,13 @@ func (ot OptionalType) String() string { } return "" } + +// Deprecated: [v0.48.0] Use ScopeMetrics instead. +func (ms ResourceMetrics) InstrumentationLibraryMetrics() ScopeMetricsSlice { + return ms.ScopeMetrics() +} + +// Deprecated: [v0.48.0] Use Scope instead. +func (ms ScopeMetrics) InstrumentationLibrary() InstrumentationScope { + return ms.Scope() +} diff --git a/model/internal/pdata/metrics_test.go b/model/internal/pdata/metrics_test.go index c417ae18e4c..e1933981db5 100644 --- a/model/internal/pdata/metrics_test.go +++ b/model/internal/pdata/metrics_test.go @@ -91,14 +91,14 @@ func TestMetricCount(t *testing.T) { rm := rms.AppendEmpty() assert.EqualValues(t, 0, md.MetricCount()) - ilm := rm.InstrumentationLibraryMetrics().AppendEmpty() + ilm := rm.ScopeMetrics().AppendEmpty() assert.EqualValues(t, 0, md.MetricCount()) ilm.Metrics().AppendEmpty() assert.EqualValues(t, 1, md.MetricCount()) - rms.AppendEmpty().InstrumentationLibraryMetrics().AppendEmpty() - ilmm := rms.AppendEmpty().InstrumentationLibraryMetrics().AppendEmpty().Metrics() + rms.AppendEmpty().ScopeMetrics().AppendEmpty() + ilmm := rms.AppendEmpty().ScopeMetrics().AppendEmpty().Metrics() ilmm.EnsureCapacity(5) for i := 0; i < 5; i++ { ilmm.AppendEmpty() @@ -123,7 +123,7 @@ func TestMetricAndDataPointCount(t *testing.T) { dps = md.DataPointCount() assert.EqualValues(t, 0, dps) - ilms := md.ResourceMetrics().At(0).InstrumentationLibraryMetrics() + ilms := md.ResourceMetrics().At(0).ScopeMetrics() ilms.AppendEmpty() dps = md.DataPointCount() assert.EqualValues(t, 0, dps) @@ -141,10 +141,10 @@ func TestMetricAndDataPointCount(t *testing.T) { md = NewMetrics() rms = md.ResourceMetrics() rms.EnsureCapacity(3) - rms.AppendEmpty().InstrumentationLibraryMetrics().AppendEmpty().Metrics().AppendEmpty() - rms.AppendEmpty().InstrumentationLibraryMetrics().AppendEmpty() - rms.AppendEmpty().InstrumentationLibraryMetrics().AppendEmpty() - ilms = rms.At(2).InstrumentationLibraryMetrics() + rms.AppendEmpty().ScopeMetrics().AppendEmpty().Metrics().AppendEmpty() + rms.AppendEmpty().ScopeMetrics().AppendEmpty() + rms.AppendEmpty().ScopeMetrics().AppendEmpty() + ilms = rms.At(2).ScopeMetrics() ilm := ilms.At(0).Metrics() for i := 0; i < 5; i++ { ilm.AppendEmpty() @@ -181,7 +181,7 @@ func TestDataPointCountWithEmpty(t *testing.T) { func TestDataPointCountWithNilDataPoints(t *testing.T) { metrics := NewMetrics() - ilm := metrics.ResourceMetrics().AppendEmpty().InstrumentationLibraryMetrics().AppendEmpty() + ilm := metrics.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty() doubleGauge := ilm.Metrics().AppendEmpty() doubleGauge.SetDataType(MetricDataTypeGauge) doubleHistogram := ilm.Metrics().AppendEmpty() @@ -221,7 +221,7 @@ func TestOtlpToInternalReadOnly(t *testing.T) { assert.EqualValues(t, NewMapFromRaw(map[string]interface{}{ "string": "string-resource", }), resourceMetric.Resource().Attributes()) - metrics := resourceMetric.InstrumentationLibraryMetrics().At(0).Metrics() + metrics := resourceMetric.ScopeMetrics().At(0).Metrics() assert.EqualValues(t, 3, metrics.Len()) // Check int64 metric @@ -335,7 +335,7 @@ func TestOtlpToFromInternalGaugeMutating(t *testing.T) { }, }) resourceMetrics := md.ResourceMetrics() - metric := resourceMetrics.At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0) + metric := resourceMetrics.At(0).ScopeMetrics().At(0).Metrics().At(0) // Mutate MetricDescriptor metric.SetName("new_my_metric_int") assert.EqualValues(t, "new_my_metric_int", metric.Name()) @@ -418,7 +418,7 @@ func TestOtlpToFromInternalSumMutating(t *testing.T) { }, }) resourceMetrics := md.ResourceMetrics() - metric := resourceMetrics.At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0) + metric := resourceMetrics.At(0).ScopeMetrics().At(0).Metrics().At(0) // Mutate MetricDescriptor metric.SetName("new_my_metric_double") assert.EqualValues(t, "new_my_metric_double", metric.Name()) @@ -503,7 +503,7 @@ func TestOtlpToFromInternalHistogramMutating(t *testing.T) { }, }) resourceMetrics := md.ResourceMetrics() - metric := resourceMetrics.At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0) + metric := resourceMetrics.At(0).ScopeMetrics().At(0).Metrics().At(0) // Mutate MetricDescriptor metric.SetName("new_my_metric_histogram") assert.EqualValues(t, "new_my_metric_histogram", metric.Name()) @@ -587,7 +587,7 @@ func TestOtlpToFromInternalExponentialHistogramMutating(t *testing.T) { }, }) resourceMetrics := md.ResourceMetrics() - metric := resourceMetrics.At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0) + metric := resourceMetrics.At(0).ScopeMetrics().At(0).Metrics().At(0) // Mutate MetricDescriptor metric.SetName("new_my_metric_exponential_histogram") assert.EqualValues(t, "new_my_metric_exponential_histogram", metric.Name()) @@ -724,7 +724,7 @@ func BenchmarkOtlpToFromInternal_Gauge_MutateOneLabel(b *testing.B) { b.ResetTimer() for n := 0; n < b.N; n++ { md := MetricsFromOtlp(req) - md.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0).Gauge().DataPoints().At(0).Attributes().UpsertString("key0", "value2") + md.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0).Gauge().DataPoints().At(0).Attributes().UpsertString("key0", "value2") newReq := MetricsToOtlp(md) if len(req.ResourceMetrics) != len(newReq.ResourceMetrics) { b.Fail() @@ -750,7 +750,7 @@ func BenchmarkOtlpToFromInternal_Sum_MutateOneLabel(b *testing.B) { b.ResetTimer() for n := 0; n < b.N; n++ { md := MetricsFromOtlp(req) - md.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0).Sum().DataPoints().At(0).Attributes().UpsertString("key0", "value2") + md.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0).Sum().DataPoints().At(0).Attributes().UpsertString("key0", "value2") newReq := MetricsToOtlp(md) if len(req.ResourceMetrics) != len(newReq.ResourceMetrics) { b.Fail() @@ -776,7 +776,7 @@ func BenchmarkOtlpToFromInternal_HistogramPoints_MutateOneLabel(b *testing.B) { b.ResetTimer() for n := 0; n < b.N; n++ { md := MetricsFromOtlp(req) - md.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0).Histogram().DataPoints().At(0).Attributes().UpsertString("key0", "value2") + md.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0).Histogram().DataPoints().At(0).Attributes().UpsertString("key0", "value2") newReq := MetricsToOtlp(md) if len(req.ResourceMetrics) != len(newReq.ResourceMetrics) { b.Fail() diff --git a/model/internal/pdata/traces.go b/model/internal/pdata/traces.go index 0939a10878d..18946f3b047 100644 --- a/model/internal/pdata/traces.go +++ b/model/internal/pdata/traces.go @@ -70,7 +70,7 @@ func (td Traces) SpanCount() int { rss := td.ResourceSpans() for i := 0; i < rss.Len(); i++ { rs := rss.At(i) - ilss := rs.InstrumentationLibrarySpans() + ilss := rs.ScopeSpans() for j := 0; j < ilss.Len(); j++ { spanCount += ilss.At(j).Spans().Len() } @@ -133,3 +133,13 @@ const ( // String returns the string representation of the StatusCode. func (sc StatusCode) String() string { return otlptrace.Status_StatusCode(sc).String() } + +// Deprecated: [v0.48.0] Use ScopeSpans instead. +func (ms ResourceSpans) InstrumentationLibrarySpans() ScopeSpansSlice { + return ms.ScopeSpans() +} + +// Deprecated: [v0.48.0] Use Scope instead. +func (ms ScopeSpans) InstrumentationLibrary() InstrumentationScope { + return ms.Scope() +} diff --git a/model/internal/pdata/traces_test.go b/model/internal/pdata/traces_test.go index d2d1c67e2ae..d70d30f3239 100644 --- a/model/internal/pdata/traces_test.go +++ b/model/internal/pdata/traces_test.go @@ -32,7 +32,7 @@ func TestSpanCount(t *testing.T) { rs := traces.ResourceSpans().AppendEmpty() assert.EqualValues(t, 0, traces.SpanCount()) - ils := rs.InstrumentationLibrarySpans().AppendEmpty() + ils := rs.ScopeSpans().AppendEmpty() assert.EqualValues(t, 0, traces.SpanCount()) ils.Spans().AppendEmpty() @@ -40,8 +40,8 @@ func TestSpanCount(t *testing.T) { rms := traces.ResourceSpans() rms.EnsureCapacity(3) - rms.AppendEmpty().InstrumentationLibrarySpans().AppendEmpty() - ilss := rms.AppendEmpty().InstrumentationLibrarySpans().AppendEmpty().Spans() + rms.AppendEmpty().ScopeSpans().AppendEmpty() + ilss := rms.AppendEmpty().ScopeSpans().AppendEmpty().Spans() for i := 0; i < 5; i++ { ilss.AppendEmpty() } diff --git a/model/otlp/json_test.go b/model/otlp/json_test.go index 23974a26832..20438ab3443 100644 --- a/model/otlp/json_test.go +++ b/model/otlp/json_test.go @@ -26,9 +26,9 @@ var tracesOTLP = func() pdata.Traces { td := pdata.NewTraces() rs := td.ResourceSpans().AppendEmpty() rs.Resource().Attributes().UpsertString("host.name", "testHost") - il := rs.InstrumentationLibrarySpans().AppendEmpty() - il.InstrumentationLibrary().SetName("name") - il.InstrumentationLibrary().SetVersion("version") + il := rs.ScopeSpans().AppendEmpty() + il.Scope().SetName("name") + il.Scope().SetVersion("version") il.Spans().AppendEmpty().SetName("testSpan") return td }() @@ -39,9 +39,9 @@ var metricsOTLP = func() pdata.Metrics { md := pdata.NewMetrics() rm := md.ResourceMetrics().AppendEmpty() rm.Resource().Attributes().UpsertString("host.name", "testHost") - il := rm.InstrumentationLibraryMetrics().AppendEmpty() - il.InstrumentationLibrary().SetName("name") - il.InstrumentationLibrary().SetVersion("version") + il := rm.ScopeMetrics().AppendEmpty() + il.Scope().SetName("name") + il.Scope().SetVersion("version") il.Metrics().AppendEmpty().SetName("testMetric") return md }() @@ -52,9 +52,9 @@ var logsOTLP = func() pdata.Logs { ld := pdata.NewLogs() rl := ld.ResourceLogs().AppendEmpty() rl.Resource().Attributes().UpsertString("host.name", "testHost") - il := rl.InstrumentationLibraryLogs().AppendEmpty() - il.InstrumentationLibrary().SetName("name") - il.InstrumentationLibrary().SetVersion("version") + il := rl.ScopeLogs().AppendEmpty() + il.Scope().SetName("name") + il.Scope().SetVersion("version") il.LogRecords().AppendEmpty().SetSeverityText("Error") return ld }() diff --git a/model/otlp/pb_test.go b/model/otlp/pb_test.go index a9a88fd4b98..3053f23fdd5 100644 --- a/model/otlp/pb_test.go +++ b/model/otlp/pb_test.go @@ -47,7 +47,7 @@ func TestProtobufTracesSizer(t *testing.T) { marshaler := NewProtobufTracesMarshaler() td := pdata.NewTraces() rms := td.ResourceSpans() - rms.AppendEmpty().InstrumentationLibrarySpans().AppendEmpty().Spans().AppendEmpty().SetName("foo") + rms.AppendEmpty().ScopeSpans().AppendEmpty().Spans().AppendEmpty().SetName("foo") size := sizer.TracesSize(td) @@ -66,7 +66,7 @@ func TestProtobufMetricsSizer(t *testing.T) { sizer := NewProtobufMetricsMarshaler().(pdata.MetricsSizer) marshaler := NewProtobufMetricsMarshaler() md := pdata.NewMetrics() - md.ResourceMetrics().AppendEmpty().InstrumentationLibraryMetrics().AppendEmpty().Metrics().AppendEmpty().SetName("foo") + md.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics().AppendEmpty().SetName("foo") size := sizer.MetricsSize(md) @@ -85,7 +85,7 @@ func TestProtobufLogsSizer(t *testing.T) { sizer := NewProtobufLogsMarshaler().(pdata.LogsSizer) marshaler := NewProtobufLogsMarshaler() ld := pdata.NewLogs() - ld.ResourceLogs().AppendEmpty().InstrumentationLibraryLogs().AppendEmpty().LogRecords().AppendEmpty().SetSeverityText("error") + ld.ResourceLogs().AppendEmpty().ScopeLogs().AppendEmpty().LogRecords().AppendEmpty().SetSeverityText("error") size := sizer.LogsSize(ld) @@ -186,7 +186,7 @@ func generateBenchmarkLogs(logsCount int) pdata.Logs { endTime := pdata.NewTimestampFromTime(time.Now()) md := pdata.NewLogs() - ilm := md.ResourceLogs().AppendEmpty().InstrumentationLibraryLogs().AppendEmpty() + ilm := md.ResourceLogs().AppendEmpty().ScopeLogs().AppendEmpty() ilm.LogRecords().EnsureCapacity(logsCount) for i := 0; i < logsCount; i++ { im := ilm.LogRecords().AppendEmpty() @@ -201,7 +201,7 @@ func generateBenchmarkMetrics(metricsCount int) pdata.Metrics { endTime := pdata.NewTimestampFromTime(now) md := pdata.NewMetrics() - ilm := md.ResourceMetrics().AppendEmpty().InstrumentationLibraryMetrics().AppendEmpty() + ilm := md.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty() ilm.Metrics().EnsureCapacity(metricsCount) for i := 0; i < metricsCount; i++ { im := ilm.Metrics().AppendEmpty() @@ -221,7 +221,7 @@ func generateBenchmarkTraces(metricsCount int) pdata.Traces { endTime := pdata.NewTimestampFromTime(now) md := pdata.NewTraces() - ilm := md.ResourceSpans().AppendEmpty().InstrumentationLibrarySpans().AppendEmpty() + ilm := md.ResourceSpans().AppendEmpty().ScopeSpans().AppendEmpty() ilm.Spans().EnsureCapacity(metricsCount) for i := 0; i < metricsCount; i++ { im := ilm.Spans().AppendEmpty() diff --git a/model/otlpgrpc/logs_test.go b/model/otlpgrpc/logs_test.go index c3efe1e6e12..e4b598a5ef6 100644 --- a/model/otlpgrpc/logs_test.go +++ b/model/otlpgrpc/logs_test.go @@ -66,7 +66,7 @@ var logsRequestJSON = []byte(` func TestLogsRequestJSON(t *testing.T) { lr := NewLogsRequest() assert.NoError(t, lr.UnmarshalJSON(logsRequestJSON)) - assert.Equal(t, "test_log_record", lr.Logs().ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords().At(0).Body().AsString()) + assert.Equal(t, "test_log_record", lr.Logs().ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(0).Body().AsString()) got, err := lr.MarshalJSON() assert.NoError(t, err) @@ -76,7 +76,7 @@ func TestLogsRequestJSON(t *testing.T) { func TestLogsRequestJSON_Deprecated(t *testing.T) { lr, err := UnmarshalJSONLogsRequest(logsRequestJSON) assert.NoError(t, err) - assert.Equal(t, "test_log_record", lr.Logs().ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords().At(0).Body().AsString()) + assert.Equal(t, "test_log_record", lr.Logs().ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(0).Body().AsString()) got, err := lr.MarshalJSON() assert.NoError(t, err) @@ -164,7 +164,7 @@ func (f fakeLogsServer) Export(_ context.Context, request LogsRequest) (LogsResp func generateLogsRequest() LogsRequest { ld := pdata.NewLogs() - ld.ResourceLogs().AppendEmpty().InstrumentationLibraryLogs().AppendEmpty().LogRecords().AppendEmpty().Body().SetStringVal("test_log_record") + ld.ResourceLogs().AppendEmpty().ScopeLogs().AppendEmpty().LogRecords().AppendEmpty().Body().SetStringVal("test_log_record") lr := NewLogsRequest() lr.SetLogs(ld) diff --git a/model/otlpgrpc/metrics_test.go b/model/otlpgrpc/metrics_test.go index 841d890cd01..d9b46cadb7e 100644 --- a/model/otlpgrpc/metrics_test.go +++ b/model/otlpgrpc/metrics_test.go @@ -62,7 +62,7 @@ var metricsRequestJSON = []byte(` func TestMetricsRequestJSON(t *testing.T) { mr := NewMetricsRequest() assert.NoError(t, mr.UnmarshalJSON(metricsRequestJSON)) - assert.Equal(t, "test_metric", mr.Metrics().ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0).Name()) + assert.Equal(t, "test_metric", mr.Metrics().ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0).Name()) got, err := mr.MarshalJSON() assert.NoError(t, err) @@ -72,7 +72,7 @@ func TestMetricsRequestJSON(t *testing.T) { func TestMetricsRequestJSON_Deprecated(t *testing.T) { mr, err := UnmarshalJSONMetricsRequest(metricsRequestJSON) assert.NoError(t, err) - assert.Equal(t, "test_metric", mr.Metrics().ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0).Name()) + assert.Equal(t, "test_metric", mr.Metrics().ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0).Name()) got, err := mr.MarshalJSON() assert.NoError(t, err) @@ -160,7 +160,7 @@ func (f fakeMetricsServer) Export(_ context.Context, request MetricsRequest) (Me func generateMetricsRequest() MetricsRequest { md := pdata.NewMetrics() - md.ResourceMetrics().AppendEmpty().InstrumentationLibraryMetrics().AppendEmpty().Metrics().AppendEmpty().SetName("test_metric") + md.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics().AppendEmpty().SetName("test_metric") mr := NewMetricsRequest() mr.SetMetrics(md) diff --git a/model/otlpgrpc/traces_test.go b/model/otlpgrpc/traces_test.go index ef5efc2f20f..107fe5e8cac 100644 --- a/model/otlpgrpc/traces_test.go +++ b/model/otlpgrpc/traces_test.go @@ -66,7 +66,7 @@ var tracesRequestJSON = []byte(` func TestTracesRequestJSON(t *testing.T) { tr := NewTracesRequest() assert.NoError(t, tr.UnmarshalJSON(tracesRequestJSON)) - assert.Equal(t, "test_span", tr.Traces().ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans().At(0).Name()) + assert.Equal(t, "test_span", tr.Traces().ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(0).Name()) got, err := tr.MarshalJSON() assert.NoError(t, err) @@ -76,7 +76,7 @@ func TestTracesRequestJSON(t *testing.T) { func TestTracesRequestJSON_Deprecated(t *testing.T) { tr, err := UnmarshalJSONTracesRequest(tracesRequestJSON) assert.NoError(t, err) - assert.Equal(t, "test_span", tr.Traces().ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans().At(0).Name()) + assert.Equal(t, "test_span", tr.Traces().ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(0).Name()) got, err := tr.MarshalJSON() assert.NoError(t, err) @@ -164,7 +164,7 @@ func (f fakeTracesServer) Export(_ context.Context, request TracesRequest) (Trac func generateTracesRequest() TracesRequest { td := pdata.NewTraces() - td.ResourceSpans().AppendEmpty().InstrumentationLibrarySpans().AppendEmpty().Spans().AppendEmpty().SetName("test_span") + td.ResourceSpans().AppendEmpty().ScopeSpans().AppendEmpty().Spans().AppendEmpty().SetName("test_span") tr := NewTracesRequest() tr.SetTraces(td) diff --git a/model/pdata/common_alias.go b/model/pdata/common_alias.go index 42d76de3735..f32781eafdb 100644 --- a/model/pdata/common_alias.go +++ b/model/pdata/common_alias.go @@ -126,3 +126,9 @@ type AttributeValueSlice = pdata.Slice // Deprecated: [v0.48.0] Use NewSlice instead. var NewAttributeValueSlice = pdata.NewSlice + +// Deprecated: [v0.48.0] Use InstrumentationScope instead. +type InstrumentationLibrary = pdata.InstrumentationScope + +// Deprecated: [v0.48.0] Use NewInstrumentationScope instead. +var NewInstrumentationLibrary = pdata.NewInstrumentationScope diff --git a/model/pdata/generated_common_alias.go b/model/pdata/generated_common_alias.go index f5e077df535..3d3e64a6878 100644 --- a/model/pdata/generated_common_alias.go +++ b/model/pdata/generated_common_alias.go @@ -19,11 +19,11 @@ package pdata import "go.opentelemetry.io/collector/model/internal/pdata" -// InstrumentationLibrary is an alias for pdata.InstrumentationLibrary struct. -type InstrumentationLibrary = pdata.InstrumentationLibrary +// InstrumentationScope is an alias for pdata.InstrumentationScope struct. +type InstrumentationScope = pdata.InstrumentationScope -// NewInstrumentationLibrary is an alias for a function to create a new empty InstrumentationLibrary. -var NewInstrumentationLibrary = pdata.NewInstrumentationLibrary +// NewInstrumentationScope is an alias for a function to create a new empty InstrumentationScope. +var NewInstrumentationScope = pdata.NewInstrumentationScope // Slice is an alias for pdata.Slice struct. type Slice = pdata.Slice diff --git a/model/pdata/generated_log_alias.go b/model/pdata/generated_log_alias.go index 8fb1a2845c0..bafbbff59d4 100644 --- a/model/pdata/generated_log_alias.go +++ b/model/pdata/generated_log_alias.go @@ -31,17 +31,17 @@ type ResourceLogs = pdata.ResourceLogs // NewResourceLogs is an alias for a function to create a new empty ResourceLogs. var NewResourceLogs = pdata.NewResourceLogs -// InstrumentationLibraryLogsSlice is an alias for pdata.InstrumentationLibraryLogsSlice struct. -type InstrumentationLibraryLogsSlice = pdata.InstrumentationLibraryLogsSlice +// ScopeLogsSlice is an alias for pdata.ScopeLogsSlice struct. +type ScopeLogsSlice = pdata.ScopeLogsSlice -// NewInstrumentationLibraryLogsSlice is an alias for a function to create InstrumentationLibraryLogsSlice. -var NewInstrumentationLibraryLogsSlice = pdata.NewInstrumentationLibraryLogsSlice +// NewScopeLogsSlice is an alias for a function to create ScopeLogsSlice. +var NewScopeLogsSlice = pdata.NewScopeLogsSlice -// InstrumentationLibraryLogs is an alias for pdata.InstrumentationLibraryLogs struct. -type InstrumentationLibraryLogs = pdata.InstrumentationLibraryLogs +// ScopeLogs is an alias for pdata.ScopeLogs struct. +type ScopeLogs = pdata.ScopeLogs -// NewInstrumentationLibraryLogs is an alias for a function to create a new empty InstrumentationLibraryLogs. -var NewInstrumentationLibraryLogs = pdata.NewInstrumentationLibraryLogs +// NewScopeLogs is an alias for a function to create a new empty ScopeLogs. +var NewScopeLogs = pdata.NewScopeLogs // LogRecordSlice is an alias for pdata.LogRecordSlice struct. type LogRecordSlice = pdata.LogRecordSlice diff --git a/model/pdata/generated_metrics_alias.go b/model/pdata/generated_metrics_alias.go index b6e77ee7a5b..282dcc9a22f 100644 --- a/model/pdata/generated_metrics_alias.go +++ b/model/pdata/generated_metrics_alias.go @@ -31,17 +31,17 @@ type ResourceMetrics = pdata.ResourceMetrics // NewResourceMetrics is an alias for a function to create a new empty ResourceMetrics. var NewResourceMetrics = pdata.NewResourceMetrics -// InstrumentationLibraryMetricsSlice is an alias for pdata.InstrumentationLibraryMetricsSlice struct. -type InstrumentationLibraryMetricsSlice = pdata.InstrumentationLibraryMetricsSlice +// ScopeMetricsSlice is an alias for pdata.ScopeMetricsSlice struct. +type ScopeMetricsSlice = pdata.ScopeMetricsSlice -// NewInstrumentationLibraryMetricsSlice is an alias for a function to create InstrumentationLibraryMetricsSlice. -var NewInstrumentationLibraryMetricsSlice = pdata.NewInstrumentationLibraryMetricsSlice +// NewScopeMetricsSlice is an alias for a function to create ScopeMetricsSlice. +var NewScopeMetricsSlice = pdata.NewScopeMetricsSlice -// InstrumentationLibraryMetrics is an alias for pdata.InstrumentationLibraryMetrics struct. -type InstrumentationLibraryMetrics = pdata.InstrumentationLibraryMetrics +// ScopeMetrics is an alias for pdata.ScopeMetrics struct. +type ScopeMetrics = pdata.ScopeMetrics -// NewInstrumentationLibraryMetrics is an alias for a function to create a new empty InstrumentationLibraryMetrics. -var NewInstrumentationLibraryMetrics = pdata.NewInstrumentationLibraryMetrics +// NewScopeMetrics is an alias for a function to create a new empty ScopeMetrics. +var NewScopeMetrics = pdata.NewScopeMetrics // MetricSlice is an alias for pdata.MetricSlice struct. type MetricSlice = pdata.MetricSlice diff --git a/model/pdata/generated_trace_alias.go b/model/pdata/generated_trace_alias.go index 52c31abf797..4b3bf5d399b 100644 --- a/model/pdata/generated_trace_alias.go +++ b/model/pdata/generated_trace_alias.go @@ -31,17 +31,17 @@ type ResourceSpans = pdata.ResourceSpans // NewResourceSpans is an alias for a function to create a new empty ResourceSpans. var NewResourceSpans = pdata.NewResourceSpans -// InstrumentationLibrarySpansSlice is an alias for pdata.InstrumentationLibrarySpansSlice struct. -type InstrumentationLibrarySpansSlice = pdata.InstrumentationLibrarySpansSlice +// ScopeSpansSlice is an alias for pdata.ScopeSpansSlice struct. +type ScopeSpansSlice = pdata.ScopeSpansSlice -// NewInstrumentationLibrarySpansSlice is an alias for a function to create InstrumentationLibrarySpansSlice. -var NewInstrumentationLibrarySpansSlice = pdata.NewInstrumentationLibrarySpansSlice +// NewScopeSpansSlice is an alias for a function to create ScopeSpansSlice. +var NewScopeSpansSlice = pdata.NewScopeSpansSlice -// InstrumentationLibrarySpans is an alias for pdata.InstrumentationLibrarySpans struct. -type InstrumentationLibrarySpans = pdata.InstrumentationLibrarySpans +// ScopeSpans is an alias for pdata.ScopeSpans struct. +type ScopeSpans = pdata.ScopeSpans -// NewInstrumentationLibrarySpans is an alias for a function to create a new empty InstrumentationLibrarySpans. -var NewInstrumentationLibrarySpans = pdata.NewInstrumentationLibrarySpans +// NewScopeSpans is an alias for a function to create a new empty ScopeSpans. +var NewScopeSpans = pdata.NewScopeSpans // SpanSlice is an alias for pdata.SpanSlice struct. type SpanSlice = pdata.SpanSlice diff --git a/model/pdata/logs_alias.go b/model/pdata/logs_alias.go index 668cb814f31..878606b92ba 100644 --- a/model/pdata/logs_alias.go +++ b/model/pdata/logs_alias.go @@ -65,3 +65,15 @@ const ( SeverityNumberFATAL3 = pdata.SeverityNumberFATAL3 SeverityNumberFATAL4 = pdata.SeverityNumberFATAL4 ) + +// Deprecated: [v0.48.0] Use ScopeLogsSlice instead. +type InstrumentationLibraryLogsSlice = pdata.ScopeLogsSlice + +// Deprecated: [v0.48.0] Use NewScopeLogsSlice instead. +var NewInstrumentationLibraryLogsSlice = pdata.NewScopeLogsSlice + +// Deprecated: [v0.48.0] Use ScopeLogs instead. +type InstrumentationLibraryLogs = pdata.ScopeLogs + +// Deprecated: [v0.48.0] Use NewScopeLogs instead. +var NewInstrumentationLibraryLogs = pdata.NewScopeLogs diff --git a/model/pdata/metrics_alias.go b/model/pdata/metrics_alias.go index e178d6b98eb..707d2147a3f 100644 --- a/model/pdata/metrics_alias.go +++ b/model/pdata/metrics_alias.go @@ -81,3 +81,15 @@ const ( MetricValueTypeInt = pdata.MetricValueTypeInt MetricValueTypeDouble = pdata.MetricValueTypeDouble ) + +// Deprecated: [v0.48.0] Use ScopeMetricsSlice instead. +type InstrumentationLibraryMetricsSlice = pdata.ScopeMetricsSlice + +// Deprecated: [v0.48.0] Use NewScopeMetricsSlice instead. +var NewInstrumentationLibraryMetricsSlice = pdata.NewScopeMetricsSlice + +// Deprecated: [v0.48.0] Use ScopeMetrics instead. +type InstrumentationLibraryMetrics = pdata.ScopeMetrics + +// Deprecated: [v0.48.0] Use NewScopeMetrics instead. +var NewInstrumentationLibraryMetrics = pdata.NewScopeMetrics diff --git a/model/pdata/traces_alias.go b/model/pdata/traces_alias.go index 8c8989c4cdc..db34296db4e 100644 --- a/model/pdata/traces_alias.go +++ b/model/pdata/traces_alias.go @@ -62,3 +62,15 @@ const ( StatusCodeOk = pdata.StatusCodeOk StatusCodeError = pdata.StatusCodeError ) + +// Deprecated: [v0.48.0] Use ScopeSpansSlice instead. +type InstrumentationLibrarySpansSlice = pdata.ScopeSpansSlice + +// Deprecated: [v0.48.0] Use NewScopeSpansSlice instead. +var NewInstrumentationLibrarySpansSlice = pdata.NewScopeSpansSlice + +// Deprecated: [v0.48.0] Use ScopeSpans instead. +type InstrumentationLibrarySpans = pdata.ScopeSpans + +// Deprecated: [v0.48.0] Use NewScopeSpans instead. +var NewInstrumentationLibrarySpans = pdata.NewScopeSpans diff --git a/processor/batchprocessor/batch_processor_test.go b/processor/batchprocessor/batch_processor_test.go index f7b01f60ed2..0b23cb7bff8 100644 --- a/processor/batchprocessor/batch_processor_test.go +++ b/processor/batchprocessor/batch_processor_test.go @@ -49,7 +49,7 @@ func TestBatchProcessorSpansDelivered(t *testing.T) { traceDataSlice := make([]pdata.Traces, 0, requestCount) for requestNum := 0; requestNum < requestCount; requestNum++ { td := testdata.GenerateTracesManySpansSameResource(spansPerRequest) - spans := td.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans() + spans := td.ResourceSpans().At(0).ScopeSpans().At(0).Spans() for spanIndex := 0; spanIndex < spansPerRequest; spanIndex++ { spans.At(spanIndex).SetName(getTestSpanName(requestNum, spanIndex)) } @@ -67,7 +67,7 @@ func TestBatchProcessorSpansDelivered(t *testing.T) { receivedTraces := sink.AllTraces() spansReceivedByName := spansReceivedByName(receivedTraces) for requestNum := 0; requestNum < requestCount; requestNum++ { - spans := traceDataSlice[requestNum].ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans() + spans := traceDataSlice[requestNum].ResourceSpans().At(0).ScopeSpans().At(0).Spans() for spanIndex := 0; spanIndex < spansPerRequest; spanIndex++ { require.EqualValues(t, spans.At(spanIndex), @@ -90,7 +90,7 @@ func TestBatchProcessorSpansDeliveredEnforceBatchSize(t *testing.T) { spansPerRequest := 150 for requestNum := 0; requestNum < requestCount; requestNum++ { td := testdata.GenerateTracesManySpansSameResource(spansPerRequest) - spans := td.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans() + spans := td.ResourceSpans().At(0).ScopeSpans().At(0).Spans() for spanIndex := 0; spanIndex < spansPerRequest; spanIndex++ { spans.At(spanIndex).SetName(getTestSpanName(requestNum, spanIndex)) } @@ -161,7 +161,7 @@ func TestBatchProcessorSentBySize(t *testing.T) { rss := td.ResourceSpans() require.Equal(t, expectedBatchingFactor, rss.Len()) for i := 0; i < expectedBatchingFactor; i++ { - require.Equal(t, spansPerRequest, rss.At(i).InstrumentationLibrarySpans().At(0).Spans().Len()) + require.Equal(t, spansPerRequest, rss.At(i).ScopeSpans().At(0).Spans().Len()) } } @@ -227,7 +227,7 @@ func TestBatchProcessorSentByTimeout(t *testing.T) { rss := td.ResourceSpans() require.Equal(t, expectedBatchingFactor, rss.Len()) for i := 0; i < expectedBatchingFactor; i++ { - require.Equal(t, spansPerRequest, rss.At(i).InstrumentationLibrarySpans().At(0).Spans().Len()) + require.Equal(t, spansPerRequest, rss.At(i).ScopeSpans().At(0).Spans().Len()) } } } @@ -280,7 +280,7 @@ func TestBatchMetricProcessor_ReceivingData(t *testing.T) { for requestNum := 0; requestNum < requestCount; requestNum++ { md := testdata.GenerateMetricsManyMetricsSameResource(metricsPerRequest) - metrics := md.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics() + metrics := md.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics() for metricIndex := 0; metricIndex < metricsPerRequest; metricIndex++ { metrics.At(metricIndex).SetName(getTestMetricName(requestNum, metricIndex)) } @@ -298,7 +298,7 @@ func TestBatchMetricProcessor_ReceivingData(t *testing.T) { receivedMds := sink.AllMetrics() metricsReceivedByName := metricsReceivedByName(receivedMds) for requestNum := 0; requestNum < requestCount; requestNum++ { - metrics := metricDataSlice[requestNum].ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics() + metrics := metricDataSlice[requestNum].ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics() for metricIndex := 0; metricIndex < metricsPerRequest; metricIndex++ { require.EqualValues(t, metrics.At(metricIndex), @@ -353,7 +353,7 @@ func TestBatchMetricProcessor_BatchSize(t *testing.T) { for _, md := range receivedMds { require.Equal(t, expectedBatchingFactor, md.ResourceMetrics().Len()) for i := 0; i < expectedBatchingFactor; i++ { - require.Equal(t, metricsPerRequest, md.ResourceMetrics().At(i).InstrumentationLibraryMetrics().At(0).Metrics().Len()) + require.Equal(t, metricsPerRequest, md.ResourceMetrics().At(i).ScopeMetrics().At(0).Metrics().Len()) } } @@ -435,7 +435,7 @@ func TestBatchMetricsProcessor_Timeout(t *testing.T) { for _, md := range receivedMds { require.Equal(t, expectedBatchingFactor, md.ResourceMetrics().Len()) for i := 0; i < expectedBatchingFactor; i++ { - require.Equal(t, metricsPerRequest, md.ResourceMetrics().At(i).InstrumentationLibraryMetrics().At(0).Metrics().Len()) + require.Equal(t, metricsPerRequest, md.ResourceMetrics().At(i).ScopeMetrics().At(0).Metrics().Len()) } } } @@ -475,7 +475,7 @@ func spansReceivedByName(tds []pdata.Traces) map[string]pdata.Span { for i := range tds { rss := tds[i].ResourceSpans() for i := 0; i < rss.Len(); i++ { - ilss := rss.At(i).InstrumentationLibrarySpans() + ilss := rss.At(i).ScopeSpans() for j := 0; j < ilss.Len(); j++ { spans := ilss.At(j).Spans() for k := 0; k < spans.Len(); k++ { @@ -493,7 +493,7 @@ func metricsReceivedByName(mds []pdata.Metrics) map[string]pdata.Metric { for _, md := range mds { rms := md.ResourceMetrics() for i := 0; i < rms.Len(); i++ { - ilms := rms.At(i).InstrumentationLibraryMetrics() + ilms := rms.At(i).ScopeMetrics() for j := 0; j < ilms.Len(); j++ { metrics := ilms.At(j).Metrics() for k := 0; k < metrics.Len(); k++ { @@ -596,7 +596,7 @@ func TestBatchLogProcessor_ReceivingData(t *testing.T) { for requestNum := 0; requestNum < requestCount; requestNum++ { ld := testdata.GenerateLogsManyLogRecordsSameResource(logsPerRequest) - logs := ld.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords() + logs := ld.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords() for logIndex := 0; logIndex < logsPerRequest; logIndex++ { logs.At(logIndex).SetSeverityText(getTestLogSeverityText(requestNum, logIndex)) } @@ -614,7 +614,7 @@ func TestBatchLogProcessor_ReceivingData(t *testing.T) { receivedMds := sink.AllLogs() logsReceivedBySeverityText := logsReceivedBySeverityText(receivedMds) for requestNum := 0; requestNum < requestCount; requestNum++ { - logs := logDataSlice[requestNum].ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords() + logs := logDataSlice[requestNum].ResourceLogs().At(0).ScopeLogs().At(0).LogRecords() for logIndex := 0; logIndex < logsPerRequest; logIndex++ { require.EqualValues(t, logs.At(logIndex), @@ -667,7 +667,7 @@ func TestBatchLogProcessor_BatchSize(t *testing.T) { for _, ld := range receivedMds { require.Equal(t, expectedBatchingFactor, ld.ResourceLogs().Len()) for i := 0; i < expectedBatchingFactor; i++ { - require.Equal(t, logsPerRequest, ld.ResourceLogs().At(i).InstrumentationLibraryLogs().At(0).LogRecords().Len()) + require.Equal(t, logsPerRequest, ld.ResourceLogs().At(i).ScopeLogs().At(0).LogRecords().Len()) } } @@ -732,7 +732,7 @@ func TestBatchLogsProcessor_Timeout(t *testing.T) { for _, ld := range receivedMds { require.Equal(t, expectedBatchingFactor, ld.ResourceLogs().Len()) for i := 0; i < expectedBatchingFactor; i++ { - require.Equal(t, logsPerRequest, ld.ResourceLogs().At(i).InstrumentationLibraryLogs().At(0).LogRecords().Len()) + require.Equal(t, logsPerRequest, ld.ResourceLogs().At(i).ScopeLogs().At(0).LogRecords().Len()) } } } @@ -773,7 +773,7 @@ func logsReceivedBySeverityText(lds []pdata.Logs) map[string]pdata.LogRecord { ld := lds[i] rms := ld.ResourceLogs() for i := 0; i < rms.Len(); i++ { - ilms := rms.At(i).InstrumentationLibraryLogs() + ilms := rms.At(i).ScopeLogs() for j := 0; j < ilms.Len(); j++ { logs := ilms.At(j).LogRecords() for k := 0; k < logs.Len(); k++ { diff --git a/processor/batchprocessor/splitlogs.go b/processor/batchprocessor/splitlogs.go index ad04ecf01ce..df40efec179 100644 --- a/processor/batchprocessor/splitlogs.go +++ b/processor/batchprocessor/splitlogs.go @@ -42,7 +42,7 @@ func splitLogs(size int, src pdata.Logs) pdata.Logs { destRl := dest.ResourceLogs().AppendEmpty() srcRl.Resource().CopyTo(destRl.Resource()) - srcRl.InstrumentationLibraryLogs().RemoveIf(func(srcIll pdata.InstrumentationLibraryLogs) bool { + srcRl.ScopeLogs().RemoveIf(func(srcIll pdata.ScopeLogs) bool { // If we are done skip everything else. if totalCopiedLogRecords == size { return false @@ -52,12 +52,12 @@ func splitLogs(size int, src pdata.Logs) pdata.Logs { srcIllLRC := srcIll.LogRecords().Len() if size >= srcIllLRC+totalCopiedLogRecords { totalCopiedLogRecords += srcIllLRC - srcIll.MoveTo(destRl.InstrumentationLibraryLogs().AppendEmpty()) + srcIll.MoveTo(destRl.ScopeLogs().AppendEmpty()) return true } - destIll := destRl.InstrumentationLibraryLogs().AppendEmpty() - srcIll.InstrumentationLibrary().CopyTo(destIll.InstrumentationLibrary()) + destIll := destRl.ScopeLogs().AppendEmpty() + srcIll.Scope().CopyTo(destIll.Scope()) srcIll.LogRecords().RemoveIf(func(srcMetric pdata.LogRecord) bool { // If we are done skip everything else. if totalCopiedLogRecords == size { @@ -69,7 +69,7 @@ func splitLogs(size int, src pdata.Logs) pdata.Logs { }) return false }) - return srcRl.InstrumentationLibraryLogs().Len() == 0 + return srcRl.ScopeLogs().Len() == 0 }) return dest @@ -77,8 +77,8 @@ func splitLogs(size int, src pdata.Logs) pdata.Logs { // resourceLRC calculates the total number of log records in the pdata.ResourceLogs. func resourceLRC(rs pdata.ResourceLogs) (count int) { - for k := 0; k < rs.InstrumentationLibraryLogs().Len(); k++ { - count += rs.InstrumentationLibraryLogs().At(k).LogRecords().Len() + for k := 0; k < rs.ScopeLogs().Len(); k++ { + count += rs.ScopeLogs().At(k).LogRecords().Len() } return } diff --git a/processor/batchprocessor/splitlogs_test.go b/processor/batchprocessor/splitlogs_test.go index 2bec917935b..76d874932f2 100644 --- a/processor/batchprocessor/splitlogs_test.go +++ b/processor/batchprocessor/splitlogs_test.go @@ -30,7 +30,7 @@ func TestSplitLogs_noop(t *testing.T) { assert.Equal(t, td, split) i := 0 - td.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords().RemoveIf(func(_ pdata.LogRecord) bool { + td.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().RemoveIf(func(_ pdata.LogRecord) bool { i++ return i > 5 }) @@ -39,17 +39,17 @@ func TestSplitLogs_noop(t *testing.T) { func TestSplitLogs(t *testing.T) { ld := testdata.GenerateLogsManyLogRecordsSameResource(20) - logs := ld.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords() + logs := ld.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords() for i := 0; i < logs.Len(); i++ { logs.At(i).SetSeverityText(getTestLogSeverityText(0, i)) } cp := pdata.NewLogs() - cpLogs := cp.ResourceLogs().AppendEmpty().InstrumentationLibraryLogs().AppendEmpty().LogRecords() + cpLogs := cp.ResourceLogs().AppendEmpty().ScopeLogs().AppendEmpty().LogRecords() cpLogs.EnsureCapacity(5) ld.ResourceLogs().At(0).Resource().CopyTo( cp.ResourceLogs().At(0).Resource()) - ld.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).InstrumentationLibrary().CopyTo( - cp.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).InstrumentationLibrary()) + ld.ResourceLogs().At(0).ScopeLogs().At(0).Scope().CopyTo( + cp.ResourceLogs().At(0).ScopeLogs().At(0).Scope()) logs.At(0).CopyTo(cpLogs.AppendEmpty()) logs.At(1).CopyTo(cpLogs.AppendEmpty()) logs.At(2).CopyTo(cpLogs.AppendEmpty()) @@ -61,35 +61,35 @@ func TestSplitLogs(t *testing.T) { assert.Equal(t, splitSize, split.LogRecordCount()) assert.Equal(t, cp, split) assert.Equal(t, 15, ld.LogRecordCount()) - assert.Equal(t, "test-log-int-0-0", split.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords().At(0).SeverityText()) - assert.Equal(t, "test-log-int-0-4", split.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords().At(4).SeverityText()) + assert.Equal(t, "test-log-int-0-0", split.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(0).SeverityText()) + assert.Equal(t, "test-log-int-0-4", split.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(4).SeverityText()) split = splitLogs(splitSize, ld) assert.Equal(t, 10, ld.LogRecordCount()) - assert.Equal(t, "test-log-int-0-5", split.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords().At(0).SeverityText()) - assert.Equal(t, "test-log-int-0-9", split.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords().At(4).SeverityText()) + assert.Equal(t, "test-log-int-0-5", split.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(0).SeverityText()) + assert.Equal(t, "test-log-int-0-9", split.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(4).SeverityText()) split = splitLogs(splitSize, ld) assert.Equal(t, 5, ld.LogRecordCount()) - assert.Equal(t, "test-log-int-0-10", split.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords().At(0).SeverityText()) - assert.Equal(t, "test-log-int-0-14", split.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords().At(4).SeverityText()) + assert.Equal(t, "test-log-int-0-10", split.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(0).SeverityText()) + assert.Equal(t, "test-log-int-0-14", split.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(4).SeverityText()) split = splitLogs(splitSize, ld) assert.Equal(t, 5, ld.LogRecordCount()) - assert.Equal(t, "test-log-int-0-15", split.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords().At(0).SeverityText()) - assert.Equal(t, "test-log-int-0-19", split.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords().At(4).SeverityText()) + assert.Equal(t, "test-log-int-0-15", split.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(0).SeverityText()) + assert.Equal(t, "test-log-int-0-19", split.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(4).SeverityText()) } func TestSplitLogsMultipleResourceLogs(t *testing.T) { td := testdata.GenerateLogsManyLogRecordsSameResource(20) - logs := td.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords() + logs := td.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords() for i := 0; i < logs.Len(); i++ { logs.At(i).SetSeverityText(getTestLogSeverityText(0, i)) } // add second index to resource logs testdata.GenerateLogsManyLogRecordsSameResource(20). ResourceLogs().At(0).CopyTo(td.ResourceLogs().AppendEmpty()) - logs = td.ResourceLogs().At(1).InstrumentationLibraryLogs().At(0).LogRecords() + logs = td.ResourceLogs().At(1).ScopeLogs().At(0).LogRecords() for i := 0; i < logs.Len(); i++ { logs.At(i).SetSeverityText(getTestLogSeverityText(1, i)) } @@ -98,20 +98,20 @@ func TestSplitLogsMultipleResourceLogs(t *testing.T) { split := splitLogs(splitSize, td) assert.Equal(t, splitSize, split.LogRecordCount()) assert.Equal(t, 35, td.LogRecordCount()) - assert.Equal(t, "test-log-int-0-0", split.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords().At(0).SeverityText()) - assert.Equal(t, "test-log-int-0-4", split.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords().At(4).SeverityText()) + assert.Equal(t, "test-log-int-0-0", split.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(0).SeverityText()) + assert.Equal(t, "test-log-int-0-4", split.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(4).SeverityText()) } func TestSplitLogsMultipleResourceLogs_split_size_greater_than_log_size(t *testing.T) { td := testdata.GenerateLogsManyLogRecordsSameResource(20) - logs := td.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords() + logs := td.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords() for i := 0; i < logs.Len(); i++ { logs.At(i).SetSeverityText(getTestLogSeverityText(0, i)) } // add second index to resource logs testdata.GenerateLogsManyLogRecordsSameResource(20). ResourceLogs().At(0).CopyTo(td.ResourceLogs().AppendEmpty()) - logs = td.ResourceLogs().At(1).InstrumentationLibraryLogs().At(0).LogRecords() + logs = td.ResourceLogs().At(1).ScopeLogs().At(0).LogRecords() for i := 0; i < logs.Len(); i++ { logs.At(i).SetSeverityText(getTestLogSeverityText(1, i)) } @@ -121,30 +121,30 @@ func TestSplitLogsMultipleResourceLogs_split_size_greater_than_log_size(t *testi assert.Equal(t, splitSize, split.LogRecordCount()) assert.Equal(t, 40-splitSize, td.LogRecordCount()) assert.Equal(t, 1, td.ResourceLogs().Len()) - assert.Equal(t, "test-log-int-0-0", split.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords().At(0).SeverityText()) - assert.Equal(t, "test-log-int-0-19", split.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords().At(19).SeverityText()) - assert.Equal(t, "test-log-int-1-0", split.ResourceLogs().At(1).InstrumentationLibraryLogs().At(0).LogRecords().At(0).SeverityText()) - assert.Equal(t, "test-log-int-1-4", split.ResourceLogs().At(1).InstrumentationLibraryLogs().At(0).LogRecords().At(4).SeverityText()) + assert.Equal(t, "test-log-int-0-0", split.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(0).SeverityText()) + assert.Equal(t, "test-log-int-0-19", split.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(19).SeverityText()) + assert.Equal(t, "test-log-int-1-0", split.ResourceLogs().At(1).ScopeLogs().At(0).LogRecords().At(0).SeverityText()) + assert.Equal(t, "test-log-int-1-4", split.ResourceLogs().At(1).ScopeLogs().At(0).LogRecords().At(4).SeverityText()) } func TestSplitLogsMultipleILL(t *testing.T) { td := testdata.GenerateLogsManyLogRecordsSameResource(20) - logs := td.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords() + logs := td.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords() for i := 0; i < logs.Len(); i++ { logs.At(i).SetSeverityText(getTestLogSeverityText(0, i)) } // add second index to ILL - td.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0). - CopyTo(td.ResourceLogs().At(0).InstrumentationLibraryLogs().AppendEmpty()) - logs = td.ResourceLogs().At(0).InstrumentationLibraryLogs().At(1).LogRecords() + td.ResourceLogs().At(0).ScopeLogs().At(0). + CopyTo(td.ResourceLogs().At(0).ScopeLogs().AppendEmpty()) + logs = td.ResourceLogs().At(0).ScopeLogs().At(1).LogRecords() for i := 0; i < logs.Len(); i++ { logs.At(i).SetSeverityText(getTestLogSeverityText(1, i)) } // add third index to ILL - td.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0). - CopyTo(td.ResourceLogs().At(0).InstrumentationLibraryLogs().AppendEmpty()) - logs = td.ResourceLogs().At(0).InstrumentationLibraryLogs().At(2).LogRecords() + td.ResourceLogs().At(0).ScopeLogs().At(0). + CopyTo(td.ResourceLogs().At(0).ScopeLogs().AppendEmpty()) + logs = td.ResourceLogs().At(0).ScopeLogs().At(2).LogRecords() for i := 0; i < logs.Len(); i++ { logs.At(i).SetSeverityText(getTestLogSeverityText(2, i)) } @@ -153,8 +153,8 @@ func TestSplitLogsMultipleILL(t *testing.T) { split := splitLogs(splitSize, td) assert.Equal(t, splitSize, split.LogRecordCount()) assert.Equal(t, 20, td.LogRecordCount()) - assert.Equal(t, "test-log-int-0-0", split.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords().At(0).SeverityText()) - assert.Equal(t, "test-log-int-0-4", split.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).LogRecords().At(4).SeverityText()) + assert.Equal(t, "test-log-int-0-0", split.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(0).SeverityText()) + assert.Equal(t, "test-log-int-0-4", split.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(4).SeverityText()) } func BenchmarkSplitLogs(b *testing.B) { @@ -162,7 +162,7 @@ func BenchmarkSplitLogs(b *testing.B) { rms := md.ResourceLogs() for i := 0; i < 20; i++ { testdata.GenerateLogsManyLogRecordsSameResource(20).ResourceLogs().MoveAndAppendTo(md.ResourceLogs()) - ms := rms.At(rms.Len() - 1).InstrumentationLibraryLogs().At(0).LogRecords() + ms := rms.At(rms.Len() - 1).ScopeLogs().At(0).LogRecords() for i := 0; i < ms.Len(); i++ { ms.At(i).SetSeverityText(getTestLogSeverityText(1, i)) } diff --git a/processor/batchprocessor/splitmetrics.go b/processor/batchprocessor/splitmetrics.go index bbf8d33322e..f1c188984d0 100644 --- a/processor/batchprocessor/splitmetrics.go +++ b/processor/batchprocessor/splitmetrics.go @@ -43,22 +43,22 @@ func splitMetrics(size int, src pdata.Metrics) pdata.Metrics { destRs := dest.ResourceMetrics().AppendEmpty() srcRs.Resource().CopyTo(destRs.Resource()) - srcRs.InstrumentationLibraryMetrics().RemoveIf(func(srcIlm pdata.InstrumentationLibraryMetrics) bool { + srcRs.ScopeMetrics().RemoveIf(func(srcIlm pdata.ScopeMetrics) bool { // If we are done skip everything else. if totalCopiedDataPoints == size { return false } // If possible to move all metrics do that. - srcIlmDataPointCount := instrumentationLibraryMetricsDPC(srcIlm) + srcIlmDataPointCount := scopeMetricsDPC(srcIlm) if srcIlmDataPointCount+totalCopiedDataPoints <= size { totalCopiedDataPoints += srcIlmDataPointCount - srcIlm.MoveTo(destRs.InstrumentationLibraryMetrics().AppendEmpty()) + srcIlm.MoveTo(destRs.ScopeMetrics().AppendEmpty()) return true } - destIlm := destRs.InstrumentationLibraryMetrics().AppendEmpty() - srcIlm.InstrumentationLibrary().CopyTo(destIlm.InstrumentationLibrary()) + destIlm := destRs.ScopeMetrics().AppendEmpty() + srcIlm.Scope().CopyTo(destIlm.Scope()) srcIlm.Metrics().RemoveIf(func(srcMetric pdata.Metric) bool { // If we are done skip everything else. if totalCopiedDataPoints == size { @@ -80,7 +80,7 @@ func splitMetrics(size int, src pdata.Metrics) pdata.Metrics { }) return false }) - return srcRs.InstrumentationLibraryMetrics().Len() == 0 + return srcRs.ScopeMetrics().Len() == 0 }) return dest @@ -89,15 +89,15 @@ func splitMetrics(size int, src pdata.Metrics) pdata.Metrics { // resourceMetricsDPC calculates the total number of data points in the pdata.ResourceMetrics. func resourceMetricsDPC(rs pdata.ResourceMetrics) int { dataPointCount := 0 - ilms := rs.InstrumentationLibraryMetrics() + ilms := rs.ScopeMetrics() for k := 0; k < ilms.Len(); k++ { - dataPointCount += instrumentationLibraryMetricsDPC(ilms.At(k)) + dataPointCount += scopeMetricsDPC(ilms.At(k)) } return dataPointCount } -// instrumentationLibraryMetricsDPC calculates the total number of data points in the pdata.InstrumentationLibraryMetrics. -func instrumentationLibraryMetricsDPC(ilm pdata.InstrumentationLibraryMetrics) int { +// scopeMetricsDPC calculates the total number of data points in the pdata.ScopeMetrics. +func scopeMetricsDPC(ilm pdata.ScopeMetrics) int { dataPointCount := 0 ms := ilm.Metrics() for k := 0; k < ms.Len(); k++ { diff --git a/processor/batchprocessor/splitmetrics_test.go b/processor/batchprocessor/splitmetrics_test.go index 11fffe113d8..2ba9fa2cd65 100644 --- a/processor/batchprocessor/splitmetrics_test.go +++ b/processor/batchprocessor/splitmetrics_test.go @@ -30,7 +30,7 @@ func TestSplitMetrics_noop(t *testing.T) { assert.Equal(t, td, split) i := 0 - td.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().RemoveIf(func(_ pdata.Metric) bool { + td.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().RemoveIf(func(_ pdata.Metric) bool { i++ return i > 5 }) @@ -39,17 +39,17 @@ func TestSplitMetrics_noop(t *testing.T) { func TestSplitMetrics(t *testing.T) { md := testdata.GenerateMetricsManyMetricsSameResource(20) - metrics := md.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics() + metrics := md.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics() dataPointCount := metricDPC(metrics.At(0)) for i := 0; i < metrics.Len(); i++ { metrics.At(i).SetName(getTestMetricName(0, i)) assert.Equal(t, dataPointCount, metricDPC(metrics.At(i))) } cp := pdata.NewMetrics() - cpMetrics := cp.ResourceMetrics().AppendEmpty().InstrumentationLibraryMetrics().AppendEmpty().Metrics() + cpMetrics := cp.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics() cpMetrics.EnsureCapacity(5) - md.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).InstrumentationLibrary().CopyTo( - cp.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).InstrumentationLibrary()) + md.ResourceMetrics().At(0).ScopeMetrics().At(0).Scope().CopyTo( + cp.ResourceMetrics().At(0).ScopeMetrics().At(0).Scope()) md.ResourceMetrics().At(0).Resource().CopyTo( cp.ResourceMetrics().At(0).Resource()) metrics.At(0).CopyTo(cpMetrics.AppendEmpty()) @@ -64,28 +64,28 @@ func TestSplitMetrics(t *testing.T) { assert.Equal(t, splitMetricCount, split.MetricCount()) assert.Equal(t, cp, split) assert.Equal(t, 15, md.MetricCount()) - assert.Equal(t, "test-metric-int-0-0", split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0).Name()) - assert.Equal(t, "test-metric-int-0-4", split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(4).Name()) + assert.Equal(t, "test-metric-int-0-0", split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0).Name()) + assert.Equal(t, "test-metric-int-0-4", split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(4).Name()) split = splitMetrics(splitSize, md) assert.Equal(t, 10, md.MetricCount()) - assert.Equal(t, "test-metric-int-0-5", split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0).Name()) - assert.Equal(t, "test-metric-int-0-9", split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(4).Name()) + assert.Equal(t, "test-metric-int-0-5", split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0).Name()) + assert.Equal(t, "test-metric-int-0-9", split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(4).Name()) split = splitMetrics(splitSize, md) assert.Equal(t, 5, md.MetricCount()) - assert.Equal(t, "test-metric-int-0-10", split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0).Name()) - assert.Equal(t, "test-metric-int-0-14", split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(4).Name()) + assert.Equal(t, "test-metric-int-0-10", split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0).Name()) + assert.Equal(t, "test-metric-int-0-14", split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(4).Name()) split = splitMetrics(splitSize, md) assert.Equal(t, 5, md.MetricCount()) - assert.Equal(t, "test-metric-int-0-15", split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0).Name()) - assert.Equal(t, "test-metric-int-0-19", split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(4).Name()) + assert.Equal(t, "test-metric-int-0-15", split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0).Name()) + assert.Equal(t, "test-metric-int-0-19", split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(4).Name()) } func TestSplitMetricsMultipleResourceSpans(t *testing.T) { md := testdata.GenerateMetricsManyMetricsSameResource(20) - metrics := md.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics() + metrics := md.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics() dataPointCount := metricDPC(metrics.At(0)) for i := 0; i < metrics.Len(); i++ { metrics.At(i).SetName(getTestMetricName(0, i)) @@ -94,7 +94,7 @@ func TestSplitMetricsMultipleResourceSpans(t *testing.T) { // add second index to resource metrics testdata.GenerateMetricsManyMetricsSameResource(20). ResourceMetrics().At(0).CopyTo(md.ResourceMetrics().AppendEmpty()) - metrics = md.ResourceMetrics().At(1).InstrumentationLibraryMetrics().At(0).Metrics() + metrics = md.ResourceMetrics().At(1).ScopeMetrics().At(0).Metrics() for i := 0; i < metrics.Len(); i++ { metrics.At(i).SetName(getTestMetricName(1, i)) } @@ -104,13 +104,13 @@ func TestSplitMetricsMultipleResourceSpans(t *testing.T) { split := splitMetrics(splitSize, md) assert.Equal(t, splitMetricCount, split.MetricCount()) assert.Equal(t, 35, md.MetricCount()) - assert.Equal(t, "test-metric-int-0-0", split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0).Name()) - assert.Equal(t, "test-metric-int-0-4", split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(4).Name()) + assert.Equal(t, "test-metric-int-0-0", split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0).Name()) + assert.Equal(t, "test-metric-int-0-4", split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(4).Name()) } func TestSplitMetricsMultipleResourceSpans_SplitSizeGreaterThanMetricSize(t *testing.T) { td := testdata.GenerateMetricsManyMetricsSameResource(20) - metrics := td.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics() + metrics := td.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics() dataPointCount := metricDPC(metrics.At(0)) for i := 0; i < metrics.Len(); i++ { metrics.At(i).SetName(getTestMetricName(0, i)) @@ -119,7 +119,7 @@ func TestSplitMetricsMultipleResourceSpans_SplitSizeGreaterThanMetricSize(t *tes // add second index to resource metrics testdata.GenerateMetricsManyMetricsSameResource(20). ResourceMetrics().At(0).CopyTo(td.ResourceMetrics().AppendEmpty()) - metrics = td.ResourceMetrics().At(1).InstrumentationLibraryMetrics().At(0).Metrics() + metrics = td.ResourceMetrics().At(1).ScopeMetrics().At(0).Metrics() for i := 0; i < metrics.Len(); i++ { metrics.At(i).SetName(getTestMetricName(1, i)) } @@ -130,15 +130,15 @@ func TestSplitMetricsMultipleResourceSpans_SplitSizeGreaterThanMetricSize(t *tes assert.Equal(t, splitMetricCount, split.MetricCount()) assert.Equal(t, 40-splitMetricCount, td.MetricCount()) assert.Equal(t, 1, td.ResourceMetrics().Len()) - assert.Equal(t, "test-metric-int-0-0", split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0).Name()) - assert.Equal(t, "test-metric-int-0-19", split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(19).Name()) - assert.Equal(t, "test-metric-int-1-0", split.ResourceMetrics().At(1).InstrumentationLibraryMetrics().At(0).Metrics().At(0).Name()) - assert.Equal(t, "test-metric-int-1-4", split.ResourceMetrics().At(1).InstrumentationLibraryMetrics().At(0).Metrics().At(4).Name()) + assert.Equal(t, "test-metric-int-0-0", split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0).Name()) + assert.Equal(t, "test-metric-int-0-19", split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(19).Name()) + assert.Equal(t, "test-metric-int-1-0", split.ResourceMetrics().At(1).ScopeMetrics().At(0).Metrics().At(0).Name()) + assert.Equal(t, "test-metric-int-1-4", split.ResourceMetrics().At(1).ScopeMetrics().At(0).Metrics().At(4).Name()) } func TestSplitMetricsUneven(t *testing.T) { md := testdata.GenerateMetricsManyMetricsSameResource(10) - metrics := md.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics() + metrics := md.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics() dataPointCount := 2 for i := 0; i < metrics.Len(); i++ { metrics.At(i).SetName(getTestMetricName(0, i)) @@ -149,24 +149,24 @@ func TestSplitMetricsUneven(t *testing.T) { split := splitMetrics(splitSize, md) assert.Equal(t, 5, split.MetricCount()) assert.Equal(t, 6, md.MetricCount()) - assert.Equal(t, "test-metric-int-0-0", split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0).Name()) - assert.Equal(t, "test-metric-int-0-4", split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(4).Name()) + assert.Equal(t, "test-metric-int-0-0", split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0).Name()) + assert.Equal(t, "test-metric-int-0-4", split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(4).Name()) split = splitMetrics(splitSize, md) assert.Equal(t, 5, split.MetricCount()) assert.Equal(t, 1, md.MetricCount()) - assert.Equal(t, "test-metric-int-0-4", split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0).Name()) - assert.Equal(t, "test-metric-int-0-8", split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(4).Name()) + assert.Equal(t, "test-metric-int-0-4", split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0).Name()) + assert.Equal(t, "test-metric-int-0-8", split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(4).Name()) split = splitMetrics(splitSize, md) assert.Equal(t, 1, split.MetricCount()) - assert.Equal(t, "test-metric-int-0-9", split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0).Name()) + assert.Equal(t, "test-metric-int-0-9", split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0).Name()) } func TestSplitMetricsAllTypes(t *testing.T) { md := testdata.GeneratMetricsAllTypesWithSampleDatapoints() dataPointCount := 2 - metrics := md.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics() + metrics := md.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics() for i := 0; i < metrics.Len(); i++ { metrics.At(i).SetName(getTestMetricName(0, i)) assert.Equal(t, dataPointCount, metricDPC(metrics.At(i))) @@ -180,15 +180,15 @@ func TestSplitMetricsAllTypes(t *testing.T) { split := splitMetrics(1, md) assert.Equal(t, 1, split.MetricCount()) assert.Equal(t, 7, md.MetricCount()) - gaugeInt := split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0) + gaugeInt := split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0) assert.Equal(t, 1, gaugeInt.Gauge().DataPoints().Len()) assert.Equal(t, "test-metric-int-0-0", gaugeInt.Name()) split = splitMetrics(splitSize, md) assert.Equal(t, 2, split.MetricCount()) assert.Equal(t, 6, md.MetricCount()) - gaugeInt = split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0) - gaugeDouble := split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(1) + gaugeInt = split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0) + gaugeDouble := split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(1) assert.Equal(t, 1, gaugeInt.Gauge().DataPoints().Len()) assert.Equal(t, "test-metric-int-0-0", gaugeInt.Name()) assert.Equal(t, 1, gaugeDouble.Gauge().DataPoints().Len()) @@ -197,8 +197,8 @@ func TestSplitMetricsAllTypes(t *testing.T) { split = splitMetrics(splitSize, md) assert.Equal(t, 2, split.MetricCount()) assert.Equal(t, 5, md.MetricCount()) - gaugeDouble = split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0) - sumInt := split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(1) + gaugeDouble = split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0) + sumInt := split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(1) assert.Equal(t, 1, gaugeDouble.Gauge().DataPoints().Len()) assert.Equal(t, "test-metric-int-0-1", gaugeDouble.Name()) assert.Equal(t, 1, sumInt.Sum().DataPoints().Len()) @@ -209,8 +209,8 @@ func TestSplitMetricsAllTypes(t *testing.T) { split = splitMetrics(splitSize, md) assert.Equal(t, 2, split.MetricCount()) assert.Equal(t, 4, md.MetricCount()) - sumInt = split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0) - sumDouble := split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(1) + sumInt = split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0) + sumDouble := split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(1) assert.Equal(t, 1, sumInt.Sum().DataPoints().Len()) assert.Equal(t, pdata.MetricAggregationTemporalityCumulative, sumInt.Sum().AggregationTemporality()) assert.Equal(t, true, sumInt.Sum().IsMonotonic()) @@ -223,8 +223,8 @@ func TestSplitMetricsAllTypes(t *testing.T) { split = splitMetrics(splitSize, md) assert.Equal(t, 2, split.MetricCount()) assert.Equal(t, 3, md.MetricCount()) - sumDouble = split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0) - histogram := split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(1) + sumDouble = split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0) + histogram := split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(1) assert.Equal(t, 1, sumDouble.Sum().DataPoints().Len()) assert.Equal(t, pdata.MetricAggregationTemporalityCumulative, sumDouble.Sum().AggregationTemporality()) assert.Equal(t, true, sumDouble.Sum().IsMonotonic()) @@ -236,8 +236,8 @@ func TestSplitMetricsAllTypes(t *testing.T) { split = splitMetrics(splitSize, md) assert.Equal(t, 2, split.MetricCount()) assert.Equal(t, 2, md.MetricCount()) - histogram = split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0) - exponentialHistogram := split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(1) + histogram = split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0) + exponentialHistogram := split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(1) assert.Equal(t, 1, histogram.Histogram().DataPoints().Len()) assert.Equal(t, pdata.MetricAggregationTemporalityCumulative, histogram.Histogram().AggregationTemporality()) assert.Equal(t, "test-metric-int-0-4", histogram.Name()) @@ -248,8 +248,8 @@ func TestSplitMetricsAllTypes(t *testing.T) { split = splitMetrics(splitSize, md) assert.Equal(t, 2, split.MetricCount()) assert.Equal(t, 1, md.MetricCount()) - exponentialHistogram = split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0) - summary := split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(1) + exponentialHistogram = split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0) + summary := split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(1) assert.Equal(t, 1, exponentialHistogram.ExponentialHistogram().DataPoints().Len()) assert.Equal(t, pdata.MetricAggregationTemporalityDelta, exponentialHistogram.ExponentialHistogram().AggregationTemporality()) assert.Equal(t, "test-metric-int-0-5", exponentialHistogram.Name()) @@ -257,14 +257,14 @@ func TestSplitMetricsAllTypes(t *testing.T) { assert.Equal(t, "test-metric-int-0-6", summary.Name()) split = splitMetrics(splitSize, md) - summary = split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0) + summary = split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0) assert.Equal(t, 1, summary.Summary().DataPoints().Len()) assert.Equal(t, "test-metric-int-0-6", summary.Name()) } func TestSplitMetricsBatchSizeSmallerThanDataPointCount(t *testing.T) { md := testdata.GenerateMetricsManyMetricsSameResource(2) - metrics := md.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics() + metrics := md.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics() dataPointCount := 2 for i := 0; i < metrics.Len(); i++ { metrics.At(i).SetName(getTestMetricName(0, i)) @@ -273,7 +273,7 @@ func TestSplitMetricsBatchSizeSmallerThanDataPointCount(t *testing.T) { splitSize := 1 split := splitMetrics(splitSize, md) - splitMetric := split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0) + splitMetric := split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0) assert.Equal(t, 1, split.MetricCount()) assert.Equal(t, 2, md.MetricCount()) assert.Equal(t, pdata.MetricAggregationTemporalityCumulative, splitMetric.Sum().AggregationTemporality()) @@ -281,7 +281,7 @@ func TestSplitMetricsBatchSizeSmallerThanDataPointCount(t *testing.T) { assert.Equal(t, "test-metric-int-0-0", splitMetric.Name()) split = splitMetrics(splitSize, md) - splitMetric = split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0) + splitMetric = split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0) assert.Equal(t, 1, split.MetricCount()) assert.Equal(t, 1, md.MetricCount()) assert.Equal(t, pdata.MetricAggregationTemporalityCumulative, splitMetric.Sum().AggregationTemporality()) @@ -289,7 +289,7 @@ func TestSplitMetricsBatchSizeSmallerThanDataPointCount(t *testing.T) { assert.Equal(t, "test-metric-int-0-0", splitMetric.Name()) split = splitMetrics(splitSize, md) - splitMetric = split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0) + splitMetric = split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0) assert.Equal(t, 1, split.MetricCount()) assert.Equal(t, 1, md.MetricCount()) assert.Equal(t, pdata.MetricAggregationTemporalityCumulative, splitMetric.Sum().AggregationTemporality()) @@ -297,7 +297,7 @@ func TestSplitMetricsBatchSizeSmallerThanDataPointCount(t *testing.T) { assert.Equal(t, "test-metric-int-0-1", splitMetric.Name()) split = splitMetrics(splitSize, md) - splitMetric = split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0) + splitMetric = split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0) assert.Equal(t, 1, split.MetricCount()) assert.Equal(t, 1, md.MetricCount()) assert.Equal(t, pdata.MetricAggregationTemporalityCumulative, splitMetric.Sum().AggregationTemporality()) @@ -307,20 +307,20 @@ func TestSplitMetricsBatchSizeSmallerThanDataPointCount(t *testing.T) { func TestSplitMetricsMultipleILM(t *testing.T) { md := testdata.GenerateMetricsManyMetricsSameResource(20) - metrics := md.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics() + metrics := md.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics() dataPointCount := metricDPC(metrics.At(0)) for i := 0; i < metrics.Len(); i++ { metrics.At(i).SetName(getTestMetricName(0, i)) assert.Equal(t, dataPointCount, metricDPC(metrics.At(i))) } // add second index to ilm - md.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0). - CopyTo(md.ResourceMetrics().At(0).InstrumentationLibraryMetrics().AppendEmpty()) + md.ResourceMetrics().At(0).ScopeMetrics().At(0). + CopyTo(md.ResourceMetrics().At(0).ScopeMetrics().AppendEmpty()) // add a third index to ilm - md.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0). - CopyTo(md.ResourceMetrics().At(0).InstrumentationLibraryMetrics().AppendEmpty()) - metrics = md.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(2).Metrics() + md.ResourceMetrics().At(0).ScopeMetrics().At(0). + CopyTo(md.ResourceMetrics().At(0).ScopeMetrics().AppendEmpty()) + metrics = md.ResourceMetrics().At(0).ScopeMetrics().At(2).Metrics() for i := 0; i < metrics.Len(); i++ { metrics.At(i).SetName(getTestMetricName(2, i)) } @@ -330,8 +330,8 @@ func TestSplitMetricsMultipleILM(t *testing.T) { split := splitMetrics(splitSize, md) assert.Equal(t, splitMetricCount, split.MetricCount()) assert.Equal(t, 20, md.MetricCount()) - assert.Equal(t, "test-metric-int-0-0", split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0).Name()) - assert.Equal(t, "test-metric-int-0-4", split.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(4).Name()) + assert.Equal(t, "test-metric-int-0-0", split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0).Name()) + assert.Equal(t, "test-metric-int-0-4", split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(4).Name()) } func BenchmarkSplitMetrics(b *testing.B) { @@ -339,7 +339,7 @@ func BenchmarkSplitMetrics(b *testing.B) { rms := md.ResourceMetrics() for i := 0; i < 20; i++ { testdata.GenerateMetricsManyMetricsSameResource(20).ResourceMetrics().MoveAndAppendTo(md.ResourceMetrics()) - ms := rms.At(rms.Len() - 1).InstrumentationLibraryMetrics().At(0).Metrics() + ms := rms.At(rms.Len() - 1).ScopeMetrics().At(0).Metrics() for i := 0; i < ms.Len(); i++ { ms.At(i).SetName(getTestMetricName(1, i)) } @@ -349,7 +349,7 @@ func BenchmarkSplitMetrics(b *testing.B) { b.Skipf("SKIP: b.N too high, set -benchtime=x with n < 100000") } - dataPointCount := metricDPC(md.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0)) + dataPointCount := metricDPC(md.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0)) clones := make([]pdata.Metrics, b.N) for n := 0; n < b.N; n++ { clones[n] = md.Clone() diff --git a/processor/batchprocessor/splittraces.go b/processor/batchprocessor/splittraces.go index b3b8bbf5ccf..e8fbf779b7b 100644 --- a/processor/batchprocessor/splittraces.go +++ b/processor/batchprocessor/splittraces.go @@ -42,7 +42,7 @@ func splitTraces(size int, src pdata.Traces) pdata.Traces { destRs := dest.ResourceSpans().AppendEmpty() srcRs.Resource().CopyTo(destRs.Resource()) - srcRs.InstrumentationLibrarySpans().RemoveIf(func(srcIls pdata.InstrumentationLibrarySpans) bool { + srcRs.ScopeSpans().RemoveIf(func(srcIls pdata.ScopeSpans) bool { // If we are done skip everything else. if totalCopiedSpans == size { return false @@ -52,12 +52,12 @@ func splitTraces(size int, src pdata.Traces) pdata.Traces { srcIlsSC := srcIls.Spans().Len() if size-totalCopiedSpans >= srcIlsSC { totalCopiedSpans += srcIlsSC - srcIls.MoveTo(destRs.InstrumentationLibrarySpans().AppendEmpty()) + srcIls.MoveTo(destRs.ScopeSpans().AppendEmpty()) return true } - destIls := destRs.InstrumentationLibrarySpans().AppendEmpty() - srcIls.InstrumentationLibrary().CopyTo(destIls.InstrumentationLibrary()) + destIls := destRs.ScopeSpans().AppendEmpty() + srcIls.Scope().CopyTo(destIls.Scope()) srcIls.Spans().RemoveIf(func(srcSpan pdata.Span) bool { // If we are done skip everything else. if totalCopiedSpans == size { @@ -69,7 +69,7 @@ func splitTraces(size int, src pdata.Traces) pdata.Traces { }) return false }) - return srcRs.InstrumentationLibrarySpans().Len() == 0 + return srcRs.ScopeSpans().Len() == 0 }) return dest @@ -77,8 +77,8 @@ func splitTraces(size int, src pdata.Traces) pdata.Traces { // resourceSC calculates the total number of spans in the pdata.ResourceSpans. func resourceSC(rs pdata.ResourceSpans) (count int) { - for k := 0; k < rs.InstrumentationLibrarySpans().Len(); k++ { - count += rs.InstrumentationLibrarySpans().At(k).Spans().Len() + for k := 0; k < rs.ScopeSpans().Len(); k++ { + count += rs.ScopeSpans().At(k).Spans().Len() } return } diff --git a/processor/batchprocessor/splittraces_test.go b/processor/batchprocessor/splittraces_test.go index df4c8b7e039..863054ad544 100644 --- a/processor/batchprocessor/splittraces_test.go +++ b/processor/batchprocessor/splittraces_test.go @@ -30,7 +30,7 @@ func TestSplitTraces_noop(t *testing.T) { assert.Equal(t, td, split) i := 0 - td.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans().RemoveIf(func(_ pdata.Span) bool { + td.ResourceSpans().At(0).ScopeSpans().At(0).Spans().RemoveIf(func(_ pdata.Span) bool { i++ return i > 5 }) @@ -39,17 +39,17 @@ func TestSplitTraces_noop(t *testing.T) { func TestSplitTraces(t *testing.T) { td := testdata.GenerateTracesManySpansSameResource(20) - spans := td.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans() + spans := td.ResourceSpans().At(0).ScopeSpans().At(0).Spans() for i := 0; i < spans.Len(); i++ { spans.At(i).SetName(getTestSpanName(0, i)) } cp := pdata.NewTraces() - cpSpans := cp.ResourceSpans().AppendEmpty().InstrumentationLibrarySpans().AppendEmpty().Spans() + cpSpans := cp.ResourceSpans().AppendEmpty().ScopeSpans().AppendEmpty().Spans() cpSpans.EnsureCapacity(5) td.ResourceSpans().At(0).Resource().CopyTo( cp.ResourceSpans().At(0).Resource()) - td.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).InstrumentationLibrary().CopyTo( - cp.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).InstrumentationLibrary()) + td.ResourceSpans().At(0).ScopeSpans().At(0).Scope().CopyTo( + cp.ResourceSpans().At(0).ScopeSpans().At(0).Scope()) spans.At(0).CopyTo(cpSpans.AppendEmpty()) spans.At(1).CopyTo(cpSpans.AppendEmpty()) spans.At(2).CopyTo(cpSpans.AppendEmpty()) @@ -61,35 +61,35 @@ func TestSplitTraces(t *testing.T) { assert.Equal(t, splitSize, split.SpanCount()) assert.Equal(t, cp, split) assert.Equal(t, 15, td.SpanCount()) - assert.Equal(t, "test-span-0-0", split.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans().At(0).Name()) - assert.Equal(t, "test-span-0-4", split.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans().At(4).Name()) + assert.Equal(t, "test-span-0-0", split.ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(0).Name()) + assert.Equal(t, "test-span-0-4", split.ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(4).Name()) split = splitTraces(splitSize, td) assert.Equal(t, 10, td.SpanCount()) - assert.Equal(t, "test-span-0-5", split.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans().At(0).Name()) - assert.Equal(t, "test-span-0-9", split.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans().At(4).Name()) + assert.Equal(t, "test-span-0-5", split.ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(0).Name()) + assert.Equal(t, "test-span-0-9", split.ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(4).Name()) split = splitTraces(splitSize, td) assert.Equal(t, 5, td.SpanCount()) - assert.Equal(t, "test-span-0-10", split.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans().At(0).Name()) - assert.Equal(t, "test-span-0-14", split.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans().At(4).Name()) + assert.Equal(t, "test-span-0-10", split.ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(0).Name()) + assert.Equal(t, "test-span-0-14", split.ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(4).Name()) split = splitTraces(splitSize, td) assert.Equal(t, 5, td.SpanCount()) - assert.Equal(t, "test-span-0-15", split.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans().At(0).Name()) - assert.Equal(t, "test-span-0-19", split.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans().At(4).Name()) + assert.Equal(t, "test-span-0-15", split.ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(0).Name()) + assert.Equal(t, "test-span-0-19", split.ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(4).Name()) } func TestSplitTracesMultipleResourceSpans(t *testing.T) { td := testdata.GenerateTracesManySpansSameResource(20) - spans := td.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans() + spans := td.ResourceSpans().At(0).ScopeSpans().At(0).Spans() for i := 0; i < spans.Len(); i++ { spans.At(i).SetName(getTestSpanName(0, i)) } // add second index to resource spans testdata.GenerateTracesManySpansSameResource(20). ResourceSpans().At(0).CopyTo(td.ResourceSpans().AppendEmpty()) - spans = td.ResourceSpans().At(1).InstrumentationLibrarySpans().At(0).Spans() + spans = td.ResourceSpans().At(1).ScopeSpans().At(0).Spans() for i := 0; i < spans.Len(); i++ { spans.At(i).SetName(getTestSpanName(1, i)) } @@ -98,20 +98,20 @@ func TestSplitTracesMultipleResourceSpans(t *testing.T) { split := splitTraces(splitSize, td) assert.Equal(t, splitSize, split.SpanCount()) assert.Equal(t, 35, td.SpanCount()) - assert.Equal(t, "test-span-0-0", split.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans().At(0).Name()) - assert.Equal(t, "test-span-0-4", split.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans().At(4).Name()) + assert.Equal(t, "test-span-0-0", split.ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(0).Name()) + assert.Equal(t, "test-span-0-4", split.ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(4).Name()) } func TestSplitTracesMultipleResourceSpans_SplitSizeGreaterThanSpanSize(t *testing.T) { td := testdata.GenerateTracesManySpansSameResource(20) - spans := td.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans() + spans := td.ResourceSpans().At(0).ScopeSpans().At(0).Spans() for i := 0; i < spans.Len(); i++ { spans.At(i).SetName(getTestSpanName(0, i)) } // add second index to resource spans testdata.GenerateTracesManySpansSameResource(20). ResourceSpans().At(0).CopyTo(td.ResourceSpans().AppendEmpty()) - spans = td.ResourceSpans().At(1).InstrumentationLibrarySpans().At(0).Spans() + spans = td.ResourceSpans().At(1).ScopeSpans().At(0).Spans() for i := 0; i < spans.Len(); i++ { spans.At(i).SetName(getTestSpanName(1, i)) } @@ -121,10 +121,10 @@ func TestSplitTracesMultipleResourceSpans_SplitSizeGreaterThanSpanSize(t *testin assert.Equal(t, splitSize, split.SpanCount()) assert.Equal(t, 40-splitSize, td.SpanCount()) assert.Equal(t, 1, td.ResourceSpans().Len()) - assert.Equal(t, "test-span-0-0", split.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans().At(0).Name()) - assert.Equal(t, "test-span-0-19", split.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans().At(19).Name()) - assert.Equal(t, "test-span-1-0", split.ResourceSpans().At(1).InstrumentationLibrarySpans().At(0).Spans().At(0).Name()) - assert.Equal(t, "test-span-1-4", split.ResourceSpans().At(1).InstrumentationLibrarySpans().At(0).Spans().At(4).Name()) + assert.Equal(t, "test-span-0-0", split.ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(0).Name()) + assert.Equal(t, "test-span-0-19", split.ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(19).Name()) + assert.Equal(t, "test-span-1-0", split.ResourceSpans().At(1).ScopeSpans().At(0).Spans().At(0).Name()) + assert.Equal(t, "test-span-1-4", split.ResourceSpans().At(1).ScopeSpans().At(0).Spans().At(4).Name()) } func BenchmarkCloneSpans(b *testing.B) { @@ -132,7 +132,7 @@ func BenchmarkCloneSpans(b *testing.B) { rms := td.ResourceSpans() for i := 0; i < 20; i++ { testdata.GenerateTracesManySpansSameResource(20).ResourceSpans().MoveAndAppendTo(td.ResourceSpans()) - ms := rms.At(rms.Len() - 1).InstrumentationLibrarySpans().At(0).Spans() + ms := rms.At(rms.Len() - 1).ScopeSpans().At(0).Spans() for i := 0; i < ms.Len(); i++ { ms.At(i).SetName(getTestMetricName(1, i)) } @@ -150,22 +150,22 @@ func BenchmarkCloneSpans(b *testing.B) { func TestSplitTracesMultipleILS(t *testing.T) { td := testdata.GenerateTracesManySpansSameResource(20) - spans := td.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans() + spans := td.ResourceSpans().At(0).ScopeSpans().At(0).Spans() for i := 0; i < spans.Len(); i++ { spans.At(i).SetName(getTestSpanName(0, i)) } // add second index to ILS - td.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0). - CopyTo(td.ResourceSpans().At(0).InstrumentationLibrarySpans().AppendEmpty()) - spans = td.ResourceSpans().At(0).InstrumentationLibrarySpans().At(1).Spans() + td.ResourceSpans().At(0).ScopeSpans().At(0). + CopyTo(td.ResourceSpans().At(0).ScopeSpans().AppendEmpty()) + spans = td.ResourceSpans().At(0).ScopeSpans().At(1).Spans() for i := 0; i < spans.Len(); i++ { spans.At(i).SetName(getTestSpanName(1, i)) } // add third index to ILS - td.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0). - CopyTo(td.ResourceSpans().At(0).InstrumentationLibrarySpans().AppendEmpty()) - spans = td.ResourceSpans().At(0).InstrumentationLibrarySpans().At(2).Spans() + td.ResourceSpans().At(0).ScopeSpans().At(0). + CopyTo(td.ResourceSpans().At(0).ScopeSpans().AppendEmpty()) + spans = td.ResourceSpans().At(0).ScopeSpans().At(2).Spans() for i := 0; i < spans.Len(); i++ { spans.At(i).SetName(getTestSpanName(2, i)) } @@ -174,8 +174,8 @@ func TestSplitTracesMultipleILS(t *testing.T) { split := splitTraces(splitSize, td) assert.Equal(t, splitSize, split.SpanCount()) assert.Equal(t, 20, td.SpanCount()) - assert.Equal(t, "test-span-0-0", split.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans().At(0).Name()) - assert.Equal(t, "test-span-0-4", split.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans().At(4).Name()) + assert.Equal(t, "test-span-0-0", split.ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(0).Name()) + assert.Equal(t, "test-span-0-4", split.ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(4).Name()) } func BenchmarkSplitTraces(b *testing.B) { @@ -183,7 +183,7 @@ func BenchmarkSplitTraces(b *testing.B) { rms := td.ResourceSpans() for i := 0; i < 20; i++ { testdata.GenerateTracesManySpansSameResource(20).ResourceSpans().MoveAndAppendTo(td.ResourceSpans()) - ms := rms.At(rms.Len() - 1).InstrumentationLibrarySpans().At(0).Spans() + ms := rms.At(rms.Len() - 1).ScopeSpans().At(0).Spans() for i := 0; i < ms.Len(); i++ { ms.At(i).SetName(getTestMetricName(1, i)) } diff --git a/receiver/otlpreceiver/otlp_test.go b/receiver/otlpreceiver/otlp_test.go index 30a23eb0b50..9a45e47d9fc 100644 --- a/receiver/otlpreceiver/otlp_test.go +++ b/receiver/otlpreceiver/otlp_test.go @@ -112,7 +112,7 @@ var traceOtlp = func() pdata.Traces { td := pdata.NewTraces() rs := td.ResourceSpans().AppendEmpty() rs.Resource().Attributes().UpsertString(semconv.AttributeHostName, "testHost") - spans := rs.InstrumentationLibrarySpans().AppendEmpty().Spans() + spans := rs.ScopeSpans().AppendEmpty().Spans() span1 := spans.AppendEmpty() span1.SetTraceID(pdata.NewTraceID([16]byte{0x5B, 0x8E, 0xFF, 0xF7, 0x98, 0x3, 0x81, 0x3, 0xD2, 0x69, 0xB6, 0x33, 0x81, 0x3F, 0xC6, 0xC})) span1.SetSpanID(pdata.NewSpanID([8]byte{0xEE, 0xE1, 0x9B, 0x7E, 0xC3, 0xC1, 0xB1, 0x74})) diff --git a/receiver/scraperhelper/scrapercontroller_test.go b/receiver/scraperhelper/scrapercontroller_test.go index c1556b908b2..0adff240e60 100644 --- a/receiver/scraperhelper/scrapercontroller_test.go +++ b/receiver/scraperhelper/scrapercontroller_test.go @@ -71,7 +71,7 @@ func (ts *testScrapeMetrics) scrape(_ context.Context) (pdata.Metrics, error) { } md := pdata.NewMetrics() - metric := md.ResourceMetrics().AppendEmpty().InstrumentationLibraryMetrics().AppendEmpty().Metrics().AppendEmpty() + metric := md.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics().AppendEmpty() metric.SetDataType(pdata.MetricDataTypeGauge) metric.Gauge().DataPoints().AppendEmpty() return md, nil