diff --git a/bridge/opencensus/exporter.go b/bridge/opencensus/exporter.go index 7e7e79600071..84aa499a60f7 100644 --- a/bridge/opencensus/exporter.go +++ b/bridge/opencensus/exporter.go @@ -64,8 +64,8 @@ type censusLibraryReader struct { metrics []*metricdata.Metric } -func (r censusLibraryReader) ForEach(readerFunc func(instrumentation.Library, export.Reader) error) error { - return readerFunc(instrumentation.Library{ +func (r censusLibraryReader) ForEach(readerFunc func(instrumentation.Scope, export.Reader) error) error { + return readerFunc(instrumentation.Scope{ Name: "OpenCensus Bridge", }, &metricReader{metrics: r.metrics}) } diff --git a/bridge/opencensus/exporter_test.go b/bridge/opencensus/exporter_test.go index 2634f5334d5f..c1ea8c954003 100644 --- a/bridge/opencensus/exporter_test.go +++ b/bridge/opencensus/exporter_test.go @@ -47,7 +47,7 @@ type fakeExporter struct { func (f *fakeExporter) Export(ctx context.Context, res *resource.Resource, ilr export.InstrumentationLibraryReader) error { return controllertest.ReadAll(ilr, aggregation.StatelessTemporalitySelector(), - func(_ instrumentation.Library, record export.Record) error { + func(_ instrumentation.Scope, record export.Record) error { f.resource = res f.records = append(f.records, record) return f.err diff --git a/exporters/jaeger/jaeger_benchmark_test.go b/exporters/jaeger/jaeger_benchmark_test.go index ab96ac8c9edb..2b0e54c90d67 100644 --- a/exporters/jaeger/jaeger_benchmark_test.go +++ b/exporters/jaeger/jaeger_benchmark_test.go @@ -61,7 +61,7 @@ func spans(n int) []tracesdk.ReadOnlySpan { StartTime: now, EndTime: now, SpanKind: trace.SpanKindClient, - InstrumentationLibrary: instrumentation.Library{ + InstrumentationLibrary: instrumentation.Scope{ Name: instrLibName, }, } diff --git a/exporters/jaeger/jaeger_test.go b/exporters/jaeger/jaeger_test.go index ffc8fe9c3b20..dac2b12a0429 100644 --- a/exporters/jaeger/jaeger_test.go +++ b/exporters/jaeger/jaeger_test.go @@ -187,7 +187,7 @@ func TestSpanSnapshotToThrift(t *testing.T) { EndTime: now, Status: sdktrace.Status{Code: codes.Error}, SpanKind: trace.SpanKindClient, - InstrumentationLibrary: instrumentation.Library{ + InstrumentationLibrary: instrumentation.Scope{ Name: instrLibName, Version: instrLibVersion, }, @@ -245,7 +245,7 @@ func TestSpanSnapshotToThrift(t *testing.T) { Description: statusMessage, }, SpanKind: trace.SpanKindClient, - InstrumentationLibrary: instrumentation.Library{ + InstrumentationLibrary: instrumentation.Scope{ Name: instrLibName, Version: instrLibVersion, }, @@ -330,7 +330,7 @@ func TestSpanSnapshotToThrift(t *testing.T) { Description: statusMessage, }, SpanKind: trace.SpanKindInternal, - InstrumentationLibrary: instrumentation.Library{ + InstrumentationLibrary: instrumentation.Scope{ Name: instrLibName, Version: instrLibVersion, }, @@ -383,7 +383,7 @@ func TestSpanSnapshotToThrift(t *testing.T) { Description: statusMessage, }, SpanKind: trace.SpanKindInternal, - InstrumentationLibrary: instrumentation.Library{ + InstrumentationLibrary: instrumentation.Scope{ Name: instrLibName, Version: instrLibVersion, }, diff --git a/exporters/otlp/otlpmetric/exporter_test.go b/exporters/otlp/otlpmetric/exporter_test.go index d5208fc26d6f..f4fe7774e9a7 100644 --- a/exporters/otlp/otlpmetric/exporter_test.go +++ b/exporters/otlp/otlpmetric/exporter_test.go @@ -728,7 +728,7 @@ func TestStatelessAggregationTemporality(t *testing.T) { func runMetricExportTests(t *testing.T, opts []otlpmetric.Option, res *resource.Resource, records []testRecord, expected []*metricpb.ResourceMetrics) { exp, driver := newExporter(t, opts...) - libraryRecs := map[instrumentation.Library][]export.Record{} + libraryRecs := map[instrumentation.Scope][]export.Record{} for _, r := range records { lcopy := make([]attribute.KeyValue, len(r.attrs)) copy(lcopy, r.attrs) @@ -771,7 +771,7 @@ func runMetricExportTests(t *testing.T, opts []otlpmetric.Option, res *resource. require.NoError(t, agg.SynchronizedMove(ckpt, &desc)) meterCfg := metric.NewMeterConfig(r.meterOpts...) - lib := instrumentation.Library{ + lib := instrumentation.Scope{ Name: r.meterName, Version: meterCfg.InstrumentationVersion(), SchemaURL: meterCfg.SchemaURL(), @@ -838,7 +838,7 @@ func TestEmptyMetricExport(t *testing.T) { }, } { driver.Reset() - require.NoError(t, exp.Export(context.Background(), resource.Empty(), processortest.MultiInstrumentationLibraryReader(map[instrumentation.Library][]export.Record{ + require.NoError(t, exp.Export(context.Background(), resource.Empty(), processortest.MultiInstrumentationLibraryReader(map[instrumentation.Scope][]export.Record{ { Name: testLibName, }: test.records, diff --git a/exporters/otlp/otlpmetric/internal/metrictransform/metric.go b/exporters/otlp/otlpmetric/internal/metrictransform/metric.go index 2d7c9049905d..a189b85bdad9 100644 --- a/exporters/otlp/otlpmetric/internal/metrictransform/metric.go +++ b/exporters/otlp/otlpmetric/internal/metrictransform/metric.go @@ -74,7 +74,7 @@ func toNanos(t time.Time) uint64 { func InstrumentationLibraryReader(ctx context.Context, temporalitySelector aggregation.TemporalitySelector, res *resource.Resource, ilmr export.InstrumentationLibraryReader, numWorkers uint) (*metricpb.ResourceMetrics, error) { var sms []*metricpb.ScopeMetrics - err := ilmr.ForEach(func(lib instrumentation.Library, mr export.Reader) error { + err := ilmr.ForEach(func(lib instrumentation.Scope, mr export.Reader) error { records, errc := source(ctx, temporalitySelector, mr) // Start a fixed number of goroutines to transform records. diff --git a/exporters/otlp/otlpmetric/internal/otlpmetrictest/data.go b/exporters/otlp/otlpmetric/internal/otlpmetrictest/data.go index d8d9c03a31e1..825a31d91897 100644 --- a/exporters/otlp/otlpmetric/internal/otlpmetrictest/data.go +++ b/exporters/otlp/otlpmetric/internal/otlpmetrictest/data.go @@ -48,7 +48,7 @@ func OneRecordReader() export.InstrumentationLibraryReader { rec := export.NewRecord(&desc, &attrs, agg[0].Aggregation(), start, end) return processortest.MultiInstrumentationLibraryReader( - map[instrumentation.Library][]export.Record{ + map[instrumentation.Scope][]export.Record{ { Name: "onelib", }: {rec}, @@ -66,6 +66,6 @@ type FailReader struct{} var _ export.InstrumentationLibraryReader = FailReader{} // ForEach implements export.Reader. It always fails. -func (FailReader) ForEach(readerFunc func(instrumentation.Library, export.Reader) error) error { +func (FailReader) ForEach(readerFunc func(instrumentation.Scope, export.Reader) error) error { return fmt.Errorf("fail") } diff --git a/exporters/otlp/otlptrace/internal/otlptracetest/data.go b/exporters/otlp/otlptrace/internal/otlptracetest/data.go index d039105cb294..4e51f317c84a 100644 --- a/exporters/otlp/otlptrace/internal/otlptracetest/data.go +++ b/exporters/otlp/otlptrace/internal/otlptracetest/data.go @@ -54,7 +54,7 @@ func SingleReadOnlySpan() []tracesdk.ReadOnlySpan { DroppedLinks: 0, ChildSpanCount: 0, Resource: resource.NewSchemaless(attribute.String("a", "b")), - InstrumentationLibrary: instrumentation.Library{ + InstrumentationLibrary: instrumentation.Scope{ Name: "bar", Version: "0.0.0", }, diff --git a/exporters/prometheus/prometheus.go b/exporters/prometheus/prometheus.go index fb544d004fb6..c7aa16d12577 100644 --- a/exporters/prometheus/prometheus.go +++ b/exporters/prometheus/prometheus.go @@ -151,7 +151,7 @@ func (c *collector) Describe(ch chan<- *prometheus.Desc) { c.exp.lock.RLock() defer c.exp.lock.RUnlock() - _ = c.exp.Controller().ForEach(func(_ instrumentation.Library, reader export.Reader) error { + _ = c.exp.Controller().ForEach(func(_ instrumentation.Scope, reader export.Reader) error { return reader.ForEach(c.exp, func(record export.Record) error { var attrKeys []string mergeAttrs(record, c.exp.controller.Resource(), &attrKeys, nil) @@ -174,7 +174,7 @@ func (c *collector) Collect(ch chan<- prometheus.Metric) { otel.Handle(err) } - err := ctrl.ForEach(func(_ instrumentation.Library, reader export.Reader) error { + err := ctrl.ForEach(func(_ instrumentation.Scope, reader export.Reader) error { return reader.ForEach(c.exp, func(record export.Record) error { agg := record.Aggregation() numberKind := record.Descriptor().NumberKind() diff --git a/exporters/stdout/stdoutmetric/metric.go b/exporters/stdout/stdoutmetric/metric.go index 38289d281a7a..0bdee8e90931 100644 --- a/exporters/stdout/stdoutmetric/metric.go +++ b/exporters/stdout/stdoutmetric/metric.go @@ -52,7 +52,7 @@ func (e *metricExporter) TemporalityFor(desc *sdkapi.Descriptor, kind aggregatio func (e *metricExporter) Export(_ context.Context, res *resource.Resource, reader export.InstrumentationLibraryReader) error { var aggError error var batch []line - aggError = reader.ForEach(func(lib instrumentation.Library, mr export.Reader) error { + aggError = reader.ForEach(func(lib instrumentation.Scope, mr export.Reader) error { var instAttrs []attribute.KeyValue if name := lib.Name; name != "" { instAttrs = append(instAttrs, attribute.String("instrumentation.name", name)) diff --git a/exporters/zipkin/model_test.go b/exporters/zipkin/model_test.go index 454d18c495be..b5cca12742c2 100644 --- a/exporters/zipkin/model_test.go +++ b/exporters/zipkin/model_test.go @@ -829,7 +829,7 @@ func TestTagsTransformation(t *testing.T) { { name: "instrLib-empty", data: tracetest.SpanStub{ - InstrumentationLibrary: instrumentation.Library{}, + InstrumentationLibrary: instrumentation.Scope{}, }, want: nil, }, @@ -837,7 +837,7 @@ func TestTagsTransformation(t *testing.T) { name: "instrLib-noversion", data: tracetest.SpanStub{ Attributes: []attribute.KeyValue{}, - InstrumentationLibrary: instrumentation.Library{ + InstrumentationLibrary: instrumentation.Scope{ Name: instrLibName, }, }, @@ -849,7 +849,7 @@ func TestTagsTransformation(t *testing.T) { name: "instrLib-with-version", data: tracetest.SpanStub{ Attributes: []attribute.KeyValue{}, - InstrumentationLibrary: instrumentation.Library{ + InstrumentationLibrary: instrumentation.Scope{ Name: instrLibName, Version: instrLibVersion, }, diff --git a/sdk/metric/controller/basic/controller.go b/sdk/metric/controller/basic/controller.go index 2107b16cb3c4..8f4cf505aa7a 100644 --- a/sdk/metric/controller/basic/controller.go +++ b/sdk/metric/controller/basic/controller.go @@ -46,12 +46,12 @@ var ErrControllerStarted = fmt.Errorf("controller already started") // both "pull" and "push" configurations. This supports two distinct // modes: // -// - Push and Pull: Start() must be called to begin calling the exporter; -// Collect() is called periodically by a background thread after starting -// the controller. -// - Pull-Only: Start() is optional in this case, to call Collect periodically. -// If Start() is not called, Collect() can be called manually to initiate -// collection +// - Push and Pull: Start() must be called to begin calling the exporter; +// Collect() is called periodically by a background thread after starting +// the controller. +// - Pull-Only: Start() is optional in this case, to call Collect periodically. +// If Start() is not called, Collect() can be called manually to initiate +// collection // // The controller supports mixing push and pull access to metric data // using the export.Reader RWLock interface. Collection will @@ -323,7 +323,7 @@ func (c *Controller) export(ctx context.Context) error { // nolint:revive // me } // ForEach implements export.InstrumentationLibraryReader. -func (c *Controller) ForEach(readerFunc func(l instrumentation.Library, r export.Reader) error) error { +func (c *Controller) ForEach(readerFunc func(l instrumentation.Scope, r export.Reader) error) error { for _, acPair := range c.accumulatorList() { reader := acPair.checkpointer.Reader() // TODO: We should not fail fast; instead accumulate errors. diff --git a/sdk/metric/controller/controllertest/test.go b/sdk/metric/controller/controllertest/test.go index 9c1a34219726..045159f39c2d 100644 --- a/sdk/metric/controller/controllertest/test.go +++ b/sdk/metric/controller/controllertest/test.go @@ -75,9 +75,9 @@ func (t MockTicker) C() <-chan time.Time { func ReadAll( reader export.InstrumentationLibraryReader, kind aggregation.TemporalitySelector, - apply func(instrumentation.Library, export.Record) error, + apply func(instrumentation.Scope, export.Record) error, ) error { - return reader.ForEach(func(library instrumentation.Library, reader export.Reader) error { + return reader.ForEach(func(library instrumentation.Scope, reader export.Reader) error { return reader.ForEach(kind, func(record export.Record) error { return apply(library, record) }) diff --git a/sdk/metric/export/metric.go b/sdk/metric/export/metric.go index 6168ca445ba5..e2cf1bf57af5 100644 --- a/sdk/metric/export/metric.go +++ b/sdk/metric/export/metric.go @@ -155,7 +155,7 @@ type InstrumentationLibraryReader interface { // ForEach calls the passed function once per instrumentation library, // allowing the caller to emit metrics grouped by the library that // produced them. - ForEach(readerFunc func(instrumentation.Library, Reader) error) error + ForEach(readerFunc func(instrumentation.Scope, Reader) error) error } // Reader allows a controller to access a complete checkpoint of diff --git a/sdk/metric/metrictest/exporter.go b/sdk/metric/metrictest/exporter.go index c0926dd7cf68..f984fc7c79a5 100644 --- a/sdk/metric/metrictest/exporter.go +++ b/sdk/metric/metrictest/exporter.go @@ -98,7 +98,7 @@ func (e *Exporter) Collect(ctx context.Context) error { return err } - return e.controller.ForEach(func(l instrumentation.Library, r export.Reader) error { + return e.controller.ForEach(func(l instrumentation.Scope, r export.Reader) error { lib := Library{ InstrumentationName: l.Name, InstrumentationVersion: l.Version, diff --git a/sdk/metric/processor/basic/basic_test.go b/sdk/metric/processor/basic/basic_test.go index 21d816b44a02..43d06109c250 100644 --- a/sdk/metric/processor/basic/basic_test.go +++ b/sdk/metric/processor/basic/basic_test.go @@ -471,7 +471,7 @@ func TestCounterObserverEndToEnd(t *testing.T) { exporter := processortest.New(eselector, attribute.DefaultEncoder()) require.NoError(t, exporter.Export(ctx, resource.Empty(), processortest.OneInstrumentationLibraryReader( - instrumentation.Library{ + instrumentation.Scope{ Name: "test", }, reader))) diff --git a/sdk/metric/processor/processortest/test.go b/sdk/metric/processor/processortest/test.go index fa0e902d2558..c84295aad644 100644 --- a/sdk/metric/processor/processortest/test.go +++ b/sdk/metric/processor/processortest/test.go @@ -118,9 +118,9 @@ func (f testFactory) NewCheckpointer() export.Checkpointer { // NewProcessor returns a new testing Processor implementation. // Verify expected outputs using Values(), e.g.: // -// require.EqualValues(t, map[string]float64{ -// "counter.sum/A=1,B=2/R=V": 100, -// }, processor.Values()) +// require.EqualValues(t, map[string]float64{ +// "counter.sum/A=1,B=2/R=V": 100, +// }, processor.Values()) // // Where in the example A=1,B=2 is the encoded attributes and R=V is the // encoded resource value. @@ -243,7 +243,7 @@ func (o *Output) AddRecord(rec export.Record) error { } // AddRecordWithResource merges rec into this Output. -func (o *Output) AddInstrumentationLibraryRecord(_ instrumentation.Library, rec export.Record) error { +func (o *Output) AddInstrumentationLibraryRecord(_ instrumentation.Scope, rec export.Record) error { return o.AddRecordWithResource(rec, resource.Empty()) } @@ -322,9 +322,9 @@ func (o *Output) AddAccumulation(acc export.Accumulation) error { // New returns a new testing Exporter implementation. // Verify exporter outputs using Values(), e.g.,: // -// require.EqualValues(t, map[string]float64{ -// "counter.sum/A=1,B=2/R=V": 100, -// }, exporter.Values()) +// require.EqualValues(t, map[string]float64{ +// "counter.sum/A=1,B=2/R=V": 100, +// }, exporter.Values()) // // Where in the example A=1,B=2 is the encoded attributes and R=V is the // encoded resource value. @@ -340,7 +340,7 @@ func (e *Exporter) Export(_ context.Context, res *resource.Resource, ckpt export e.output.Lock() defer e.output.Unlock() e.exportCount++ - return ckpt.ForEach(func(library instrumentation.Library, mr export.Reader) error { + return ckpt.ForEach(func(library instrumentation.Scope, mr export.Reader) error { return mr.ForEach(e.TemporalitySelector, func(r export.Record) error { if e.InjectErr != nil { if err := e.InjectErr(r); err != nil { @@ -381,32 +381,32 @@ func (e *Exporter) Reset() { // OneInstrumentationLibraryReader returns an InstrumentationLibraryReader for // a single instrumentation library. -func OneInstrumentationLibraryReader(l instrumentation.Library, r export.Reader) export.InstrumentationLibraryReader { +func OneInstrumentationLibraryReader(l instrumentation.Scope, r export.Reader) export.InstrumentationLibraryReader { return oneLibraryReader{l, r} } type oneLibraryReader struct { - library instrumentation.Library + library instrumentation.Scope reader export.Reader } -func (o oneLibraryReader) ForEach(readerFunc func(instrumentation.Library, export.Reader) error) error { +func (o oneLibraryReader) ForEach(readerFunc func(instrumentation.Scope, export.Reader) error) error { return readerFunc(o.library, o.reader) } // MultiInstrumentationLibraryReader returns an InstrumentationLibraryReader // for a group of records that came from multiple instrumentation libraries. -func MultiInstrumentationLibraryReader(records map[instrumentation.Library][]export.Record) export.InstrumentationLibraryReader { +func MultiInstrumentationLibraryReader(records map[instrumentation.Scope][]export.Record) export.InstrumentationLibraryReader { return instrumentationLibraryReader{records: records} } type instrumentationLibraryReader struct { - records map[instrumentation.Library][]export.Record + records map[instrumentation.Scope][]export.Record } var _ export.InstrumentationLibraryReader = instrumentationLibraryReader{} -func (m instrumentationLibraryReader) ForEach(fn func(instrumentation.Library, export.Reader) error) error { +func (m instrumentationLibraryReader) ForEach(fn func(instrumentation.Scope, export.Reader) error) error { for library, records := range m.records { if err := fn(library, &metricReader{records: records}); err != nil { return err diff --git a/sdk/metric/processor/processortest/test_test.go b/sdk/metric/processor/processortest/test_test.go index 98c15f2f763a..2ca854edb7ac 100644 --- a/sdk/metric/processor/processortest/test_test.go +++ b/sdk/metric/processor/processortest/test_test.go @@ -80,7 +80,7 @@ func TestProcessorTesting(t *testing.T) { ) err := exporter.Export(context.Background(), res, processortest.OneInstrumentationLibraryReader( - instrumentation.Library{ + instrumentation.Scope{ Name: "test", }, checkpointer.Reader(), diff --git a/sdk/metric/processor/reducer/reducer_test.go b/sdk/metric/processor/reducer/reducer_test.go index 12fbb7f86e03..197cafe516f7 100644 --- a/sdk/metric/processor/reducer/reducer_test.go +++ b/sdk/metric/processor/reducer/reducer_test.go @@ -106,7 +106,7 @@ func TestFilterBasicProcessor(t *testing.T) { } res := resource.NewSchemaless(attribute.String("R", "V")) - require.NoError(t, exporter.Export(context.Background(), res, processortest.OneInstrumentationLibraryReader(instrumentation.Library{ + require.NoError(t, exporter.Export(context.Background(), res, processortest.OneInstrumentationLibraryReader(instrumentation.Scope{ Name: "test", }, basicProc.Reader()))) diff --git a/sdk/trace/snapshot.go b/sdk/trace/snapshot.go index 0349b2f198e4..1f0cad6e2423 100644 --- a/sdk/trace/snapshot.go +++ b/sdk/trace/snapshot.go @@ -110,7 +110,7 @@ func (s snapshot) InstrumentationScope() instrumentation.Scope { // InstrumentationLibrary returns information about the instrumentation // library that created the span. -func (s snapshot) InstrumentationLibrary() instrumentation.Library { +func (s snapshot) InstrumentationLibrary() instrumentation.Scope { return s.instrumentationScope } diff --git a/sdk/trace/span.go b/sdk/trace/span.go index 14d0aabfe695..80ba2553f5f1 100644 --- a/sdk/trace/span.go +++ b/sdk/trace/span.go @@ -69,7 +69,7 @@ type ReadOnlySpan interface { // InstrumentationLibrary returns information about the instrumentation // library that created the span. // Deprecated: please use InstrumentationScope instead. - InstrumentationLibrary() instrumentation.Library + InstrumentationLibrary() instrumentation.Scope // Resource returns information about the entity that produced the span. Resource() *resource.Resource // DroppedAttributes returns the number of attributes dropped by the span @@ -596,9 +596,9 @@ func (s *recordingSpan) InstrumentationScope() instrumentation.Scope { return s.tracer.instrumentationScope } -// InstrumentationLibrary returns the instrumentation.Library associated with +// InstrumentationLibrary returns the instrumentation.Scope associated with // the Tracer that created this span. -func (s *recordingSpan) InstrumentationLibrary() instrumentation.Library { +func (s *recordingSpan) InstrumentationLibrary() instrumentation.Scope { s.mu.Lock() defer s.mu.Unlock() return s.tracer.instrumentationScope diff --git a/sdk/trace/tracetest/span.go b/sdk/trace/tracetest/span.go index bfe73de9c415..b785dfe7381d 100644 --- a/sdk/trace/tracetest/span.go +++ b/sdk/trace/tracetest/span.go @@ -71,7 +71,7 @@ type SpanStub struct { DroppedLinks int ChildSpanCount int Resource *resource.Resource - InstrumentationLibrary instrumentation.Library + InstrumentationLibrary instrumentation.Scope } // SpanStubFromReadOnlySpan returns a SpanStub populated from ro. @@ -162,6 +162,6 @@ func (s spanSnapshot) Resource() *resource.Resource { return s.resource } func (s spanSnapshot) InstrumentationScope() instrumentation.Scope { return s.instrumentationScope } -func (s spanSnapshot) InstrumentationLibrary() instrumentation.Library { +func (s spanSnapshot) InstrumentationLibrary() instrumentation.Scope { return s.instrumentationScope }