You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-07-03 00:27:03 +02:00
Deprecate Library and move all uses to Scope (#2977)
* Deprecate Library and move all uses to Scope * Add PR number to changelog * Don't change signatures in stable modules * Revert some changes * Rename internal struct names * A bit more renaming * Update sdk/trace/span.go Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com> * Update based on feedback * Revert change Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com> Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
This commit is contained in:
@ -17,6 +17,13 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||||||
|
|
||||||
- Support for go1.16. Support is now only for go1.17 and go1.18 (#2917)
|
- Support for go1.16. Support is now only for go1.17 and go1.18 (#2917)
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
|
||||||
|
- The `Library` struct in the `go.opentelemetry.io/otel/sdk/instrumentation` package is deprecated.
|
||||||
|
Use the equivalent `Scope` struct instead. (#2977)
|
||||||
|
- The `ReadOnlySpan.InstrumentationLibrary` method from the `go.opentelemetry.io/otel/sdk/trace` package is deprecated.
|
||||||
|
Use the equivalent `ReadOnlySpan.InstrumentationScope` method instead. (#2977)
|
||||||
|
|
||||||
## [1.7.0/0.30.0] - 2022-04-28
|
## [1.7.0/0.30.0] - 2022-04-28
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@ -142,10 +142,10 @@ func spanToThrift(ss sdktrace.ReadOnlySpan) *gen.Span {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if il := ss.InstrumentationLibrary(); il.Name != "" {
|
if is := ss.InstrumentationScope(); is.Name != "" {
|
||||||
tags = append(tags, getStringTag(keyInstrumentationLibraryName, il.Name))
|
tags = append(tags, getStringTag(keyInstrumentationLibraryName, is.Name))
|
||||||
if il.Version != "" {
|
if is.Version != "" {
|
||||||
tags = append(tags, getStringTag(keyInstrumentationLibraryVersion, il.Version))
|
tags = append(tags, getStringTag(keyInstrumentationLibraryVersion, is.Version))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@ import (
|
|||||||
commonpb "go.opentelemetry.io/proto/otlp/common/v1"
|
commonpb "go.opentelemetry.io/proto/otlp/common/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func InstrumentationScope(il instrumentation.Library) *commonpb.InstrumentationScope {
|
func InstrumentationScope(il instrumentation.Scope) *commonpb.InstrumentationScope {
|
||||||
if il == (instrumentation.Library{}) {
|
if il == (instrumentation.Scope{}) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return &commonpb.InstrumentationScope{
|
return &commonpb.InstrumentationScope{
|
||||||
|
@ -34,7 +34,7 @@ func Spans(sdl []tracesdk.ReadOnlySpan) []*tracepb.ResourceSpans {
|
|||||||
|
|
||||||
type key struct {
|
type key struct {
|
||||||
r attribute.Distinct
|
r attribute.Distinct
|
||||||
il instrumentation.Library
|
is instrumentation.Scope
|
||||||
}
|
}
|
||||||
ssm := make(map[key]*tracepb.ScopeSpans)
|
ssm := make(map[key]*tracepb.ScopeSpans)
|
||||||
|
|
||||||
@ -47,15 +47,15 @@ func Spans(sdl []tracesdk.ReadOnlySpan) []*tracepb.ResourceSpans {
|
|||||||
rKey := sd.Resource().Equivalent()
|
rKey := sd.Resource().Equivalent()
|
||||||
k := key{
|
k := key{
|
||||||
r: rKey,
|
r: rKey,
|
||||||
il: sd.InstrumentationLibrary(),
|
is: sd.InstrumentationScope(),
|
||||||
}
|
}
|
||||||
scopeSpan, iOk := ssm[k]
|
scopeSpan, iOk := ssm[k]
|
||||||
if !iOk {
|
if !iOk {
|
||||||
// Either the resource or instrumentation library were unknown.
|
// Either the resource or instrumentation scope were unknown.
|
||||||
scopeSpan = &tracepb.ScopeSpans{
|
scopeSpan = &tracepb.ScopeSpans{
|
||||||
Scope: InstrumentationScope(sd.InstrumentationLibrary()),
|
Scope: InstrumentationScope(sd.InstrumentationScope()),
|
||||||
Spans: []*tracepb.Span{},
|
Spans: []*tracepb.Span{},
|
||||||
SchemaUrl: sd.InstrumentationLibrary().SchemaURL,
|
SchemaUrl: sd.InstrumentationScope().SchemaURL,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scopeSpan.Spans = append(scopeSpan.Spans, span(sd))
|
scopeSpan.Spans = append(scopeSpan.Spans, span(sd))
|
||||||
|
@ -264,7 +264,7 @@ func TestSpanData(t *testing.T) {
|
|||||||
attribute.Int64("rk2", 5),
|
attribute.Int64("rk2", 5),
|
||||||
attribute.StringSlice("rk3", []string{"sv1", "sv2"}),
|
attribute.StringSlice("rk3", []string{"sv1", "sv2"}),
|
||||||
),
|
),
|
||||||
InstrumentationLibrary: instrumentation.Library{
|
InstrumentationLibrary: instrumentation.Scope{
|
||||||
Name: "go.opentelemetry.io/test/otel",
|
Name: "go.opentelemetry.io/test/otel",
|
||||||
Version: "v0.0.1",
|
Version: "v0.0.1",
|
||||||
SchemaURL: semconv.SchemaURL,
|
SchemaURL: semconv.SchemaURL,
|
||||||
|
@ -218,10 +218,10 @@ func toZipkinTags(data tracesdk.ReadOnlySpan) map[string]string {
|
|||||||
delete(m, "error")
|
delete(m, "error")
|
||||||
}
|
}
|
||||||
|
|
||||||
if il := data.InstrumentationLibrary(); il.Name != "" {
|
if is := data.InstrumentationScope(); is.Name != "" {
|
||||||
m[keyInstrumentationLibraryName] = il.Name
|
m[keyInstrumentationLibraryName] = is.Name
|
||||||
if il.Version != "" {
|
if is.Version != "" {
|
||||||
m[keyInstrumentationLibraryVersion] = il.Version
|
m[keyInstrumentationLibraryVersion] = is.Version
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,4 +22,5 @@ For more information see
|
|||||||
package instrumentation // import "go.opentelemetry.io/otel/sdk/instrumentation"
|
package instrumentation // import "go.opentelemetry.io/otel/sdk/instrumentation"
|
||||||
|
|
||||||
// Library represents the instrumentation library.
|
// Library represents the instrumentation library.
|
||||||
|
// Deprecated: please use Scope instead.
|
||||||
type Library = Scope
|
type Library = Scope
|
||||||
|
@ -59,7 +59,7 @@ var ErrControllerStarted = fmt.Errorf("controller already started")
|
|||||||
type Controller struct {
|
type Controller struct {
|
||||||
// lock synchronizes Start() and Stop().
|
// lock synchronizes Start() and Stop().
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
libraries sync.Map
|
scopes sync.Map
|
||||||
checkpointerFactory export.CheckpointerFactory
|
checkpointerFactory export.CheckpointerFactory
|
||||||
|
|
||||||
resource *resource.Resource
|
resource *resource.Resource
|
||||||
@ -85,21 +85,21 @@ var _ metric.MeterProvider = &Controller{}
|
|||||||
// with opts.
|
// with opts.
|
||||||
func (c *Controller) Meter(instrumentationName string, opts ...metric.MeterOption) metric.Meter {
|
func (c *Controller) Meter(instrumentationName string, opts ...metric.MeterOption) metric.Meter {
|
||||||
cfg := metric.NewMeterConfig(opts...)
|
cfg := metric.NewMeterConfig(opts...)
|
||||||
library := instrumentation.Library{
|
scope := instrumentation.Scope{
|
||||||
Name: instrumentationName,
|
Name: instrumentationName,
|
||||||
Version: cfg.InstrumentationVersion(),
|
Version: cfg.InstrumentationVersion(),
|
||||||
SchemaURL: cfg.SchemaURL(),
|
SchemaURL: cfg.SchemaURL(),
|
||||||
}
|
}
|
||||||
|
|
||||||
m, ok := c.libraries.Load(library)
|
m, ok := c.scopes.Load(scope)
|
||||||
if !ok {
|
if !ok {
|
||||||
checkpointer := c.checkpointerFactory.NewCheckpointer()
|
checkpointer := c.checkpointerFactory.NewCheckpointer()
|
||||||
m, _ = c.libraries.LoadOrStore(
|
m, _ = c.scopes.LoadOrStore(
|
||||||
library,
|
scope,
|
||||||
registry.NewUniqueInstrumentMeterImpl(&accumulatorCheckpointer{
|
registry.NewUniqueInstrumentMeterImpl(&accumulatorCheckpointer{
|
||||||
Accumulator: sdk.NewAccumulator(checkpointer),
|
Accumulator: sdk.NewAccumulator(checkpointer),
|
||||||
checkpointer: checkpointer,
|
checkpointer: checkpointer,
|
||||||
library: library,
|
scope: scope,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
return sdkapi.WrapMeterImpl(m.(*registry.UniqueInstrumentMeterImpl))
|
return sdkapi.WrapMeterImpl(m.(*registry.UniqueInstrumentMeterImpl))
|
||||||
@ -108,7 +108,7 @@ func (c *Controller) Meter(instrumentationName string, opts ...metric.MeterOptio
|
|||||||
type accumulatorCheckpointer struct {
|
type accumulatorCheckpointer struct {
|
||||||
*sdk.Accumulator
|
*sdk.Accumulator
|
||||||
checkpointer export.Checkpointer
|
checkpointer export.Checkpointer
|
||||||
library instrumentation.Library
|
scope instrumentation.Scope
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ sdkapi.MeterImpl = &accumulatorCheckpointer{}
|
var _ sdkapi.MeterImpl = &accumulatorCheckpointer{}
|
||||||
@ -248,7 +248,7 @@ func (c *Controller) collect(ctx context.Context) error {
|
|||||||
// registered to this controller. This briefly locks the controller.
|
// registered to this controller. This briefly locks the controller.
|
||||||
func (c *Controller) accumulatorList() []*accumulatorCheckpointer {
|
func (c *Controller) accumulatorList() []*accumulatorCheckpointer {
|
||||||
var r []*accumulatorCheckpointer
|
var r []*accumulatorCheckpointer
|
||||||
c.libraries.Range(func(key, value interface{}) bool {
|
c.scopes.Range(func(key, value interface{}) bool {
|
||||||
acc, ok := value.(*registry.UniqueInstrumentMeterImpl).MeterImpl().(*accumulatorCheckpointer)
|
acc, ok := value.(*registry.UniqueInstrumentMeterImpl).MeterImpl().(*accumulatorCheckpointer)
|
||||||
if ok {
|
if ok {
|
||||||
r = append(r, acc)
|
r = append(r, acc)
|
||||||
@ -272,7 +272,7 @@ func (c *Controller) checkpoint(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// checkpointSingleAccumulator checkpoints a single instrumentation
|
// checkpointSingleAccumulator checkpoints a single instrumentation
|
||||||
// library's accumulator, which involves calling
|
// scope's accumulator, which involves calling
|
||||||
// checkpointer.StartCollection, accumulator.Collect, and
|
// checkpointer.StartCollection, accumulator.Collect, and
|
||||||
// checkpointer.FinishCollection in sequence.
|
// checkpointer.FinishCollection in sequence.
|
||||||
func (c *Controller) checkpointSingleAccumulator(ctx context.Context, ac *accumulatorCheckpointer) error {
|
func (c *Controller) checkpointSingleAccumulator(ctx context.Context, ac *accumulatorCheckpointer) error {
|
||||||
@ -330,7 +330,7 @@ func (c *Controller) ForEach(readerFunc func(l instrumentation.Library, r export
|
|||||||
if err := func() error {
|
if err := func() error {
|
||||||
reader.RLock()
|
reader.RLock()
|
||||||
defer reader.RUnlock()
|
defer reader.RUnlock()
|
||||||
return readerFunc(acPair.library, reader)
|
return readerFunc(acPair.scope, reader)
|
||||||
}(); err != nil {
|
}(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ func getMap(t *testing.T, cont *controller.Controller) map[string]float64 {
|
|||||||
out := processortest.NewOutput(attribute.DefaultEncoder())
|
out := processortest.NewOutput(attribute.DefaultEncoder())
|
||||||
|
|
||||||
require.NoError(t, cont.ForEach(
|
require.NoError(t, cont.ForEach(
|
||||||
func(_ instrumentation.Library, reader export.Reader) error {
|
func(_ instrumentation.Scope, reader export.Reader) error {
|
||||||
return reader.ForEach(
|
return reader.ForEach(
|
||||||
aggregation.CumulativeTemporalitySelector(),
|
aggregation.CumulativeTemporalitySelector(),
|
||||||
func(record export.Record) error {
|
func(record export.Record) error {
|
||||||
|
@ -64,9 +64,12 @@ func NewTestMeterProvider(opts ...Option) (metric.MeterProvider, *Exporter) {
|
|||||||
return c, exp
|
return c, exp
|
||||||
}
|
}
|
||||||
|
|
||||||
// Library is the same as "sdk/instrumentation".Library but there is
|
// Deprecated: please use Scope instead.
|
||||||
|
type Library = Scope
|
||||||
|
|
||||||
|
// Scope is the same as "sdk/instrumentation".Scope but there is
|
||||||
// a package cycle to use it so it is redeclared here.
|
// a package cycle to use it so it is redeclared here.
|
||||||
type Library struct {
|
type Scope struct {
|
||||||
InstrumentationName string
|
InstrumentationName string
|
||||||
InstrumentationVersion string
|
InstrumentationVersion string
|
||||||
SchemaURL string
|
SchemaURL string
|
||||||
|
@ -74,7 +74,7 @@ func (cfg tracerProviderConfig) MarshalLog() interface{} {
|
|||||||
// instrumentation so it can trace operational flow through a system.
|
// instrumentation so it can trace operational flow through a system.
|
||||||
type TracerProvider struct {
|
type TracerProvider struct {
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
namedTracer map[instrumentation.Library]*tracer
|
namedTracer map[instrumentation.Scope]*tracer
|
||||||
spanProcessors atomic.Value
|
spanProcessors atomic.Value
|
||||||
|
|
||||||
// These fields are not protected by the lock mu. They are assumed to be
|
// These fields are not protected by the lock mu. They are assumed to be
|
||||||
@ -110,7 +110,7 @@ func NewTracerProvider(opts ...TracerProviderOption) *TracerProvider {
|
|||||||
o = ensureValidTracerProviderConfig(o)
|
o = ensureValidTracerProviderConfig(o)
|
||||||
|
|
||||||
tp := &TracerProvider{
|
tp := &TracerProvider{
|
||||||
namedTracer: make(map[instrumentation.Library]*tracer),
|
namedTracer: make(map[instrumentation.Scope]*tracer),
|
||||||
sampler: o.sampler,
|
sampler: o.sampler,
|
||||||
idGenerator: o.idGenerator,
|
idGenerator: o.idGenerator,
|
||||||
spanLimits: o.spanLimits,
|
spanLimits: o.spanLimits,
|
||||||
@ -141,18 +141,18 @@ func (p *TracerProvider) Tracer(name string, opts ...trace.TracerOption) trace.T
|
|||||||
if name == "" {
|
if name == "" {
|
||||||
name = defaultTracerName
|
name = defaultTracerName
|
||||||
}
|
}
|
||||||
il := instrumentation.Library{
|
is := instrumentation.Scope{
|
||||||
Name: name,
|
Name: name,
|
||||||
Version: c.InstrumentationVersion(),
|
Version: c.InstrumentationVersion(),
|
||||||
SchemaURL: c.SchemaURL(),
|
SchemaURL: c.SchemaURL(),
|
||||||
}
|
}
|
||||||
t, ok := p.namedTracer[il]
|
t, ok := p.namedTracer[is]
|
||||||
if !ok {
|
if !ok {
|
||||||
t = &tracer{
|
t = &tracer{
|
||||||
provider: p,
|
provider: p,
|
||||||
instrumentationLibrary: il,
|
instrumentationScope: is,
|
||||||
}
|
}
|
||||||
p.namedTracer[il] = t
|
p.namedTracer[is] = t
|
||||||
global.Info("Tracer created", "name", name, "version", c.InstrumentationVersion(), "schemaURL", c.SchemaURL())
|
global.Info("Tracer created", "name", name, "version", c.InstrumentationVersion(), "schemaURL", c.SchemaURL())
|
||||||
}
|
}
|
||||||
return t
|
return t
|
||||||
|
@ -96,7 +96,7 @@ func TestSchemaURL(t *testing.T) {
|
|||||||
|
|
||||||
// Verify that the SchemaURL of the constructed Tracer is correctly populated.
|
// Verify that the SchemaURL of the constructed Tracer is correctly populated.
|
||||||
tracerStruct := tracerIface.(*tracer)
|
tracerStruct := tracerIface.(*tracer)
|
||||||
assert.EqualValues(t, schemaURL, tracerStruct.instrumentationLibrary.SchemaURL)
|
assert.EqualValues(t, schemaURL, tracerStruct.instrumentationScope.SchemaURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTracerProviderSamplerConfigFromEnv(t *testing.T) {
|
func TestTracerProviderSamplerConfigFromEnv(t *testing.T) {
|
||||||
|
@ -41,7 +41,7 @@ type snapshot struct {
|
|||||||
droppedEventCount int
|
droppedEventCount int
|
||||||
droppedLinkCount int
|
droppedLinkCount int
|
||||||
resource *resource.Resource
|
resource *resource.Resource
|
||||||
instrumentationLibrary instrumentation.Library
|
instrumentationScope instrumentation.Scope
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ ReadOnlySpan = snapshot{}
|
var _ ReadOnlySpan = snapshot{}
|
||||||
@ -102,10 +102,16 @@ func (s snapshot) Status() Status {
|
|||||||
return s.status
|
return s.status
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InstrumentationScope returns information about the instrumentation
|
||||||
|
// scope that created the span.
|
||||||
|
func (s snapshot) InstrumentationScope() instrumentation.Scope {
|
||||||
|
return s.instrumentationScope
|
||||||
|
}
|
||||||
|
|
||||||
// InstrumentationLibrary returns information about the instrumentation
|
// InstrumentationLibrary returns information about the instrumentation
|
||||||
// library that created the span.
|
// library that created the span.
|
||||||
func (s snapshot) InstrumentationLibrary() instrumentation.Library {
|
func (s snapshot) InstrumentationLibrary() instrumentation.Library {
|
||||||
return s.instrumentationLibrary
|
return s.instrumentationScope
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resource returns information about the entity that produced the span.
|
// Resource returns information about the entity that produced the span.
|
||||||
|
@ -63,8 +63,12 @@ type ReadOnlySpan interface {
|
|||||||
Events() []Event
|
Events() []Event
|
||||||
// Status returns the spans status.
|
// Status returns the spans status.
|
||||||
Status() Status
|
Status() Status
|
||||||
|
// InstrumentationScope returns information about the instrumentation
|
||||||
|
// scope that created the span.
|
||||||
|
InstrumentationScope() instrumentation.Scope
|
||||||
// InstrumentationLibrary returns information about the instrumentation
|
// InstrumentationLibrary returns information about the instrumentation
|
||||||
// library that created the span.
|
// library that created the span.
|
||||||
|
// Deprecated: please use InstrumentationScope instead.
|
||||||
InstrumentationLibrary() instrumentation.Library
|
InstrumentationLibrary() instrumentation.Library
|
||||||
// Resource returns information about the entity that produced the span.
|
// Resource returns information about the entity that produced the span.
|
||||||
Resource() *resource.Resource
|
Resource() *resource.Resource
|
||||||
@ -584,12 +588,20 @@ func (s *recordingSpan) Status() Status {
|
|||||||
return s.status
|
return s.status
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InstrumentationScope returns the instrumentation.Scope associated with
|
||||||
|
// the Tracer that created this span.
|
||||||
|
func (s *recordingSpan) InstrumentationScope() instrumentation.Scope {
|
||||||
|
s.mu.Lock()
|
||||||
|
defer s.mu.Unlock()
|
||||||
|
return s.tracer.instrumentationScope
|
||||||
|
}
|
||||||
|
|
||||||
// InstrumentationLibrary returns the instrumentation.Library associated with
|
// InstrumentationLibrary returns the instrumentation.Library associated with
|
||||||
// the Tracer that created this span.
|
// the Tracer that created this span.
|
||||||
func (s *recordingSpan) InstrumentationLibrary() instrumentation.Library {
|
func (s *recordingSpan) InstrumentationLibrary() instrumentation.Library {
|
||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
defer s.mu.Unlock()
|
defer s.mu.Unlock()
|
||||||
return s.tracer.instrumentationLibrary
|
return s.tracer.instrumentationScope
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resource returns the Resource associated with the Tracer that created this
|
// Resource returns the Resource associated with the Tracer that created this
|
||||||
@ -668,7 +680,7 @@ func (s *recordingSpan) snapshot() ReadOnlySpan {
|
|||||||
defer s.mu.Unlock()
|
defer s.mu.Unlock()
|
||||||
|
|
||||||
sd.endTime = s.endTime
|
sd.endTime = s.endTime
|
||||||
sd.instrumentationLibrary = s.tracer.instrumentationLibrary
|
sd.instrumentationScope = s.tracer.instrumentationScope
|
||||||
sd.name = s.name
|
sd.name = s.name
|
||||||
sd.parent = s.parent
|
sd.parent = s.parent
|
||||||
sd.resource = s.tracer.provider.resource
|
sd.resource = s.tracer.provider.resource
|
||||||
|
@ -67,7 +67,7 @@ func (f InstrumentationBlacklist) ForceFlush(ctx context.Context) error {
|
|||||||
return f.Next.ForceFlush(ctx)
|
return f.Next.ForceFlush(ctx)
|
||||||
}
|
}
|
||||||
func (f InstrumentationBlacklist) OnEnd(s ReadOnlySpan) {
|
func (f InstrumentationBlacklist) OnEnd(s ReadOnlySpan) {
|
||||||
if f.Blacklist != nil && f.Blacklist[s.InstrumentationLibrary().Name] {
|
if f.Blacklist != nil && f.Blacklist[s.InstrumentationScope().Name] {
|
||||||
// Drop spans from this instrumentation
|
// Drop spans from this instrumentation
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -412,7 +412,7 @@ func TestSetSpanAttributesOnStart(t *testing.T) {
|
|||||||
attribute.String("key2", "value2"),
|
attribute.String("key2", "value2"),
|
||||||
},
|
},
|
||||||
spanKind: trace.SpanKindInternal,
|
spanKind: trace.SpanKindInternal,
|
||||||
instrumentationLibrary: instrumentation.Library{Name: "StartSpanAttribute"},
|
instrumentationScope: instrumentation.Scope{Name: "StartSpanAttribute"},
|
||||||
}
|
}
|
||||||
if diff := cmpDiff(got, want); diff != "" {
|
if diff := cmpDiff(got, want); diff != "" {
|
||||||
t.Errorf("SetSpanAttributesOnStart: -got +want %s", diff)
|
t.Errorf("SetSpanAttributesOnStart: -got +want %s", diff)
|
||||||
@ -667,7 +667,7 @@ func TestEvents(t *testing.T) {
|
|||||||
{Name: "bar", Attributes: []attribute.KeyValue{k2v2, k3v3}},
|
{Name: "bar", Attributes: []attribute.KeyValue{k2v2, k3v3}},
|
||||||
},
|
},
|
||||||
spanKind: trace.SpanKindInternal,
|
spanKind: trace.SpanKindInternal,
|
||||||
instrumentationLibrary: instrumentation.Library{Name: "Events"},
|
instrumentationScope: instrumentation.Scope{Name: "Events"},
|
||||||
}
|
}
|
||||||
if diff := cmpDiff(got, want); diff != "" {
|
if diff := cmpDiff(got, want); diff != "" {
|
||||||
t.Errorf("Message Events: -got +want %s", diff)
|
t.Errorf("Message Events: -got +want %s", diff)
|
||||||
@ -719,7 +719,7 @@ func TestEventsOverLimit(t *testing.T) {
|
|||||||
},
|
},
|
||||||
droppedEventCount: 2,
|
droppedEventCount: 2,
|
||||||
spanKind: trace.SpanKindInternal,
|
spanKind: trace.SpanKindInternal,
|
||||||
instrumentationLibrary: instrumentation.Library{Name: "EventsOverLimit"},
|
instrumentationScope: instrumentation.Scope{Name: "EventsOverLimit"},
|
||||||
}
|
}
|
||||||
if diff := cmpDiff(got, want); diff != "" {
|
if diff := cmpDiff(got, want); diff != "" {
|
||||||
t.Errorf("Message Event over limit: -got +want %s", diff)
|
t.Errorf("Message Event over limit: -got +want %s", diff)
|
||||||
@ -757,7 +757,7 @@ func TestLinks(t *testing.T) {
|
|||||||
name: "span0",
|
name: "span0",
|
||||||
links: []Link{{l1.SpanContext, l1.Attributes, 0}, {l2.SpanContext, l2.Attributes, 0}},
|
links: []Link{{l1.SpanContext, l1.Attributes, 0}, {l2.SpanContext, l2.Attributes, 0}},
|
||||||
spanKind: trace.SpanKindInternal,
|
spanKind: trace.SpanKindInternal,
|
||||||
instrumentationLibrary: instrumentation.Library{Name: "Links"},
|
instrumentationScope: instrumentation.Scope{Name: "Links"},
|
||||||
}
|
}
|
||||||
if diff := cmpDiff(got, want); diff != "" {
|
if diff := cmpDiff(got, want); diff != "" {
|
||||||
t.Errorf("Link: -got +want %s", diff)
|
t.Errorf("Link: -got +want %s", diff)
|
||||||
@ -813,7 +813,7 @@ func TestLinksOverLimit(t *testing.T) {
|
|||||||
},
|
},
|
||||||
droppedLinkCount: 1,
|
droppedLinkCount: 1,
|
||||||
spanKind: trace.SpanKindInternal,
|
spanKind: trace.SpanKindInternal,
|
||||||
instrumentationLibrary: instrumentation.Library{Name: "LinksOverLimit"},
|
instrumentationScope: instrumentation.Scope{Name: "LinksOverLimit"},
|
||||||
}
|
}
|
||||||
if diff := cmpDiff(got, want); diff != "" {
|
if diff := cmpDiff(got, want); diff != "" {
|
||||||
t.Errorf("Link over limit: -got +want %s", diff)
|
t.Errorf("Link over limit: -got +want %s", diff)
|
||||||
@ -861,7 +861,7 @@ func TestSetSpanStatus(t *testing.T) {
|
|||||||
Code: codes.Error,
|
Code: codes.Error,
|
||||||
Description: "Error",
|
Description: "Error",
|
||||||
},
|
},
|
||||||
instrumentationLibrary: instrumentation.Library{Name: "SpanStatus"},
|
instrumentationScope: instrumentation.Scope{Name: "SpanStatus"},
|
||||||
}
|
}
|
||||||
if diff := cmpDiff(got, want); diff != "" {
|
if diff := cmpDiff(got, want); diff != "" {
|
||||||
t.Errorf("SetSpanStatus: -got +want %s", diff)
|
t.Errorf("SetSpanStatus: -got +want %s", diff)
|
||||||
@ -891,7 +891,7 @@ func TestSetSpanStatusWithoutMessageWhenStatusIsNotError(t *testing.T) {
|
|||||||
Code: codes.Ok,
|
Code: codes.Ok,
|
||||||
Description: "",
|
Description: "",
|
||||||
},
|
},
|
||||||
instrumentationLibrary: instrumentation.Library{Name: "SpanStatus"},
|
instrumentationScope: instrumentation.Scope{Name: "SpanStatus"},
|
||||||
}
|
}
|
||||||
if diff := cmpDiff(got, want); diff != "" {
|
if diff := cmpDiff(got, want); diff != "" {
|
||||||
t.Errorf("SetSpanStatus: -got +want %s", diff)
|
t.Errorf("SetSpanStatus: -got +want %s", diff)
|
||||||
@ -1230,7 +1230,7 @@ func TestRecordError(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
instrumentationLibrary: instrumentation.Library{Name: "RecordError"},
|
instrumentationScope: instrumentation.Scope{Name: "RecordError"},
|
||||||
}
|
}
|
||||||
if diff := cmpDiff(got, want); diff != "" {
|
if diff := cmpDiff(got, want); diff != "" {
|
||||||
t.Errorf("SpanErrorOptions: -got +want %s", diff)
|
t.Errorf("SpanErrorOptions: -got +want %s", diff)
|
||||||
@ -1274,7 +1274,7 @@ func TestRecordErrorWithStackTrace(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
instrumentationLibrary: instrumentation.Library{Name: "RecordError"},
|
instrumentationScope: instrumentation.Scope{Name: "RecordError"},
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.Equal(t, got.spanContext, want.spanContext)
|
assert.Equal(t, got.spanContext, want.spanContext)
|
||||||
@ -1314,7 +1314,7 @@ func TestRecordErrorNil(t *testing.T) {
|
|||||||
Code: codes.Unset,
|
Code: codes.Unset,
|
||||||
Description: "",
|
Description: "",
|
||||||
},
|
},
|
||||||
instrumentationLibrary: instrumentation.Library{Name: "RecordErrorNil"},
|
instrumentationScope: instrumentation.Scope{Name: "RecordErrorNil"},
|
||||||
}
|
}
|
||||||
if diff := cmpDiff(got, want); diff != "" {
|
if diff := cmpDiff(got, want); diff != "" {
|
||||||
t.Errorf("SpanErrorOptions: -got +want %s", diff)
|
t.Errorf("SpanErrorOptions: -got +want %s", diff)
|
||||||
@ -1430,7 +1430,7 @@ func TestWithResource(t *testing.T) {
|
|||||||
},
|
},
|
||||||
spanKind: trace.SpanKindInternal,
|
spanKind: trace.SpanKindInternal,
|
||||||
resource: tc.want,
|
resource: tc.want,
|
||||||
instrumentationLibrary: instrumentation.Library{Name: "WithResource"},
|
instrumentationScope: instrumentation.Scope{Name: "WithResource"},
|
||||||
}
|
}
|
||||||
if diff := cmpDiff(got, want); diff != "" {
|
if diff := cmpDiff(got, want); diff != "" {
|
||||||
t.Errorf("WithResource:\n -got +want %s", diff)
|
t.Errorf("WithResource:\n -got +want %s", diff)
|
||||||
@ -1463,7 +1463,7 @@ func TestWithInstrumentationVersionAndSchema(t *testing.T) {
|
|||||||
parent: sc.WithRemote(true),
|
parent: sc.WithRemote(true),
|
||||||
name: "span0",
|
name: "span0",
|
||||||
spanKind: trace.SpanKindInternal,
|
spanKind: trace.SpanKindInternal,
|
||||||
instrumentationLibrary: instrumentation.Library{
|
instrumentationScope: instrumentation.Scope{
|
||||||
Name: "WithInstrumentationVersion",
|
Name: "WithInstrumentationVersion",
|
||||||
Version: "v0.1.0",
|
Version: "v0.1.0",
|
||||||
SchemaURL: "https://opentelemetry.io/schemas/1.2.0",
|
SchemaURL: "https://opentelemetry.io/schemas/1.2.0",
|
||||||
@ -1572,6 +1572,8 @@ func TestReadOnlySpan(t *testing.T) {
|
|||||||
assert.Equal(t, "", ro.Status().Description)
|
assert.Equal(t, "", ro.Status().Description)
|
||||||
assert.Equal(t, "ReadOnlySpan", ro.InstrumentationLibrary().Name)
|
assert.Equal(t, "ReadOnlySpan", ro.InstrumentationLibrary().Name)
|
||||||
assert.Equal(t, "3", ro.InstrumentationLibrary().Version)
|
assert.Equal(t, "3", ro.InstrumentationLibrary().Version)
|
||||||
|
assert.Equal(t, "ReadOnlySpan", ro.InstrumentationScope().Name)
|
||||||
|
assert.Equal(t, "3", ro.InstrumentationScope().Version)
|
||||||
assert.Equal(t, kv.Key, ro.Resource().Attributes()[0].Key)
|
assert.Equal(t, kv.Key, ro.Resource().Attributes()[0].Key)
|
||||||
assert.Equal(t, kv.Value, ro.Resource().Attributes()[0].Value)
|
assert.Equal(t, kv.Value, ro.Resource().Attributes()[0].Value)
|
||||||
|
|
||||||
@ -1696,7 +1698,7 @@ func TestAddEventsWithMoreAttributesThanLimit(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
spanKind: trace.SpanKindInternal,
|
spanKind: trace.SpanKindInternal,
|
||||||
instrumentationLibrary: instrumentation.Library{Name: "AddSpanEventWithOverLimitedAttributes"},
|
instrumentationScope: instrumentation.Scope{Name: "AddSpanEventWithOverLimitedAttributes"},
|
||||||
}
|
}
|
||||||
if diff := cmpDiff(got, want); diff != "" {
|
if diff := cmpDiff(got, want); diff != "" {
|
||||||
t.Errorf("SetSpanAttributesOverLimit: -got +want %s", diff)
|
t.Errorf("SetSpanAttributesOverLimit: -got +want %s", diff)
|
||||||
@ -1751,7 +1753,7 @@ func TestAddLinksWithMoreAttributesThanLimit(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
spanKind: trace.SpanKindInternal,
|
spanKind: trace.SpanKindInternal,
|
||||||
instrumentationLibrary: instrumentation.Library{Name: "Links"},
|
instrumentationScope: instrumentation.Scope{Name: "Links"},
|
||||||
}
|
}
|
||||||
if diff := cmpDiff(got, want); diff != "" {
|
if diff := cmpDiff(got, want); diff != "" {
|
||||||
t.Errorf("Link: -got +want %s", diff)
|
t.Errorf("Link: -got +want %s", diff)
|
||||||
|
@ -24,7 +24,7 @@ import (
|
|||||||
|
|
||||||
type tracer struct {
|
type tracer struct {
|
||||||
provider *TracerProvider
|
provider *TracerProvider
|
||||||
instrumentationLibrary instrumentation.Library
|
instrumentationScope instrumentation.Scope
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ trace.Tracer = &tracer{}
|
var _ trace.Tracer = &tracer{}
|
||||||
|
@ -96,7 +96,7 @@ func SpanStubFromReadOnlySpan(ro tracesdk.ReadOnlySpan) SpanStub {
|
|||||||
DroppedLinks: ro.DroppedLinks(),
|
DroppedLinks: ro.DroppedLinks(),
|
||||||
ChildSpanCount: ro.ChildSpanCount(),
|
ChildSpanCount: ro.ChildSpanCount(),
|
||||||
Resource: ro.Resource(),
|
Resource: ro.Resource(),
|
||||||
InstrumentationLibrary: ro.InstrumentationLibrary(),
|
InstrumentationLibrary: ro.InstrumentationScope(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ func (s SpanStub) Snapshot() tracesdk.ReadOnlySpan {
|
|||||||
droppedLinks: s.DroppedLinks,
|
droppedLinks: s.DroppedLinks,
|
||||||
childSpanCount: s.ChildSpanCount,
|
childSpanCount: s.ChildSpanCount,
|
||||||
resource: s.Resource,
|
resource: s.Resource,
|
||||||
instrumentationLibrary: s.InstrumentationLibrary,
|
instrumentationScope: s.InstrumentationLibrary,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ type spanSnapshot struct {
|
|||||||
droppedLinks int
|
droppedLinks int
|
||||||
childSpanCount int
|
childSpanCount int
|
||||||
resource *resource.Resource
|
resource *resource.Resource
|
||||||
instrumentationLibrary instrumentation.Library
|
instrumentationScope instrumentation.Scope
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s spanSnapshot) Name() string { return s.name }
|
func (s spanSnapshot) Name() string { return s.name }
|
||||||
@ -159,6 +159,9 @@ func (s spanSnapshot) DroppedLinks() int { return s.droppedLinks
|
|||||||
func (s spanSnapshot) DroppedEvents() int { return s.droppedEvents }
|
func (s spanSnapshot) DroppedEvents() int { return s.droppedEvents }
|
||||||
func (s spanSnapshot) ChildSpanCount() int { return s.childSpanCount }
|
func (s spanSnapshot) ChildSpanCount() int { return s.childSpanCount }
|
||||||
func (s spanSnapshot) Resource() *resource.Resource { return s.resource }
|
func (s spanSnapshot) Resource() *resource.Resource { return s.resource }
|
||||||
func (s spanSnapshot) InstrumentationLibrary() instrumentation.Library {
|
func (s spanSnapshot) InstrumentationScope() instrumentation.Scope {
|
||||||
return s.instrumentationLibrary
|
return s.instrumentationScope
|
||||||
|
}
|
||||||
|
func (s spanSnapshot) InstrumentationLibrary() instrumentation.Library {
|
||||||
|
return s.instrumentationScope
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user