mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2024-12-26 21:05:00 +02:00
8b510c36ed
This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [github.com/stretchr/testify](https://redirect.github.com/stretchr/testify) | `v1.9.0` -> `v1.10.0` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fstretchr%2ftestify/v1.10.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fstretchr%2ftestify/v1.10.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fstretchr%2ftestify/v1.9.0/v1.10.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fstretchr%2ftestify/v1.9.0/v1.10.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>stretchr/testify (github.com/stretchr/testify)</summary> ### [`v1.10.0`](https://redirect.github.com/stretchr/testify/releases/tag/v1.10.0) [Compare Source](https://redirect.github.com/stretchr/testify/compare/v1.9.0...v1.10.0) #### What's Changed ##### Functional Changes - Add PanicAssertionFunc by [@​fahimbagar](https://redirect.github.com/fahimbagar) in [https://github.com/stretchr/testify/pull/1337](https://redirect.github.com/stretchr/testify/pull/1337) - assert: deprecate CompareType by [@​dolmen](https://redirect.github.com/dolmen) in [https://github.com/stretchr/testify/pull/1566](https://redirect.github.com/stretchr/testify/pull/1566) - assert: make YAML dependency pluggable via build tags by [@​dolmen](https://redirect.github.com/dolmen) in [https://github.com/stretchr/testify/pull/1579](https://redirect.github.com/stretchr/testify/pull/1579) - assert: new assertion NotElementsMatch by [@​hendrywiranto](https://redirect.github.com/hendrywiranto) in [https://github.com/stretchr/testify/pull/1600](https://redirect.github.com/stretchr/testify/pull/1600) - mock: in order mock calls by [@​ReyOrtiz](https://redirect.github.com/ReyOrtiz) in [https://github.com/stretchr/testify/pull/1637](https://redirect.github.com/stretchr/testify/pull/1637) - Add assertion for NotErrorAs by [@​palsivertsen](https://redirect.github.com/palsivertsen) in [https://github.com/stretchr/testify/pull/1129](https://redirect.github.com/stretchr/testify/pull/1129) - Record Return Arguments of a Call by [@​jayd3e](https://redirect.github.com/jayd3e) in [https://github.com/stretchr/testify/pull/1636](https://redirect.github.com/stretchr/testify/pull/1636) - assert.EqualExportedValues: accepts everything by [@​redachl](https://redirect.github.com/redachl) in [https://github.com/stretchr/testify/pull/1586](https://redirect.github.com/stretchr/testify/pull/1586) ##### Fixes - assert: make tHelper a type alias by [@​dolmen](https://redirect.github.com/dolmen) in [https://github.com/stretchr/testify/pull/1562](https://redirect.github.com/stretchr/testify/pull/1562) - Do not get argument again unnecessarily in Arguments.Error() by [@​TomWright](https://redirect.github.com/TomWright) in [https://github.com/stretchr/testify/pull/820](https://redirect.github.com/stretchr/testify/pull/820) - Fix time.Time compare by [@​myxo](https://redirect.github.com/myxo) in [https://github.com/stretchr/testify/pull/1582](https://redirect.github.com/stretchr/testify/pull/1582) - assert.Regexp: handle \[]byte array properly by [@​kevinburkesegment](https://redirect.github.com/kevinburkesegment) in [https://github.com/stretchr/testify/pull/1587](https://redirect.github.com/stretchr/testify/pull/1587) - assert: collect.FailNow() should not panic by [@​marshall-lee](https://redirect.github.com/marshall-lee) in [https://github.com/stretchr/testify/pull/1481](https://redirect.github.com/stretchr/testify/pull/1481) - mock: simplify implementation of FunctionalOptions by [@​dolmen](https://redirect.github.com/dolmen) in [https://github.com/stretchr/testify/pull/1571](https://redirect.github.com/stretchr/testify/pull/1571) - mock: caller information for unexpected method call by [@​spirin](https://redirect.github.com/spirin) in [https://github.com/stretchr/testify/pull/1644](https://redirect.github.com/stretchr/testify/pull/1644) - suite: fix test failures by [@​stevenh](https://redirect.github.com/stevenh) in [https://github.com/stretchr/testify/pull/1421](https://redirect.github.com/stretchr/testify/pull/1421) - Fix issue [#​1662](https://redirect.github.com/stretchr/testify/issues/1662) (comparing infs should fail) by [@​ybrustin](https://redirect.github.com/ybrustin) in [https://github.com/stretchr/testify/pull/1663](https://redirect.github.com/stretchr/testify/pull/1663) - NotSame should fail if args are not pointers [#​1661](https://redirect.github.com/stretchr/testify/issues/1661) by [@​sikehish](https://redirect.github.com/sikehish) in [https://github.com/stretchr/testify/pull/1664](https://redirect.github.com/stretchr/testify/pull/1664) - Increase timeouts in Test_Mock_Called_blocks to reduce flakiness in CI by [@​sikehish](https://redirect.github.com/sikehish) in [https://github.com/stretchr/testify/pull/1667](https://redirect.github.com/stretchr/testify/pull/1667) - fix: compare functional option names for indirect calls by [@​arjun-1](https://redirect.github.com/arjun-1) in [https://github.com/stretchr/testify/pull/1626](https://redirect.github.com/stretchr/testify/pull/1626) ##### Documantation, Build & CI - .gitignore: ignore "go test -c" binaries by [@​dolmen](https://redirect.github.com/dolmen) in [https://github.com/stretchr/testify/pull/1565](https://redirect.github.com/stretchr/testify/pull/1565) - mock: improve doc by [@​dolmen](https://redirect.github.com/dolmen) in [https://github.com/stretchr/testify/pull/1570](https://redirect.github.com/stretchr/testify/pull/1570) - mock: fix FunctionalOptions docs by [@​snirye](https://redirect.github.com/snirye) in [https://github.com/stretchr/testify/pull/1433](https://redirect.github.com/stretchr/testify/pull/1433) - README: link out to the excellent testifylint by [@​brackendawson](https://redirect.github.com/brackendawson) in [https://github.com/stretchr/testify/pull/1568](https://redirect.github.com/stretchr/testify/pull/1568) - assert: fix typo in comment by [@​JohnEndson](https://redirect.github.com/JohnEndson) in [https://github.com/stretchr/testify/pull/1580](https://redirect.github.com/stretchr/testify/pull/1580) - Correct the EventuallyWithT and EventuallyWithTf example by [@​JonCrowther](https://redirect.github.com/JonCrowther) in [https://github.com/stretchr/testify/pull/1588](https://redirect.github.com/stretchr/testify/pull/1588) - CI: bump softprops/action-gh-release from 1 to 2 by [@​dependabot](https://redirect.github.com/dependabot) in [https://github.com/stretchr/testify/pull/1575](https://redirect.github.com/stretchr/testify/pull/1575) - mock: document more alternatives to deprecated AnythingOfTypeArgument by [@​dolmen](https://redirect.github.com/dolmen) in [https://github.com/stretchr/testify/pull/1569](https://redirect.github.com/stretchr/testify/pull/1569) - assert: Correctly document EqualValues behavior by [@​brackendawson](https://redirect.github.com/brackendawson) in [https://github.com/stretchr/testify/pull/1593](https://redirect.github.com/stretchr/testify/pull/1593) - fix: grammar in godoc by [@​miparnisari](https://redirect.github.com/miparnisari) in [https://github.com/stretchr/testify/pull/1607](https://redirect.github.com/stretchr/testify/pull/1607) - .github/workflows: Run tests for Go 1.22 by [@​HaraldNordgren](https://redirect.github.com/HaraldNordgren) in [https://github.com/stretchr/testify/pull/1629](https://redirect.github.com/stretchr/testify/pull/1629) - Document suite's lack of support for t.Parallel by [@​brackendawson](https://redirect.github.com/brackendawson) in [https://github.com/stretchr/testify/pull/1645](https://redirect.github.com/stretchr/testify/pull/1645) - assert: fix typos in comments by [@​alexandear](https://redirect.github.com/alexandear) in [https://github.com/stretchr/testify/pull/1650](https://redirect.github.com/stretchr/testify/pull/1650) - mock: fix doc comment for NotBefore by [@​alexandear](https://redirect.github.com/alexandear) in [https://github.com/stretchr/testify/pull/1651](https://redirect.github.com/stretchr/testify/pull/1651) - Generate better comments for require package by [@​Neokil](https://redirect.github.com/Neokil) in [https://github.com/stretchr/testify/pull/1610](https://redirect.github.com/stretchr/testify/pull/1610) - README: replace Testify V2 notice with [@​dolmen](https://redirect.github.com/dolmen)'s V2 manifesto by [@​hendrywiranto](https://redirect.github.com/hendrywiranto) in [https://github.com/stretchr/testify/pull/1518](https://redirect.github.com/stretchr/testify/pull/1518) #### New Contributors - [@​fahimbagar](https://redirect.github.com/fahimbagar) made their first contribution in [https://github.com/stretchr/testify/pull/1337](https://redirect.github.com/stretchr/testify/pull/1337) - [@​TomWright](https://redirect.github.com/TomWright) made their first contribution in [https://github.com/stretchr/testify/pull/820](https://redirect.github.com/stretchr/testify/pull/820) - [@​snirye](https://redirect.github.com/snirye) made their first contribution in [https://github.com/stretchr/testify/pull/1433](https://redirect.github.com/stretchr/testify/pull/1433) - [@​myxo](https://redirect.github.com/myxo) made their first contribution in [https://github.com/stretchr/testify/pull/1582](https://redirect.github.com/stretchr/testify/pull/1582) - [@​JohnEndson](https://redirect.github.com/JohnEndson) made their first contribution in [https://github.com/stretchr/testify/pull/1580](https://redirect.github.com/stretchr/testify/pull/1580) - [@​JonCrowther](https://redirect.github.com/JonCrowther) made their first contribution in [https://github.com/stretchr/testify/pull/1588](https://redirect.github.com/stretchr/testify/pull/1588) - [@​miparnisari](https://redirect.github.com/miparnisari) made their first contribution in [https://github.com/stretchr/testify/pull/1607](https://redirect.github.com/stretchr/testify/pull/1607) - [@​marshall-lee](https://redirect.github.com/marshall-lee) made their first contribution in [https://github.com/stretchr/testify/pull/1481](https://redirect.github.com/stretchr/testify/pull/1481) - [@​spirin](https://redirect.github.com/spirin) made their first contribution in [https://github.com/stretchr/testify/pull/1644](https://redirect.github.com/stretchr/testify/pull/1644) - [@​ReyOrtiz](https://redirect.github.com/ReyOrtiz) made their first contribution in [https://github.com/stretchr/testify/pull/1637](https://redirect.github.com/stretchr/testify/pull/1637) - [@​stevenh](https://redirect.github.com/stevenh) made their first contribution in [https://github.com/stretchr/testify/pull/1421](https://redirect.github.com/stretchr/testify/pull/1421) - [@​jayd3e](https://redirect.github.com/jayd3e) made their first contribution in [https://github.com/stretchr/testify/pull/1636](https://redirect.github.com/stretchr/testify/pull/1636) - [@​Neokil](https://redirect.github.com/Neokil) made their first contribution in [https://github.com/stretchr/testify/pull/1610](https://redirect.github.com/stretchr/testify/pull/1610) - [@​redachl](https://redirect.github.com/redachl) made their first contribution in [https://github.com/stretchr/testify/pull/1586](https://redirect.github.com/stretchr/testify/pull/1586) - [@​ybrustin](https://redirect.github.com/ybrustin) made their first contribution in [https://github.com/stretchr/testify/pull/1663](https://redirect.github.com/stretchr/testify/pull/1663) - [@​sikehish](https://redirect.github.com/sikehish) made their first contribution in [https://github.com/stretchr/testify/pull/1664](https://redirect.github.com/stretchr/testify/pull/1664) - [@​arjun-1](https://redirect.github.com/arjun-1) made their first contribution in [https://github.com/stretchr/testify/pull/1626](https://redirect.github.com/stretchr/testify/pull/1626) **Full Changelog**: https://github.com/stretchr/testify/compare/v1.9.0...v1.10.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/open-telemetry/opentelemetry-go). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4xOS4wIiwidXBkYXRlZEluVmVyIjoiMzkuMTkuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiU2tpcCBDaGFuZ2Vsb2ciLCJkZXBlbmRlbmNpZXMiXX0=--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Tyler Yahn <codingalias@gmail.com>
294 lines
8.0 KiB
Go
294 lines
8.0 KiB
Go
// Copyright The OpenTelemetry Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package global
|
|
|
|
import (
|
|
"context"
|
|
"sync/atomic"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"go.opentelemetry.io/auto/sdk"
|
|
"go.opentelemetry.io/otel/attribute"
|
|
"go.opentelemetry.io/otel/trace"
|
|
"go.opentelemetry.io/otel/trace/embedded"
|
|
"go.opentelemetry.io/otel/trace/noop"
|
|
)
|
|
|
|
type fnTracerProvider struct {
|
|
embedded.TracerProvider
|
|
|
|
tracer func(string, ...trace.TracerOption) trace.Tracer
|
|
}
|
|
|
|
func (fn fnTracerProvider) Tracer(instrumentationName string, opts ...trace.TracerOption) trace.Tracer {
|
|
return fn.tracer(instrumentationName, opts...)
|
|
}
|
|
|
|
type fnTracer struct {
|
|
embedded.Tracer
|
|
|
|
start func(ctx context.Context, spanName string, opts ...trace.SpanStartOption) (context.Context, trace.Span)
|
|
}
|
|
|
|
func (fn fnTracer) Start(ctx context.Context, spanName string, opts ...trace.SpanStartOption) (context.Context, trace.Span) {
|
|
return fn.start(ctx, spanName, opts...)
|
|
}
|
|
|
|
func TestTraceProviderDelegation(t *testing.T) {
|
|
ResetForTest(t)
|
|
|
|
// Map of tracers to expected span names.
|
|
expected := map[string][]string{
|
|
"pre": {"span2"},
|
|
"post": {"span3"},
|
|
"fromSpan": {"span4"},
|
|
}
|
|
|
|
ctx := context.Background()
|
|
gtp := TracerProvider()
|
|
tracer1 := gtp.Tracer("pre")
|
|
// This is started before an SDK was registered and should be dropped.
|
|
_, span1 := tracer1.Start(ctx, "span1")
|
|
|
|
SetTracerProvider(fnTracerProvider{
|
|
tracer: func(name string, opts ...trace.TracerOption) trace.Tracer {
|
|
spans, ok := expected[name]
|
|
assert.Truef(t, ok, "invalid tracer: %s", name)
|
|
return fnTracer{
|
|
start: func(ctx context.Context, spanName string, opts ...trace.SpanStartOption) (context.Context, trace.Span) {
|
|
if ok {
|
|
if len(spans) == 0 {
|
|
t.Errorf("unexpected span: %s", spanName)
|
|
} else {
|
|
var want string
|
|
want, spans = spans[0], spans[1:]
|
|
assert.Equal(t, want, spanName)
|
|
}
|
|
}
|
|
return noop.NewTracerProvider().Tracer(name).Start(ctx, spanName)
|
|
},
|
|
}
|
|
},
|
|
})
|
|
|
|
// This span was started before initialization, it is expected to be dropped.
|
|
span1.End()
|
|
|
|
// The existing Tracer should have been configured to now use the configured SDK.
|
|
_, span2 := tracer1.Start(ctx, "span2")
|
|
span2.End()
|
|
|
|
// The global TracerProvider should now create Tracers that also use the newly configured SDK.
|
|
tracer2 := gtp.Tracer("post")
|
|
_, span3 := tracer2.Start(ctx, "span3")
|
|
span3.End()
|
|
|
|
// The noop-span should still provide access to a usable TracerProvider.
|
|
_, span4 := span1.TracerProvider().Tracer("fromSpan").Start(ctx, "span4")
|
|
span4.End()
|
|
}
|
|
|
|
func TestTraceProviderDelegates(t *testing.T) {
|
|
ResetForTest(t)
|
|
|
|
// Retrieve the placeholder TracerProvider.
|
|
gtp := TracerProvider()
|
|
|
|
// Configure it with a spy.
|
|
called := false
|
|
SetTracerProvider(fnTracerProvider{
|
|
tracer: func(name string, opts ...trace.TracerOption) trace.Tracer {
|
|
called = true
|
|
assert.Equal(t, "abc", name)
|
|
return noop.NewTracerProvider().Tracer("")
|
|
},
|
|
})
|
|
|
|
gtp.Tracer("abc", trace.WithInstrumentationVersion("xyz"))
|
|
assert.True(t, called, "expected configured TraceProvider to be called")
|
|
}
|
|
|
|
func TestTraceProviderDelegatesConcurrentSafe(t *testing.T) {
|
|
ResetForTest(t)
|
|
|
|
// Retrieve the placeholder TracerProvider.
|
|
gtp := TracerProvider()
|
|
|
|
done := make(chan struct{})
|
|
quit := make(chan struct{})
|
|
go func() {
|
|
defer close(done)
|
|
for {
|
|
select {
|
|
case <-time.After(1 * time.Millisecond):
|
|
gtp.Tracer("abc", trace.WithInstrumentationVersion("xyz"))
|
|
case <-quit:
|
|
return
|
|
}
|
|
}
|
|
}()
|
|
|
|
// Wait for the goroutine to make some calls before installing the provider.
|
|
<-time.After(100 * time.Millisecond)
|
|
|
|
// Configure it with a spy.
|
|
called := int32(0)
|
|
SetTracerProvider(fnTracerProvider{
|
|
tracer: func(name string, opts ...trace.TracerOption) trace.Tracer {
|
|
newVal := atomic.AddInt32(&called, 1)
|
|
assert.Equal(t, "abc", name)
|
|
if newVal == 10 {
|
|
// Signal the goroutine to finish.
|
|
close(quit)
|
|
}
|
|
return noop.NewTracerProvider().Tracer("")
|
|
},
|
|
})
|
|
|
|
// Wait for the go routine to finish
|
|
<-done
|
|
|
|
assert.LessOrEqual(t, int32(10), atomic.LoadInt32(&called), "expected configured TraceProvider to be called")
|
|
}
|
|
|
|
func TestTracerDelegatesConcurrentSafe(t *testing.T) {
|
|
ResetForTest(t)
|
|
|
|
// Retrieve the placeholder TracerProvider.
|
|
gtp := TracerProvider()
|
|
tracer := gtp.Tracer("abc", trace.WithInstrumentationVersion("xyz"))
|
|
|
|
done := make(chan struct{})
|
|
quit := make(chan struct{})
|
|
go func() {
|
|
defer close(done)
|
|
for {
|
|
select {
|
|
case <-time.After(1 * time.Millisecond):
|
|
tracer.Start(context.Background(), "name")
|
|
case <-quit:
|
|
return
|
|
}
|
|
}
|
|
}()
|
|
|
|
// Wait for the goroutine to make some calls before installing the provider.
|
|
<-time.After(100 * time.Millisecond)
|
|
|
|
// Configure it with a spy.
|
|
called := int32(0)
|
|
SetTracerProvider(fnTracerProvider{
|
|
tracer: func(name string, opts ...trace.TracerOption) trace.Tracer {
|
|
assert.Equal(t, "abc", name)
|
|
return fnTracer{
|
|
start: func(ctx context.Context, spanName string, opts ...trace.SpanStartOption) (context.Context, trace.Span) {
|
|
newVal := atomic.AddInt32(&called, 1)
|
|
assert.Equal(t, "name", spanName)
|
|
if newVal == 10 {
|
|
// Signal the goroutine to finish.
|
|
close(quit)
|
|
}
|
|
return noop.NewTracerProvider().Tracer("").Start(ctx, spanName)
|
|
},
|
|
}
|
|
},
|
|
})
|
|
|
|
// Wait for the go routine to finish
|
|
<-done
|
|
|
|
assert.LessOrEqual(t, int32(10), atomic.LoadInt32(&called), "expected configured TraceProvider to be called")
|
|
}
|
|
|
|
func TestTraceProviderDelegatesSameInstance(t *testing.T) {
|
|
ResetForTest(t)
|
|
|
|
// Retrieve the placeholder TracerProvider.
|
|
gtp := TracerProvider()
|
|
tracer := gtp.Tracer("abc", trace.WithInstrumentationVersion("xyz"))
|
|
assert.Same(t, tracer, gtp.Tracer("abc", trace.WithInstrumentationVersion("xyz")))
|
|
assert.Same(t, tracer, gtp.Tracer("abc", trace.WithInstrumentationVersion("xyz")))
|
|
|
|
SetTracerProvider(fnTracerProvider{
|
|
tracer: func(name string, opts ...trace.TracerOption) trace.Tracer {
|
|
return noop.NewTracerProvider().Tracer("")
|
|
},
|
|
})
|
|
|
|
assert.NotEqual(t, tracer, gtp.Tracer("abc", trace.WithInstrumentationVersion("xyz")))
|
|
}
|
|
|
|
func TestSpanContextPropagatedWithNonRecordingSpan(t *testing.T) {
|
|
ResetForTest(t)
|
|
|
|
sc := trace.NewSpanContext(trace.SpanContextConfig{
|
|
TraceID: [16]byte{0x01},
|
|
SpanID: [8]byte{0x01},
|
|
TraceFlags: trace.FlagsSampled,
|
|
Remote: true,
|
|
})
|
|
ctx := trace.ContextWithSpanContext(context.Background(), sc)
|
|
_, span := TracerProvider().Tracer("test").Start(ctx, "test")
|
|
|
|
assert.Equal(t, sc, span.SpanContext())
|
|
assert.False(t, span.IsRecording())
|
|
}
|
|
|
|
func TestTracerIdentity(t *testing.T) {
|
|
type id struct{ name, ver, url, attr string }
|
|
|
|
ids := []id{
|
|
{"name-a", "version-a", "url-a", ""},
|
|
{"name-a", "version-a", "url-a", "attr"},
|
|
{"name-a", "version-a", "url-b", ""},
|
|
{"name-a", "version-b", "url-a", ""},
|
|
{"name-a", "version-b", "url-b", ""},
|
|
{"name-b", "version-a", "url-a", ""},
|
|
{"name-b", "version-a", "url-b", ""},
|
|
{"name-b", "version-b", "url-a", ""},
|
|
{"name-b", "version-b", "url-b", ""},
|
|
}
|
|
|
|
provider := &tracerProvider{}
|
|
newTracer := func(i id) trace.Tracer {
|
|
return provider.Tracer(
|
|
i.name,
|
|
trace.WithInstrumentationVersion(i.ver),
|
|
trace.WithSchemaURL(i.url),
|
|
trace.WithInstrumentationAttributes(attribute.String("key", i.attr)),
|
|
)
|
|
}
|
|
|
|
for i, id0 := range ids {
|
|
for j, id1 := range ids {
|
|
l0, l1 := newTracer(id0), newTracer(id1)
|
|
|
|
if i == j {
|
|
assert.Samef(t, l0, l1, "Tracer(%v) != Tracer(%v)", id0, id1)
|
|
} else {
|
|
assert.NotSamef(t, l0, l1, "Tracer(%v) == Tracer(%v)", id0, id1)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestNewSpanType(t *testing.T) {
|
|
tracer := new(tracer)
|
|
ctx := context.Background()
|
|
_, got := tracer.newSpan(ctx, autoInstEnabled, "", nil)
|
|
assert.IsType(t, nonRecordingSpan{}, got, "default span type")
|
|
|
|
orig := *autoInstEnabled
|
|
*autoInstEnabled = true
|
|
t.Cleanup(func() { *autoInstEnabled = orig })
|
|
|
|
_, got = tracer.newSpan(ctx, autoInstEnabled, "", nil)
|
|
autoTracer := sdk.TracerProvider().Tracer("")
|
|
_, span := autoTracer.Start(ctx, "")
|
|
assert.IsType(t, span, got, "auto span type")
|
|
}
|