Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

clean up instrumentationLibrary* rename #9068

Merged
merged 1 commit into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions exporter/azuremonitorexporter/logexporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ func (exporter *logExporter) onLogData(context context.Context, logData pdata.Lo
logPacker := newLogPacker(exporter.logger)

for i := 0; i < resourceLogs.Len(); i++ {
instrumentationLibraryLogs := resourceLogs.At(i).ScopeLogs()
for j := 0; j < instrumentationLibraryLogs.Len(); j++ {
logs := instrumentationLibraryLogs.At(j).LogRecords()
scopeLogs := resourceLogs.At(i).ScopeLogs()
for j := 0; j < scopeLogs.Len(); j++ {
logs := scopeLogs.At(j).LogRecords()
for k := 0; k < logs.Len(); k++ {
envelope := logPacker.LogRecordToEnvelope(logs.At(k))
envelope.IKey = exporter.config.InstrumentationKey
Expand Down
4 changes: 2 additions & 2 deletions exporter/azuremonitorexporter/logexporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ func getTestLogRecord(tb testing.TB) pdata.LogRecord {
var logRecord pdata.LogRecord
logs := getTestLogs(tb)
resourceLogs := logs.ResourceLogs()
instrumentationLibraryLogs := resourceLogs.At(0).ScopeLogs()
logRecords := instrumentationLibraryLogs.At(0).LogRecords()
scopeLogs := resourceLogs.At(0).ScopeLogs()
logRecords := scopeLogs.At(0).LogRecords()
logRecord = logRecords.At(0)

return logRecord
Expand Down
12 changes: 6 additions & 6 deletions exporter/azuremonitorexporter/traceiteration.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ func Accept(traces pdata.Traces, v TraceVisitor) {
for i := 0; i < resourceSpans.Len(); i++ {
rs := resourceSpans.At(i)
resource := rs.Resource()
instrumentationLibrarySpansSlice := rs.ScopeSpans()
scopeSpansSlice := rs.ScopeSpans()

for j := 0; j < instrumentationLibrarySpansSlice.Len(); j++ {
instrumentationLibrarySpans := instrumentationLibrarySpansSlice.At(j)
for j := 0; j < scopeSpansSlice.Len(); j++ {
scopeSpans := scopeSpansSlice.At(j)
// instrumentation library is optional
instrumentationLibrary := instrumentationLibrarySpans.Scope()
spansSlice := instrumentationLibrarySpans.Spans()
scope := scopeSpans.Scope()
spansSlice := scopeSpans.Spans()
if spansSlice.Len() == 0 {
continue
}

for k := 0; k < spansSlice.Len(); k++ {
if ok := v.visit(resource, instrumentationLibrary, spansSlice.At(k)); !ok {
if ok := v.visit(resource, scope, spansSlice.At(k)); !ok {
return
}
}
Expand Down
24 changes: 12 additions & 12 deletions exporter/elasticexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,16 @@ func (e *elasticExporter) ExportResourceSpans(ctx context.Context, rs pdata.Reso
elastic.EncodeResourceMetadata(rs.Resource(), &w)
var errs []error
var count int
instrumentationLibrarySpansSlice := rs.ScopeSpans()
for i := 0; i < instrumentationLibrarySpansSlice.Len(); i++ {
instrumentationLibrarySpans := instrumentationLibrarySpansSlice.At(i)
instrumentationLibrary := instrumentationLibrarySpans.Scope()
spanSlice := instrumentationLibrarySpans.Spans()
scopeSpansSlice := rs.ScopeSpans()
for i := 0; i < scopeSpansSlice.Len(); i++ {
scopeSpans := scopeSpansSlice.At(i)
scope := scopeSpans.Scope()
spanSlice := scopeSpans.Spans()
for i := 0; i < spanSlice.Len(); i++ {
count++
span := spanSlice.At(i)
before := w.Size()
if err := elastic.EncodeSpan(span, instrumentationLibrary, rs.Resource(), &w); err != nil {
if err := elastic.EncodeSpan(span, scope, rs.Resource(), &w); err != nil {
w.Rewind(before)
errs = append(errs, err)
}
Expand All @@ -155,13 +155,13 @@ func (e *elasticExporter) ExportResourceMetrics(ctx context.Context, rm pdata.Re
elastic.EncodeResourceMetadata(rm.Resource(), &w)
var errs error
var totalDropped int
instrumentationLibraryMetricsSlice := rm.ScopeMetrics()
for i := 0; i < instrumentationLibraryMetricsSlice.Len(); i++ {
instrumentationLibraryMetrics := instrumentationLibraryMetricsSlice.At(i)
instrumentationLibrary := instrumentationLibraryMetrics.Scope()
metrics := instrumentationLibraryMetrics.Metrics()
scopeMetricsSlice := rm.ScopeMetrics()
for i := 0; i < scopeMetricsSlice.Len(); i++ {
scopeMetrics := scopeMetricsSlice.At(i)
scope := scopeMetrics.Scope()
metrics := scopeMetrics.Metrics()
before := w.Size()
dropped, err := elastic.EncodeMetrics(metrics, instrumentationLibrary, &w)
dropped, err := elastic.EncodeMetrics(metrics, scope, &w)
if err != nil {
w.Rewind(before)
errs = multierr.Append(errs, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func TestEncodeMetrics(t *testing.T) {
var recorder transporttest.RecorderTransport
elastic.EncodeResourceMetadata(pdata.NewResource(), &w)

instrumentationLibraryMetrics := pdata.NewScopeMetrics()
metrics := instrumentationLibraryMetrics.Metrics()
scopeMetrics := pdata.NewScopeMetrics()
metrics := scopeMetrics.Metrics()
appendMetric := func(name string, dataType pdata.MetricDataType) pdata.Metric {
metric := metrics.AppendEmpty()
metric.SetName(name)
Expand Down Expand Up @@ -118,7 +118,7 @@ func TestEncodeMetrics(t *testing.T) {
metric.Histogram().DataPoints().AppendEmpty()
expectDropped++

dropped, err := elastic.EncodeMetrics(metrics, instrumentationLibraryMetrics.Scope(), &w)
dropped, err := elastic.EncodeMetrics(metrics, scopeMetrics.Scope(), &w)
require.NoError(t, err)
assert.Equal(t, expectDropped, dropped)
sendStream(t, &w, &recorder)
Expand Down
16 changes: 8 additions & 8 deletions internal/coreinternal/goldendataset/traces_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func appendResourceSpan(tracingInputs *PICTTracingInputs, spanPairsFile string,
}

func appendScopeSpans(tracingInputs *PICTTracingInputs, spanPairsFile string,
random io.Reader, instrumentationLibrarySpansSlice pdata.ScopeSpansSlice) error {
random io.Reader, scopeSpansSlice pdata.ScopeSpansSlice) error {
var count int
switch tracingInputs.InstrumentationLibrary {
case LibraryNone:
Expand All @@ -81,31 +81,31 @@ func appendScopeSpans(tracingInputs *PICTTracingInputs, spanPairsFile string,
count = 2
}
for i := 0; i < count; i++ {
err := fillScopeSpans(tracingInputs, i, spanPairsFile, random, instrumentationLibrarySpansSlice.AppendEmpty())
err := fillScopeSpans(tracingInputs, i, spanPairsFile, random, scopeSpansSlice.AppendEmpty())
if err != nil {
return err
}
}
return nil
}

func fillScopeSpans(tracingInputs *PICTTracingInputs, index int, spanPairsFile string, random io.Reader, instrumentationLibrarySpans pdata.ScopeSpans) error {
func fillScopeSpans(tracingInputs *PICTTracingInputs, index int, spanPairsFile string, random io.Reader, scopeSpans pdata.ScopeSpans) error {
spanCaseCount, err := countTotalSpanCases(spanPairsFile)
if err != nil {
return err
}
fillInstrumentationLibrary(tracingInputs, index, instrumentationLibrarySpans.Scope())
fillInstrumentationLibrary(tracingInputs, index, scopeSpans.Scope())
switch tracingInputs.Spans {
case LibrarySpansNone:
return nil
case LibrarySpansOne:
return appendSpans(1, spanPairsFile, random, instrumentationLibrarySpans.Spans())
return appendSpans(1, spanPairsFile, random, scopeSpans.Spans())
case LibrarySpansSeveral:
return appendSpans(spanCaseCount/4, spanPairsFile, random, instrumentationLibrarySpans.Spans())
return appendSpans(spanCaseCount/4, spanPairsFile, random, scopeSpans.Spans())
case LibrarySpansAll:
return appendSpans(spanCaseCount, spanPairsFile, random, instrumentationLibrarySpans.Spans())
return appendSpans(spanCaseCount, spanPairsFile, random, scopeSpans.Spans())
default:
return appendSpans(16, spanPairsFile, random, instrumentationLibrarySpans.Spans())
return appendSpans(16, spanPairsFile, random, scopeSpans.Spans())
}
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/translator/prometheusremotewrite/metrics_to_prw.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ func FromMetrics(md pdata.Metrics, settings Settings) (tsMap map[string]*prompb.
for i := 0; i < resourceMetricsSlice.Len(); i++ {
resourceMetrics := resourceMetricsSlice.At(i)
resource := resourceMetrics.Resource()
instrumentationLibraryMetricsSlice := resourceMetrics.ScopeMetrics()
scopeMetricsSlice := resourceMetrics.ScopeMetrics()
// TODO: add resource attributes as labels, probably in next PR
for j := 0; j < instrumentationLibraryMetricsSlice.Len(); j++ {
instrumentationLibraryMetrics := instrumentationLibraryMetricsSlice.At(j)
metricSlice := instrumentationLibraryMetrics.Metrics()
for j := 0; j < scopeMetricsSlice.Len(); j++ {
scopeMetrics := scopeMetricsSlice.At(j)
metricSlice := scopeMetrics.Metrics()

// TODO: decide if instrumentation library information should be exported as labels
for k := 0; k < metricSlice.Len(); k++ {
Expand Down
14 changes: 7 additions & 7 deletions processor/groupbyattrsprocessor/attribute_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func instrumentationLibrariesEqual(il1, il2 pdata.InstrumentationScope) bool {
}

// matchingScopeSpans searches for a pdata.ScopeSpans instance matching
// given InstrumentationLibrary. If nothing is found, it creates a new one
// given InstrumentationScope. If nothing is found, it creates a new one
func matchingScopeSpans(rl pdata.ResourceSpans, library pdata.InstrumentationScope) pdata.ScopeSpans {
ilss := rl.ScopeSpans()
for i := 0; i < ilss.Len(); i++ {
Expand All @@ -38,9 +38,9 @@ func matchingScopeSpans(rl pdata.ResourceSpans, library pdata.InstrumentationSco
return ils
}

// matchingInstrumentationLibraryLogs searches for a pdata.ScopeLogs instance matching
// given InstrumentationLibrary. If nothing is found, it creates a new one
func matchingInstrumentationLibraryLogs(rl pdata.ResourceLogs, library pdata.InstrumentationScope) pdata.ScopeLogs {
// matchingScopeLogs searches for a pdata.ScopeLogs instance matching
// given InstrumentationScope. If nothing is found, it creates a new one
func matchingScopeLogs(rl pdata.ResourceLogs, library pdata.InstrumentationScope) pdata.ScopeLogs {
ills := rl.ScopeLogs()
for i := 0; i < ills.Len(); i++ {
sl := ills.At(i)
Expand All @@ -54,9 +54,9 @@ func matchingInstrumentationLibraryLogs(rl pdata.ResourceLogs, library pdata.Ins
return sl
}

// matchingInstrumentationLibraryMetrics searches for a pdata.ScopeMetrics instance matching
// given InstrumentationLibrary. If nothing is found, it creates a new one
func matchingInstrumentationLibraryMetrics(rm pdata.ResourceMetrics, library pdata.InstrumentationScope) pdata.ScopeMetrics {
// matchingScopeMetrics searches for a pdata.ScopeMetrics instance matching
// given InstrumentationScope. If nothing is found, it creates a new one
func matchingScopeMetrics(rm pdata.ResourceMetrics, library pdata.InstrumentationScope) pdata.ScopeMetrics {
ilms := rm.ScopeMetrics()
for i := 0; i < ilms.Len(); i++ {
ilm := ilms.At(i)
Expand Down
12 changes: 6 additions & 6 deletions processor/groupbyattrsprocessor/attribute_groups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,23 +132,23 @@ func TestInstrumentationLibraryMatching(t *testing.T) {
il2 := pdata.NewInstrumentationScope()
il2.SetName("Name2")

ill1 := matchingInstrumentationLibraryLogs(rl, il1)
ill1 := matchingScopeLogs(rl, il1)
ils1 := matchingScopeSpans(rs, il1)
ilm1 := matchingInstrumentationLibraryMetrics(rm, il1)
ilm1 := matchingScopeMetrics(rm, il1)
assert.EqualValues(t, il1, ill1.Scope())
assert.EqualValues(t, il1, ils1.Scope())
assert.EqualValues(t, il1, ilm1.Scope())

ill2 := matchingInstrumentationLibraryLogs(rl, il2)
ill2 := matchingScopeLogs(rl, il2)
ils2 := matchingScopeSpans(rs, il2)
ilm2 := matchingInstrumentationLibraryMetrics(rm, il2)
ilm2 := matchingScopeMetrics(rm, il2)
assert.EqualValues(t, il2, ill2.Scope())
assert.EqualValues(t, il2, ils2.Scope())
assert.EqualValues(t, il2, ilm2.Scope())

ill1 = matchingInstrumentationLibraryLogs(rl, il1)
ill1 = matchingScopeLogs(rl, il1)
ils1 = matchingScopeSpans(rs, il1)
ilm1 = matchingInstrumentationLibraryMetrics(rm, il1)
ilm1 = matchingScopeMetrics(rm, il1)
assert.EqualValues(t, il1, ill1.Scope())
assert.EqualValues(t, il1, ils1.Scope())
assert.EqualValues(t, il1, ilm1.Scope())
Expand Down
4 changes: 2 additions & 2 deletions processor/groupbyattrsprocessor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (gap *groupByAttrsProcessor) processLogs(ctx context.Context, ld pdata.Logs
// Lets combine the base resource attributes + the extracted (grouped) attributes
// and keep them in the grouping entry
groupedLogs := groupedResourceLogs.findResourceOrElseCreate(ls.Resource(), requiredAttributes)
lr := matchingInstrumentationLibraryLogs(groupedLogs, sl.Scope()).LogRecords().AppendEmpty()
lr := matchingScopeLogs(groupedLogs, sl.Scope()).LogRecords().AppendEmpty()
log.CopyTo(lr)
}
}
Expand Down Expand Up @@ -246,7 +246,7 @@ func (gap *groupByAttrsProcessor) getGroupedMetricsFromAttributes(
groupedResource := groupedResourceMetrics.findResourceOrElseCreate(originResourceMetrics.Resource(), requiredAttributes)

// Get the corresponding instrumentation library
groupedInstrumentationLibrary := matchingInstrumentationLibraryMetrics(groupedResource, ilm.Scope())
groupedInstrumentationLibrary := matchingScopeMetrics(groupedResource, ilm.Scope())

// Return the metric in this resource
return getMetricInInstrumentationLibrary(groupedInstrumentationLibrary, metric)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (s *scraper) scrape(_ context.Context) (pdata.Metrics, error) {
now := pdata.NewTimestampFromTime(time.Now())

md := pdata.NewMetrics()
metrics := md.ResourceMetrics().AppendEmpty().InstrumentationLibraryMetrics().AppendEmpty().Metrics()
metrics := md.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics()
metrics.EnsureCapacity(metricsLength)

processMetadata, err := s.getProcessesMetadata()
Expand Down