1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-01-01 22:09:57 +02:00

Move SpanContext from core package into trace

This commit is contained in:
tensorchen 2020-05-02 20:17:11 +08:00
parent 34bd998963
commit c6c155de6f
47 changed files with 392 additions and 403 deletions

View File

@ -23,7 +23,6 @@ import (
"google.golang.org/grpc/codes"
"go.opentelemetry.io/otel/api/core"
"go.opentelemetry.io/otel/api/key"
"go.opentelemetry.io/otel/api/trace"
"go.opentelemetry.io/otel/internal/matchers"
@ -79,7 +78,7 @@ func (h *Harness) TestTracer(subjectFactory func() trace.Tracer) {
ctx, span := subject.Start(context.Background(), "test")
e.Expect(span).NotToBeNil()
e.Expect(span.SpanContext()).NotToEqual(core.EmptySpanContext())
e.Expect(span.SpanContext()).NotToEqual(trace.EmptySpanContext())
e.Expect(trace.SpanFromContext(ctx)).ToEqual(span)
})

View File

@ -30,10 +30,10 @@ type alwaysOffSampler struct{}
// It always returns a Decision with Sampled value set to false
// and with Attributes set to an empty slice.
func (ns alwaysOffSampler) ShouldSample(
_ core.SpanContext,
_ SpanContext,
_ bool,
_ core.TraceID,
_ core.SpanID,
_ TraceID,
_ SpanID,
_ string,
_ SpanKind,
_ []core.KeyValue,

View File

@ -24,7 +24,7 @@ import (
func TestNeverSamperShouldSample(t *testing.T) {
gotD := AlwaysOffSampler().ShouldSample(
core.SpanContext{}, false, core.TraceID{}, core.SpanID{}, "span", SpanKindClient, []core.KeyValue{}, []Link{})
SpanContext{}, false, TraceID{}, SpanID{}, "span", SpanKindClient, []core.KeyValue{}, []Link{})
wantD := Decision{Sampled: false}
if diff := cmp.Diff(wantD, gotD); diff != "" {
t.Errorf("Decision: +got, -want%v", diff)

View File

@ -30,10 +30,10 @@ type alwaysOnSampler struct{}
// It always returns a Decision with Sampled value set to true
// and with Attributes set to an empty slice.
func (as alwaysOnSampler) ShouldSample(
_ core.SpanContext,
_ SpanContext,
_ bool,
_ core.TraceID,
_ core.SpanID,
_ TraceID,
_ SpanID,
_ string,
_ SpanKind,
_ []core.KeyValue,

View File

@ -24,7 +24,7 @@ import (
func TestAlwaysOnSamplerShouldSample(t *testing.T) {
gotD := AlwaysOnSampler().ShouldSample(
core.SpanContext{}, false, core.TraceID{}, core.SpanID{}, "span", SpanKindClient, []core.KeyValue{}, []Link{})
SpanContext{}, false, TraceID{}, SpanID{}, "span", SpanKindClient, []core.KeyValue{}, []Link{})
wantD := Decision{Sampled: true}
if diff := cmp.Diff(wantD, gotD); diff != "" {
t.Errorf("Decision: +got, -want%v", diff)

View File

@ -105,7 +105,7 @@ type Span interface {
// SpanContext returns span context of the span. Returned SpanContext is usable
// even after the span ends.
SpanContext() core.SpanContext
SpanContext() SpanContext
// SetStatus sets the status of the span in the form of a code
// and a message. SetStatus overrides the value of previous
@ -152,7 +152,7 @@ type StartConfig struct {
// on service provider side so two traces (from Client and from Service Provider) can
// be correlated.
type Link struct {
core.SpanContext
SpanContext
Attributes []core.KeyValue
}
@ -248,7 +248,7 @@ func WithNewRoot() StartOption {
}
// LinkedTo allows instantiating a Span with initial Links.
func LinkedTo(sc core.SpanContext, attrs ...core.KeyValue) StartOption {
func LinkedTo(sc SpanContext, attrs ...core.KeyValue) StartOption {
return func(c *StartConfig) {
c.Links = append(c.Links, Link{sc, attrs})
}

View File

@ -19,7 +19,6 @@ import (
"fmt"
"strings"
"go.opentelemetry.io/otel/api/core"
"go.opentelemetry.io/otel/api/propagation"
)
@ -57,7 +56,7 @@ func (b3 B3) Inject(ctx context.Context, supplier propagation.HTTPSupplier) {
return
}
if b3.SingleHeader {
sampled := sc.TraceFlags & core.TraceFlagsSampled
sampled := sc.TraceFlags & TraceFlagsSampled
supplier.Set(B3SingleHeader,
fmt.Sprintf("%s-%s-%.1d", sc.TraceID, sc.SpanID, sampled))
} else {
@ -76,7 +75,7 @@ func (b3 B3) Inject(ctx context.Context, supplier propagation.HTTPSupplier) {
// Extract retrieves B3 Headers from the supplier
func (b3 B3) Extract(ctx context.Context, supplier propagation.HTTPSupplier) context.Context {
var sc core.SpanContext
var sc SpanContext
if b3.SingleHeader {
sc = b3.extractSingleHeader(supplier)
} else {
@ -88,84 +87,84 @@ func (b3 B3) Extract(ctx context.Context, supplier propagation.HTTPSupplier) con
return ContextWithRemoteSpanContext(ctx, sc)
}
func (b3 B3) extract(supplier propagation.HTTPSupplier) core.SpanContext {
tid, err := core.TraceIDFromHex(supplier.Get(B3TraceIDHeader))
func (b3 B3) extract(supplier propagation.HTTPSupplier) SpanContext {
tid, err := TraceIDFromHex(supplier.Get(B3TraceIDHeader))
if err != nil {
return core.EmptySpanContext()
return EmptySpanContext()
}
sid, err := core.SpanIDFromHex(supplier.Get(B3SpanIDHeader))
sid, err := SpanIDFromHex(supplier.Get(B3SpanIDHeader))
if err != nil {
return core.EmptySpanContext()
return EmptySpanContext()
}
sampled, ok := b3.extractSampledState(supplier.Get(B3SampledHeader))
if !ok {
return core.EmptySpanContext()
return EmptySpanContext()
}
debug, ok := b3.extracDebugFlag(supplier.Get(B3DebugFlagHeader))
if !ok {
return core.EmptySpanContext()
return EmptySpanContext()
}
if debug == core.TraceFlagsSampled {
sampled = core.TraceFlagsSampled
if debug == TraceFlagsSampled {
sampled = TraceFlagsSampled
}
sc := core.SpanContext{
sc := SpanContext{
TraceID: tid,
SpanID: sid,
TraceFlags: sampled,
}
if !sc.IsValid() {
return core.EmptySpanContext()
return EmptySpanContext()
}
return sc
}
func (b3 B3) extractSingleHeader(supplier propagation.HTTPSupplier) core.SpanContext {
func (b3 B3) extractSingleHeader(supplier propagation.HTTPSupplier) SpanContext {
h := supplier.Get(B3SingleHeader)
if h == "" || h == "0" {
return core.EmptySpanContext()
return EmptySpanContext()
}
sc := core.SpanContext{}
sc := SpanContext{}
parts := strings.Split(h, "-")
l := len(parts)
if l > 4 {
return core.EmptySpanContext()
return EmptySpanContext()
}
if l < 2 {
return core.EmptySpanContext()
return EmptySpanContext()
}
var err error
sc.TraceID, err = core.TraceIDFromHex(parts[0])
sc.TraceID, err = TraceIDFromHex(parts[0])
if err != nil {
return core.EmptySpanContext()
return EmptySpanContext()
}
sc.SpanID, err = core.SpanIDFromHex(parts[1])
sc.SpanID, err = SpanIDFromHex(parts[1])
if err != nil {
return core.EmptySpanContext()
return EmptySpanContext()
}
if l > 2 {
var ok bool
sc.TraceFlags, ok = b3.extractSampledState(parts[2])
if !ok {
return core.EmptySpanContext()
return EmptySpanContext()
}
}
if l == 4 {
_, err = core.SpanIDFromHex(parts[3])
_, err = SpanIDFromHex(parts[3])
if err != nil {
return core.EmptySpanContext()
return EmptySpanContext()
}
}
if !sc.IsValid() {
return core.EmptySpanContext()
return EmptySpanContext()
}
return sc
@ -177,14 +176,14 @@ func (b3 B3) extractSampledState(sampled string) (flag byte, ok bool) {
case "", "0":
return 0, true
case "1":
return core.TraceFlagsSampled, true
return TraceFlagsSampled, true
case "true":
if !b3.SingleHeader {
return core.TraceFlagsSampled, true
return TraceFlagsSampled, true
}
case "d":
if b3.SingleHeader {
return core.TraceFlagsSampled, true
return TraceFlagsSampled, true
}
}
return 0, false
@ -196,7 +195,7 @@ func (b3 B3) extracDebugFlag(debug string) (flag byte, ok bool) {
case "", "0":
return 0, true
case "1":
return core.TraceFlagsSampled, true
return TraceFlagsSampled, true
}
return 0, false
}

View File

@ -16,8 +16,6 @@ package trace
import (
"context"
"go.opentelemetry.io/otel/api/core"
)
type traceContextKeyType int
@ -43,15 +41,15 @@ func SpanFromContext(ctx context.Context) Span {
// ContextWithRemoteSpanContext creates a new context with a remote
// span context set to the passed span context.
func ContextWithRemoteSpanContext(ctx context.Context, sc core.SpanContext) context.Context {
func ContextWithRemoteSpanContext(ctx context.Context, sc SpanContext) context.Context {
return context.WithValue(ctx, remoteContextKey, sc)
}
// RemoteSpanContextFromContext returns the remote span context stored
// in the context.
func RemoteSpanContextFromContext(ctx context.Context) core.SpanContext {
if sc, ok := ctx.Value(remoteContextKey).(core.SpanContext); ok {
func RemoteSpanContextFromContext(ctx context.Context) SpanContext {
if sc, ok := ctx.Value(remoteContextKey).(SpanContext); ok {
return sc
}
return core.EmptySpanContext()
return EmptySpanContext()
}

View File

@ -72,8 +72,8 @@ type mockSpan struct{}
var _ trace.Span = mockSpan{}
// SpanContext returns an invalid span context.
func (mockSpan) SpanContext() core.SpanContext {
return core.EmptySpanContext()
func (mockSpan) SpanContext() trace.SpanContext {
return trace.EmptySpanContext()
}
// IsRecording always returns false for mockSpan.

View File

@ -29,8 +29,8 @@ type NoopSpan struct {
var _ Span = (*NoopSpan)(nil)
// SpanContext returns an invalid span context.
func (NoopSpan) SpanContext() core.SpanContext {
return core.EmptySpanContext()
func (NoopSpan) SpanContext() SpanContext {
return EmptySpanContext()
}
// IsRecording always returns false for NoopSpan.

View File

@ -21,10 +21,10 @@ type Sampler interface {
// or not sample the span to be created. Decision is based on a Sampler specific
// algorithm that takes into account one or more input parameters.
ShouldSample(
sc core.SpanContext,
sc SpanContext,
remote bool,
traceID core.TraceID,
spanID core.SpanID,
traceID TraceID,
spanID SpanID,
spanName string,
spanKind SpanKind,
attributes []core.KeyValue,

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package core
package trace
import (
"bytes"

View File

@ -12,19 +12,19 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package core_test
package trace_test
import (
"testing"
"go.opentelemetry.io/otel/api/core"
"go.opentelemetry.io/otel/api/trace"
)
func TestIsValid(t *testing.T) {
for _, testcase := range []struct {
name string
tid core.TraceID
sid core.SpanID
tid trace.TraceID
sid trace.SpanID
want bool
}{
{
@ -34,23 +34,23 @@ func TestIsValid(t *testing.T) {
want: true,
}, {
name: "SpanContext.IsValid() returns false if sc has neither an Trace ID nor Span ID",
tid: core.TraceID([16]byte{}),
tid: trace.TraceID([16]byte{}),
sid: [8]byte{},
want: false,
}, {
name: "SpanContext.IsValid() returns false if sc has a Span ID but not a Trace ID",
tid: core.TraceID([16]byte{}),
tid: trace.TraceID([16]byte{}),
sid: [8]byte{42},
want: false,
}, {
name: "SpanContext.IsValid() returns false if sc has a Trace ID but not a Span ID",
tid: core.TraceID([16]byte{1}),
tid: trace.TraceID([16]byte{1}),
sid: [8]byte{},
want: false,
},
} {
t.Run(testcase.name, func(t *testing.T) {
sc := core.SpanContext{
sc := trace.SpanContext{
TraceID: testcase.tid,
SpanID: testcase.sid,
}
@ -66,12 +66,12 @@ func TestIsValidFromHex(t *testing.T) {
for _, testcase := range []struct {
name string
hex string
tid core.TraceID
tid trace.TraceID
valid bool
}{
{
name: "Valid TraceID",
tid: core.TraceID([16]byte{128, 241, 152, 238, 86, 52, 59, 168, 100, 254, 139, 42, 87, 211, 239, 247}),
tid: trace.TraceID([16]byte{128, 241, 152, 238, 86, 52, 59, 168, 100, 254, 139, 42, 87, 211, 239, 247}),
hex: "80f198ee56343ba864fe8b2a57d3eff7",
valid: true,
}, {
@ -89,7 +89,7 @@ func TestIsValidFromHex(t *testing.T) {
},
} {
t.Run(testcase.name, func(t *testing.T) {
tid, err := core.TraceIDFromHex(testcase.hex)
tid, err := trace.TraceIDFromHex(testcase.hex)
if testcase.valid && err != nil {
t.Errorf("Expected TraceID %s to be valid but end with error %s", testcase.hex, err.Error())
@ -109,22 +109,22 @@ func TestIsValidFromHex(t *testing.T) {
func TestHasTraceID(t *testing.T) {
for _, testcase := range []struct {
name string
tid core.TraceID
tid trace.TraceID
want bool
}{
{
name: "SpanContext.HasTraceID() returns true if both Low and High are nonzero",
tid: core.TraceID([16]byte{1}),
tid: trace.TraceID([16]byte{1}),
want: true,
}, {
name: "SpanContext.HasTraceID() returns false if neither Low nor High are nonzero",
tid: core.TraceID{},
tid: trace.TraceID{},
want: false,
},
} {
t.Run(testcase.name, func(t *testing.T) {
//proto: func (sc SpanContext) HasTraceID() bool{}
sc := core.SpanContext{TraceID: testcase.tid}
sc := trace.SpanContext{TraceID: testcase.tid}
have := sc.HasTraceID()
if have != testcase.want {
t.Errorf("Want: %v, but have: %v", testcase.want, have)
@ -136,16 +136,16 @@ func TestHasTraceID(t *testing.T) {
func TestHasSpanID(t *testing.T) {
for _, testcase := range []struct {
name string
sc core.SpanContext
sc trace.SpanContext
want bool
}{
{
name: "SpanContext.HasSpanID() returns true if self.SpanID != 0",
sc: core.SpanContext{SpanID: [8]byte{42}},
sc: trace.SpanContext{SpanID: [8]byte{42}},
want: true,
}, {
name: "SpanContext.HasSpanID() returns false if self.SpanID == 0",
sc: core.SpanContext{},
sc: trace.SpanContext{},
want: false,
},
} {
@ -162,26 +162,26 @@ func TestHasSpanID(t *testing.T) {
func TestSpanContextIsSampled(t *testing.T) {
for _, testcase := range []struct {
name string
sc core.SpanContext
sc trace.SpanContext
want bool
}{
{
name: "sampled",
sc: core.SpanContext{
TraceID: core.TraceID([16]byte{1}),
TraceFlags: core.TraceFlagsSampled,
sc: trace.SpanContext{
TraceID: trace.TraceID([16]byte{1}),
TraceFlags: trace.TraceFlagsSampled,
},
want: true,
}, {
name: "sampled plus unused",
sc: core.SpanContext{
TraceID: core.TraceID([16]byte{1}),
TraceFlags: core.TraceFlagsSampled | core.TraceFlagsUnused,
sc: trace.SpanContext{
TraceID: trace.TraceID([16]byte{1}),
TraceFlags: trace.TraceFlagsSampled | trace.TraceFlagsUnused,
},
want: true,
}, {
name: "not sampled/default",
sc: core.SpanContext{TraceID: core.TraceID{}},
sc: trace.SpanContext{TraceID: trace.TraceID{}},
want: false,
},
} {
@ -197,17 +197,17 @@ func TestSpanContextIsSampled(t *testing.T) {
func TestStringTraceID(t *testing.T) {
for _, testcase := range []struct {
name string
tid core.TraceID
tid trace.TraceID
want string
}{
{
name: "TraceID.String returns string representation of self.TraceID values > 0",
tid: core.TraceID([16]byte{255}),
tid: trace.TraceID([16]byte{255}),
want: "ff000000000000000000000000000000",
},
{
name: "TraceID.String returns string representation of self.TraceID values == 0",
tid: core.TraceID([16]byte{}),
tid: trace.TraceID([16]byte{}),
want: "00000000000000000000000000000000",
},
} {
@ -224,17 +224,17 @@ func TestStringTraceID(t *testing.T) {
func TestStringSpanID(t *testing.T) {
for _, testcase := range []struct {
name string
sid core.SpanID
sid trace.SpanID
want string
}{
{
name: "SpanID.String returns string representation of self.SpanID values > 0",
sid: core.SpanID([8]byte{255}),
sid: trace.SpanID([8]byte{255}),
want: "ff00000000000000",
},
{
name: "SpanID.String returns string representation of self.SpanID values == 0",
sid: core.SpanID([8]byte{}),
sid: trace.SpanID([8]byte{}),
want: "0000000000000000",
},
} {

View File

@ -15,14 +15,13 @@
package testtrace_test
import (
"go.opentelemetry.io/otel/api/core"
"go.opentelemetry.io/otel/api/trace"
)
type extractTest struct {
name string
headers map[string]string
wantSc core.SpanContext
wantSc trace.SpanContext
}
var extractMultipleHeaders = []extractTest{
@ -32,7 +31,7 @@ var extractMultipleHeaders = []extractTest{
trace.B3TraceIDHeader: "4bf92f3577b34da6a3ce929d0e0e4736",
trace.B3SpanIDHeader: "00f067aa0ba902b7",
},
wantSc: core.SpanContext{
wantSc: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
},
@ -44,7 +43,7 @@ var extractMultipleHeaders = []extractTest{
trace.B3SpanIDHeader: "00f067aa0ba902b7",
trace.B3SampledHeader: "0",
},
wantSc: core.SpanContext{
wantSc: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
},
@ -56,10 +55,10 @@ var extractMultipleHeaders = []extractTest{
trace.B3SpanIDHeader: "00f067aa0ba902b7",
trace.B3SampledHeader: "1",
},
wantSc: core.SpanContext{
wantSc: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
TraceFlags: core.TraceFlagsSampled,
TraceFlags: trace.TraceFlagsSampled,
},
},
{
@ -69,10 +68,10 @@ var extractMultipleHeaders = []extractTest{
trace.B3SpanIDHeader: "00f067aa0ba902b7",
trace.B3SampledHeader: "true",
},
wantSc: core.SpanContext{
wantSc: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
TraceFlags: core.TraceFlagsSampled,
TraceFlags: trace.TraceFlagsSampled,
},
},
{
@ -82,10 +81,10 @@ var extractMultipleHeaders = []extractTest{
trace.B3SpanIDHeader: "00f067aa0ba902b7",
trace.B3DebugFlagHeader: "1",
},
wantSc: core.SpanContext{
wantSc: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
TraceFlags: core.TraceFlagsSampled,
TraceFlags: trace.TraceFlagsSampled,
},
},
{
@ -99,10 +98,10 @@ var extractMultipleHeaders = []extractTest{
trace.B3SampledHeader: "0",
trace.B3DebugFlagHeader: "1",
},
wantSc: core.SpanContext{
wantSc: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
TraceFlags: core.TraceFlagsSampled,
TraceFlags: trace.TraceFlagsSampled,
},
},
{
@ -113,10 +112,10 @@ var extractMultipleHeaders = []extractTest{
trace.B3SampledHeader: "1",
trace.B3ParentSpanIDHeader: "00f067aa0ba90200",
},
wantSc: core.SpanContext{
wantSc: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
TraceFlags: core.TraceFlagsSampled,
TraceFlags: trace.TraceFlagsSampled,
},
},
{
@ -124,7 +123,7 @@ var extractMultipleHeaders = []extractTest{
headers: map[string]string{
trace.B3SampledHeader: "0",
},
wantSc: core.EmptySpanContext(),
wantSc: trace.EmptySpanContext(),
},
}
@ -134,7 +133,7 @@ var extractSingleHeader = []extractTest{
headers: map[string]string{
trace.B3SingleHeader: "4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7",
},
wantSc: core.SpanContext{
wantSc: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
},
@ -144,7 +143,7 @@ var extractSingleHeader = []extractTest{
headers: map[string]string{
trace.B3SingleHeader: "4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-0",
},
wantSc: core.SpanContext{
wantSc: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
},
@ -154,10 +153,10 @@ var extractSingleHeader = []extractTest{
headers: map[string]string{
trace.B3SingleHeader: "4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-1",
},
wantSc: core.SpanContext{
wantSc: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
TraceFlags: core.TraceFlagsSampled,
TraceFlags: trace.TraceFlagsSampled,
},
},
{
@ -165,10 +164,10 @@ var extractSingleHeader = []extractTest{
headers: map[string]string{
trace.B3SingleHeader: "4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-d",
},
wantSc: core.SpanContext{
wantSc: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
TraceFlags: core.TraceFlagsSampled,
TraceFlags: trace.TraceFlagsSampled,
},
},
{
@ -176,10 +175,10 @@ var extractSingleHeader = []extractTest{
headers: map[string]string{
trace.B3SingleHeader: "4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-1-00000000000000cd",
},
wantSc: core.SpanContext{
wantSc: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
TraceFlags: core.TraceFlagsSampled,
TraceFlags: trace.TraceFlagsSampled,
},
},
{
@ -187,7 +186,7 @@ var extractSingleHeader = []extractTest{
headers: map[string]string{
trace.B3SingleHeader: "0",
},
wantSc: core.EmptySpanContext(),
wantSc: trace.EmptySpanContext(),
},
}
@ -436,7 +435,7 @@ var extractInvalidB3SingleHeader = []extractTest{
type injectTest struct {
name string
parentSc core.SpanContext
parentSc trace.SpanContext
wantHeaders map[string]string
doNotWantHeaders []string
}
@ -444,10 +443,10 @@ type injectTest struct {
var injectB3MultipleHeader = []injectTest{
{
name: "valid spancontext, sampled",
parentSc: core.SpanContext{
parentSc: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
TraceFlags: core.TraceFlagsSampled,
TraceFlags: trace.TraceFlagsSampled,
},
wantHeaders: map[string]string{
trace.B3TraceIDHeader: "4bf92f3577b34da6a3ce929d0e0e4736",
@ -460,7 +459,7 @@ var injectB3MultipleHeader = []injectTest{
},
{
name: "valid spancontext, not sampled",
parentSc: core.SpanContext{
parentSc: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
},
@ -475,7 +474,7 @@ var injectB3MultipleHeader = []injectTest{
},
{
name: "valid spancontext, with unsupported bit set in traceflags",
parentSc: core.SpanContext{
parentSc: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
TraceFlags: 0xff,
@ -494,10 +493,10 @@ var injectB3MultipleHeader = []injectTest{
var injectB3SingleleHeader = []injectTest{
{
name: "valid spancontext, sampled",
parentSc: core.SpanContext{
parentSc: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
TraceFlags: core.TraceFlagsSampled,
TraceFlags: trace.TraceFlagsSampled,
},
wantHeaders: map[string]string{
trace.B3SingleHeader: "4bf92f3577b34da6a3ce929d0e0e4736-0000000000000001-1",
@ -511,7 +510,7 @@ var injectB3SingleleHeader = []injectTest{
},
{
name: "valid spancontext, not sampled",
parentSc: core.SpanContext{
parentSc: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
},
@ -527,7 +526,7 @@ var injectB3SingleleHeader = []injectTest{
},
{
name: "valid spancontext, with unsupported bit set in traceflags",
parentSc: core.SpanContext{
parentSc: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
TraceFlags: 0xff,

View File

@ -18,12 +18,12 @@ import (
"encoding/binary"
"sync"
"go.opentelemetry.io/otel/api/core"
"go.opentelemetry.io/otel/api/trace"
)
type Generator interface {
TraceID() core.TraceID
SpanID() core.SpanID
TraceID() trace.TraceID
SpanID() trace.SpanID
}
var _ Generator = (*CountGenerator)(nil)
@ -41,7 +41,7 @@ func NewCountGenerator() *CountGenerator {
return &CountGenerator{}
}
func (g *CountGenerator) TraceID() core.TraceID {
func (g *CountGenerator) TraceID() trace.TraceID {
g.lock.Lock()
defer g.lock.Unlock()
@ -51,7 +51,7 @@ func (g *CountGenerator) TraceID() core.TraceID {
g.traceIDLow++
}
var traceID core.TraceID
var traceID trace.TraceID
binary.BigEndian.PutUint64(traceID[0:8], g.traceIDLow)
binary.BigEndian.PutUint64(traceID[8:], g.traceIDHigh)
@ -59,13 +59,13 @@ func (g *CountGenerator) TraceID() core.TraceID {
return traceID
}
func (g *CountGenerator) SpanID() core.SpanID {
func (g *CountGenerator) SpanID() trace.SpanID {
g.lock.Lock()
defer g.lock.Unlock()
g.spanID++
var spanID core.SpanID
var spanID trace.SpanID
binary.BigEndian.PutUint64(spanID[:], g.spanID)

View File

@ -21,7 +21,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/otel/api/core"
"go.opentelemetry.io/otel/api/propagation"
"go.opentelemetry.io/otel/api/trace"
)
@ -33,11 +32,11 @@ type outOfThinAirPropagator struct {
var _ propagation.HTTPPropagator = outOfThinAirPropagator{}
func (p outOfThinAirPropagator) Extract(ctx context.Context, supplier propagation.HTTPSupplier) context.Context {
traceID, err := core.TraceIDFromHex("938753245abe987f098c0987a9873987")
traceID, err := trace.TraceIDFromHex("938753245abe987f098c0987a9873987")
require.NoError(p.t, err)
spanID, err := core.SpanIDFromHex("2345f98c0987a09d")
spanID, err := trace.SpanIDFromHex("2345f98c0987a09d")
require.NoError(p.t, err)
sc := core.SpanContext{
sc := trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
TraceFlags: 0,

View File

@ -39,8 +39,8 @@ var _ trace.Span = (*Span)(nil)
type Span struct {
lock *sync.RWMutex
tracer *Tracer
spanContext core.SpanContext
parentSpanID core.SpanID
spanContext trace.SpanContext
parentSpanID trace.SpanID
ended bool
name string
startTime time.Time
@ -49,7 +49,7 @@ type Span struct {
statusMessage string
attributes map[core.Key]core.Value
events []Event
links map[core.SpanContext][]core.KeyValue
links map[trace.SpanContext][]core.KeyValue
}
func (s *Span) Tracer() trace.Tracer {
@ -138,7 +138,7 @@ func (s *Span) IsRecording() bool {
return true
}
func (s *Span) SpanContext() core.SpanContext {
func (s *Span) SpanContext() trace.SpanContext {
return s.spanContext
}
@ -191,7 +191,7 @@ func (s *Span) Name() string {
// ParentSpanID returns the SpanID of the parent Span.
// If the Span is a root Span and therefore does not have a parent, the returned SpanID will be invalid
// (i.e., it will contain all zeroes).
func (s *Span) ParentSpanID() core.SpanID {
func (s *Span) ParentSpanID() trace.SpanID {
return s.parentSpanID
}
@ -219,8 +219,8 @@ func (s *Span) Events() []Event {
// Links returns the links set on the Span at creation time.
// If multiple links for the same SpanContext were set, the last link will be used.
func (s *Span) Links() map[core.SpanContext][]core.KeyValue {
links := make(map[core.SpanContext][]core.KeyValue)
func (s *Span) Links() map[trace.SpanContext][]core.KeyValue {
links := make(map[trace.SpanContext][]core.KeyValue)
for sc, attributes := range s.links {
links[sc] = append([]core.KeyValue{}, attributes...)

View File

@ -19,7 +19,6 @@ import (
"net/http"
"testing"
"go.opentelemetry.io/otel/api/core"
"go.opentelemetry.io/otel/api/trace"
mocktrace "go.opentelemetry.io/otel/internal/trace"
)
@ -39,18 +38,18 @@ func BenchmarkInject(b *testing.B) {
func injectSubBenchmarks(b *testing.B, fn func(context.Context, *testing.B)) {
b.Run("SampledSpanContext", func(b *testing.B) {
var id uint64
spanID, _ := core.SpanIDFromHex("00f067aa0ba902b7")
traceID, _ := core.TraceIDFromHex("4bf92f3577b34da6a3ce929d0e0e4736")
spanID, _ := trace.SpanIDFromHex("00f067aa0ba902b7")
traceID, _ := trace.TraceIDFromHex("4bf92f3577b34da6a3ce929d0e0e4736")
mockTracer := &mocktrace.MockTracer{
Sampled: false,
StartSpanID: &id,
}
b.ReportAllocs()
sc := core.SpanContext{
sc := trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
TraceFlags: core.TraceFlagsSampled,
TraceFlags: trace.TraceFlagsSampled,
}
ctx := trace.ContextWithRemoteSpanContext(context.Background(), sc)
ctx, _ = mockTracer.Start(ctx, "inject")

View File

@ -21,7 +21,6 @@ import (
"github.com/google/go-cmp/cmp"
"go.opentelemetry.io/otel/api/core"
"go.opentelemetry.io/otel/api/propagation"
"go.opentelemetry.io/otel/api/trace"
mocktrace "go.opentelemetry.io/otel/internal/trace"
@ -32,13 +31,13 @@ var (
spanID = mustSpanIDFromHex("00f067aa0ba902b7")
)
func mustTraceIDFromHex(s string) (t core.TraceID) {
t, _ = core.TraceIDFromHex(s)
func mustTraceIDFromHex(s string) (t trace.TraceID) {
t, _ = trace.TraceIDFromHex(s)
return
}
func mustSpanIDFromHex(s string) (t core.SpanID) {
t, _ = core.SpanIDFromHex(s)
func mustSpanIDFromHex(s string) (t trace.SpanID) {
t, _ = trace.SpanIDFromHex(s)
return
}
@ -47,12 +46,12 @@ func TestExtractValidTraceContextFromHTTPReq(t *testing.T) {
tests := []struct {
name string
header string
wantSc core.SpanContext
wantSc trace.SpanContext
}{
{
name: "valid w3cHeader",
header: "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-00",
wantSc: core.SpanContext{
wantSc: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
},
@ -60,34 +59,34 @@ func TestExtractValidTraceContextFromHTTPReq(t *testing.T) {
{
name: "valid w3cHeader and sampled",
header: "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01",
wantSc: core.SpanContext{
wantSc: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
TraceFlags: core.TraceFlagsSampled,
TraceFlags: trace.TraceFlagsSampled,
},
},
{
name: "future version",
header: "02-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01",
wantSc: core.SpanContext{
wantSc: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
TraceFlags: core.TraceFlagsSampled,
TraceFlags: trace.TraceFlagsSampled,
},
},
{
name: "future options with sampled bit set",
header: "02-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-09",
wantSc: core.SpanContext{
wantSc: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
TraceFlags: core.TraceFlagsSampled,
TraceFlags: trace.TraceFlagsSampled,
},
},
{
name: "future options with sampled bit cleared",
header: "02-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-08",
wantSc: core.SpanContext{
wantSc: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
},
@ -95,28 +94,28 @@ func TestExtractValidTraceContextFromHTTPReq(t *testing.T) {
{
name: "future additional data",
header: "02-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-09-XYZxsf09",
wantSc: core.SpanContext{
wantSc: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
TraceFlags: core.TraceFlagsSampled,
TraceFlags: trace.TraceFlagsSampled,
},
},
{
name: "valid b3Header ending in dash",
header: "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01-",
wantSc: core.SpanContext{
wantSc: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
TraceFlags: core.TraceFlagsSampled,
TraceFlags: trace.TraceFlagsSampled,
},
},
{
name: "future valid b3Header ending in dash",
header: "01-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-09-",
wantSc: core.SpanContext{
wantSc: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
TraceFlags: core.TraceFlagsSampled,
TraceFlags: trace.TraceFlagsSampled,
},
},
}
@ -137,7 +136,7 @@ func TestExtractValidTraceContextFromHTTPReq(t *testing.T) {
}
func TestExtractInvalidTraceContextFromHTTPReq(t *testing.T) {
wantSc := core.EmptySpanContext()
wantSc := trace.EmptySpanContext()
props := propagation.New(propagation.WithExtractors(trace.TraceContext{}))
tests := []struct {
name string
@ -233,21 +232,21 @@ func TestInjectTraceContextToHTTPReq(t *testing.T) {
props := propagation.New(propagation.WithInjectors(trace.TraceContext{}))
tests := []struct {
name string
sc core.SpanContext
sc trace.SpanContext
wantHeader string
}{
{
name: "valid spancontext, sampled",
sc: core.SpanContext{
sc: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
TraceFlags: core.TraceFlagsSampled,
TraceFlags: trace.TraceFlagsSampled,
},
wantHeader: "00-4bf92f3577b34da6a3ce929d0e0e4736-0000000000000001-01",
},
{
name: "valid spancontext, not sampled",
sc: core.SpanContext{
sc: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
},
@ -255,7 +254,7 @@ func TestInjectTraceContextToHTTPReq(t *testing.T) {
},
{
name: "valid spancontext, with unsupported bit set in traceflags",
sc: core.SpanContext{
sc: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
TraceFlags: 0xff,
@ -264,7 +263,7 @@ func TestInjectTraceContextToHTTPReq(t *testing.T) {
},
{
name: "invalid spancontext",
sc: core.EmptySpanContext(),
sc: trace.EmptySpanContext(),
wantHeader: "",
},
}

View File

@ -51,8 +51,8 @@ func (t *Tracer) Start(ctx context.Context, name string, opts ...trace.StartOpti
opt(&c)
}
var traceID core.TraceID
var parentSpanID core.SpanID
var traceID trace.TraceID
var parentSpanID trace.SpanID
parentSpanContext, _, links := parent.GetSpanContextAndLinks(ctx, c.NewRoot)
@ -75,13 +75,13 @@ func (t *Tracer) Start(ctx context.Context, name string, opts ...trace.StartOpti
lock: &sync.RWMutex{},
tracer: t,
startTime: startTime,
spanContext: core.SpanContext{
spanContext: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
},
parentSpanID: parentSpanID,
attributes: make(map[core.Key]core.Value),
links: make(map[core.SpanContext][]core.KeyValue),
links: make(map[trace.SpanContext][]core.KeyValue),
}
span.SetName(name)

View File

@ -21,7 +21,6 @@ import (
"regexp"
"strings"
"go.opentelemetry.io/otel/api/core"
"go.opentelemetry.io/otel/api/propagation"
)
@ -52,7 +51,7 @@ func (TraceContext) Inject(ctx context.Context, supplier propagation.HTTPSupplie
supportedVersion,
sc.TraceID,
sc.SpanID,
sc.TraceFlags&core.TraceFlagsSampled)
sc.TraceFlags&TraceFlagsSampled)
supplier.Set(traceparentHeader, h)
}
@ -64,68 +63,68 @@ func (tc TraceContext) Extract(ctx context.Context, supplier propagation.HTTPSup
return ContextWithRemoteSpanContext(ctx, sc)
}
func (TraceContext) extract(supplier propagation.HTTPSupplier) core.SpanContext {
func (TraceContext) extract(supplier propagation.HTTPSupplier) SpanContext {
h := supplier.Get(traceparentHeader)
if h == "" {
return core.EmptySpanContext()
return EmptySpanContext()
}
h = strings.Trim(h, "-")
if !traceCtxRegExp.MatchString(h) {
return core.EmptySpanContext()
return EmptySpanContext()
}
sections := strings.Split(h, "-")
if len(sections) < 4 {
return core.EmptySpanContext()
return EmptySpanContext()
}
if len(sections[0]) != 2 {
return core.EmptySpanContext()
return EmptySpanContext()
}
ver, err := hex.DecodeString(sections[0])
if err != nil {
return core.EmptySpanContext()
return EmptySpanContext()
}
version := int(ver[0])
if version > maxVersion {
return core.EmptySpanContext()
return EmptySpanContext()
}
if version == 0 && len(sections) != 4 {
return core.EmptySpanContext()
return EmptySpanContext()
}
if len(sections[1]) != 32 {
return core.EmptySpanContext()
return EmptySpanContext()
}
var sc core.SpanContext
var sc SpanContext
sc.TraceID, err = core.TraceIDFromHex(sections[1][:32])
sc.TraceID, err = TraceIDFromHex(sections[1][:32])
if err != nil {
return core.EmptySpanContext()
return EmptySpanContext()
}
if len(sections[2]) != 16 {
return core.EmptySpanContext()
return EmptySpanContext()
}
sc.SpanID, err = core.SpanIDFromHex(sections[2])
sc.SpanID, err = SpanIDFromHex(sections[2])
if err != nil {
return core.EmptySpanContext()
return EmptySpanContext()
}
if len(sections[3]) != 2 {
return core.EmptySpanContext()
return EmptySpanContext()
}
opts, err := hex.DecodeString(sections[3])
if err != nil || len(opts) < 1 || (version == 0 && opts[0] > 2) {
return core.EmptySpanContext()
return EmptySpanContext()
}
sc.TraceFlags = opts[0] &^ core.TraceFlagsUnused
sc.TraceFlags = opts[0] &^ TraceFlagsUnused
if !sc.IsValid() {
return core.EmptySpanContext()
return EmptySpanContext()
}
return sc

View File

@ -40,12 +40,12 @@ import (
type bridgeSpanContext struct {
baggageItems otelcorrelation.Map
otelSpanContext otelcore.SpanContext
otelSpanContext oteltrace.SpanContext
}
var _ ot.SpanContext = &bridgeSpanContext{}
func newBridgeSpanContext(otelSpanContext otelcore.SpanContext, parentOtSpanContext ot.SpanContext) *bridgeSpanContext {
func newBridgeSpanContext(otelSpanContext oteltrace.SpanContext, parentOtSpanContext ot.SpanContext) *bridgeSpanContext {
bCtx := &bridgeSpanContext{
baggageItems: otelcorrelation.NewEmptyMap(),
otelSpanContext: otelSpanContext,
@ -582,10 +582,10 @@ func otSpanReferenceTypeToString(refType ot.SpanReferenceType) string {
type fakeSpan struct {
oteltrace.NoopSpan
sc otelcore.SpanContext
sc oteltrace.SpanContext
}
func (s fakeSpan) SpanContext() otelcore.SpanContext {
func (s fakeSpan) SpanContext() oteltrace.SpanContext {
return s.sc
}

View File

@ -49,8 +49,8 @@ type MockContextKeyValue struct {
type MockTracer struct {
Resources otelcorrelation.Map
FinishedSpans []*MockSpan
SpareTraceIDs []otelcore.TraceID
SpareSpanIDs []otelcore.SpanID
SpareTraceIDs []oteltrace.TraceID
SpareSpanIDs []oteltrace.SpanID
SpareContextKeyValues []MockContextKeyValue
randLock sync.Mutex
@ -87,7 +87,7 @@ func (t *MockTracer) Start(ctx context.Context, name string, opts ...oteltrace.S
if startTime.IsZero() {
startTime = time.Now()
}
spanContext := otelcore.SpanContext{
spanContext := oteltrace.SpanContext{
TraceID: t.getTraceID(ctx, &spanOpts),
SpanID: t.getSpanID(),
TraceFlags: 0,
@ -126,7 +126,7 @@ func (t *MockTracer) addSpareContextValue(ctx context.Context) context.Context {
return ctx
}
func (t *MockTracer) getTraceID(ctx context.Context, spanOpts *oteltrace.StartConfig) otelcore.TraceID {
func (t *MockTracer) getTraceID(ctx context.Context, spanOpts *oteltrace.StartConfig) oteltrace.TraceID {
if parent := t.getParentSpanContext(ctx, spanOpts); parent.IsValid() {
return parent.TraceID
}
@ -141,19 +141,19 @@ func (t *MockTracer) getTraceID(ctx context.Context, spanOpts *oteltrace.StartCo
return t.getRandTraceID()
}
func (t *MockTracer) getParentSpanID(ctx context.Context, spanOpts *oteltrace.StartConfig) otelcore.SpanID {
func (t *MockTracer) getParentSpanID(ctx context.Context, spanOpts *oteltrace.StartConfig) oteltrace.SpanID {
if parent := t.getParentSpanContext(ctx, spanOpts); parent.IsValid() {
return parent.SpanID
}
return otelcore.SpanID{}
return oteltrace.SpanID{}
}
func (t *MockTracer) getParentSpanContext(ctx context.Context, spanOpts *oteltrace.StartConfig) otelcore.SpanContext {
func (t *MockTracer) getParentSpanContext(ctx context.Context, spanOpts *oteltrace.StartConfig) oteltrace.SpanContext {
spanCtx, _, _ := otelparent.GetSpanContextAndLinks(ctx, spanOpts.NewRoot)
return spanCtx
}
func (t *MockTracer) getSpanID() otelcore.SpanID {
func (t *MockTracer) getSpanID() oteltrace.SpanID {
if len(t.SpareSpanIDs) > 0 {
spanID := t.SpareSpanIDs[0]
t.SpareSpanIDs = t.SpareSpanIDs[1:]
@ -165,21 +165,21 @@ func (t *MockTracer) getSpanID() otelcore.SpanID {
return t.getRandSpanID()
}
func (t *MockTracer) getRandSpanID() otelcore.SpanID {
func (t *MockTracer) getRandSpanID() oteltrace.SpanID {
t.randLock.Lock()
defer t.randLock.Unlock()
sid := otelcore.SpanID{}
sid := oteltrace.SpanID{}
t.rand.Read(sid[:])
return sid
}
func (t *MockTracer) getRandTraceID() otelcore.TraceID {
func (t *MockTracer) getRandTraceID() oteltrace.TraceID {
t.randLock.Lock()
defer t.randLock.Unlock()
tid := otelcore.TraceID{}
tid := oteltrace.TraceID{}
t.rand.Read(tid[:])
return tid
@ -199,21 +199,21 @@ type MockEvent struct {
type MockSpan struct {
mockTracer *MockTracer
officialTracer oteltrace.Tracer
spanContext otelcore.SpanContext
spanContext oteltrace.SpanContext
SpanKind oteltrace.SpanKind
recording bool
Attributes otelcorrelation.Map
StartTime time.Time
EndTime time.Time
ParentSpanID otelcore.SpanID
ParentSpanID oteltrace.SpanID
Events []MockEvent
}
var _ oteltrace.Span = &MockSpan{}
var _ migration.OverrideTracerSpanExtension = &MockSpan{}
func (s *MockSpan) SpanContext() otelcore.SpanContext {
func (s *MockSpan) SpanContext() oteltrace.SpanContext {
return s.spanContext
}

View File

@ -143,8 +143,8 @@ func TestMixedAPIs(t *testing.T) {
// simple test
type simpleTest struct {
traceID otelcore.TraceID
spanIDs []otelcore.SpanID
traceID oteltrace.TraceID
spanIDs []oteltrace.SpanID
}
func newSimpleTest() *simpleTest {
@ -178,11 +178,11 @@ func (st *simpleTest) noop(t *testing.T, ctx context.Context) context.Context {
// current/active span test
type currentActiveSpanTest struct {
traceID otelcore.TraceID
spanIDs []otelcore.SpanID
traceID oteltrace.TraceID
spanIDs []oteltrace.SpanID
recordedCurrentOtelSpanIDs []otelcore.SpanID
recordedActiveOTSpanIDs []otelcore.SpanID
recordedCurrentOtelSpanIDs []oteltrace.SpanID
recordedActiveOTSpanIDs []oteltrace.SpanID
}
func newCurrentActiveSpanTest() *currentActiveSpanTest {
@ -233,7 +233,7 @@ func (cast *currentActiveSpanTest) recordSpans(t *testing.T, ctx context.Context
spanID := oteltrace.SpanFromContext(ctx).SpanContext().SpanID
cast.recordedCurrentOtelSpanIDs = append(cast.recordedCurrentOtelSpanIDs, spanID)
spanID = otelcore.SpanID{}
spanID = oteltrace.SpanID{}
if bridgeSpan, ok := ot.SpanFromContext(ctx).(*bridgeSpan); ok {
spanID = bridgeSpan.otelSpan.SpanContext().SpanID
}
@ -614,20 +614,20 @@ func generateBaggageKeys(key string) (otKey, otelKey string) {
// helpers
func checkTraceAndSpans(t *testing.T, tracer *internal.MockTracer, expectedTraceID otelcore.TraceID, expectedSpanIDs []otelcore.SpanID) {
func checkTraceAndSpans(t *testing.T, tracer *internal.MockTracer, expectedTraceID oteltrace.TraceID, expectedSpanIDs []oteltrace.SpanID) {
expectedSpanCount := len(expectedSpanIDs)
// reverse spanIDs, since first span ID belongs to root, that
// finishes last
spanIDs := make([]otelcore.SpanID, len(expectedSpanIDs))
spanIDs := make([]oteltrace.SpanID, len(expectedSpanIDs))
copy(spanIDs, expectedSpanIDs)
reverse(len(spanIDs), func(i, j int) {
spanIDs[i], spanIDs[j] = spanIDs[j], spanIDs[i]
})
// the last finished span has no parent
parentSpanIDs := append(spanIDs[1:], otelcore.SpanID{})
parentSpanIDs := append(spanIDs[1:], oteltrace.SpanID{})
sks := map[otelcore.SpanID]oteltrace.SpanKind{
sks := map[oteltrace.SpanID]oteltrace.SpanKind{
{125}: oteltrace.SpanKindProducer,
{124}: oteltrace.SpanKindInternal,
{123}: oteltrace.SpanKindClient,
@ -661,12 +661,12 @@ func reverse(length int, swap func(i, j int)) {
}
}
func simpleTraceID() otelcore.TraceID {
func simpleTraceID() oteltrace.TraceID {
return [16]byte{123, 42}
}
func simpleSpanIDs(count int) []otelcore.SpanID {
base := []otelcore.SpanID{
func simpleSpanIDs(count int) []oteltrace.SpanID {
base := []oteltrace.SpanID{
{123},
{124},
{125},

View File

@ -123,7 +123,7 @@ func TestLinks(t *testing.T) {
l := []apitrace.Link{
{},
{
SpanContext: core.EmptySpanContext(),
SpanContext: apitrace.EmptySpanContext(),
Attributes: attrs,
},
}
@ -270,12 +270,12 @@ func TestSpanData(t *testing.T) {
startTime := time.Unix(1585674086, 1234)
endTime := startTime.Add(10 * time.Second)
spanData := &export.SpanData{
SpanContext: core.SpanContext{
TraceID: core.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F},
SpanID: core.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8},
SpanContext: apitrace.SpanContext{
TraceID: apitrace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F},
SpanID: apitrace.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8},
},
SpanKind: apitrace.SpanKindServer,
ParentSpanID: core.SpanID{0xEF, 0xEE, 0xED, 0xEC, 0xEB, 0xEA, 0xE9, 0xE8},
ParentSpanID: apitrace.SpanID{0xEF, 0xEE, 0xED, 0xEC, 0xEB, 0xEA, 0xE9, 0xE8},
Name: "span data to span data",
StartTime: startTime,
EndTime: endTime,
@ -293,9 +293,9 @@ func TestSpanData(t *testing.T) {
},
Links: []apitrace.Link{
{
SpanContext: core.SpanContext{
TraceID: core.TraceID{0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF},
SpanID: core.SpanID{0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7},
SpanContext: apitrace.SpanContext{
TraceID: apitrace.TraceID{0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF},
SpanID: apitrace.SpanID{0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7},
TraceFlags: 0,
},
Attributes: []core.KeyValue{
@ -303,9 +303,9 @@ func TestSpanData(t *testing.T) {
},
},
{
SpanContext: core.SpanContext{
TraceID: core.TraceID{0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF},
SpanID: core.SpanID{0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7},
SpanContext: apitrace.SpanContext{
TraceID: apitrace.TraceID{0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF},
SpanID: apitrace.SpanID{0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7},
TraceFlags: 0,
},
Attributes: []core.KeyValue{

View File

@ -81,9 +81,9 @@ func TestExportSpans(t *testing.T) {
{
[]*tracesdk.SpanData{
{
SpanContext: core.SpanContext{
TraceID: core.TraceID([16]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}),
SpanID: core.SpanID([8]byte{0, 0, 0, 0, 0, 0, 0, 1}),
SpanContext: apitrace.SpanContext{
TraceID: apitrace.TraceID([16]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}),
SpanID: apitrace.SpanID([8]byte{0, 0, 0, 0, 0, 0, 0, 1}),
TraceFlags: byte(1),
},
SpanKind: apitrace.SpanKindServer,
@ -99,12 +99,12 @@ func TestExportSpans(t *testing.T) {
Resource: resource.New(key.String("instance", "tester-a")),
},
{
SpanContext: core.SpanContext{
TraceID: core.TraceID([16]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}),
SpanID: core.SpanID([8]byte{0, 0, 0, 0, 0, 0, 0, 2}),
SpanContext: apitrace.SpanContext{
TraceID: apitrace.TraceID([16]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}),
SpanID: apitrace.SpanID([8]byte{0, 0, 0, 0, 0, 0, 0, 2}),
TraceFlags: byte(1),
},
ParentSpanID: core.SpanID([8]byte{0, 0, 0, 0, 0, 0, 0, 1}),
ParentSpanID: apitrace.SpanID([8]byte{0, 0, 0, 0, 0, 0, 0, 1}),
SpanKind: apitrace.SpanKindInternal,
Name: "internal process",
StartTime: startTime,
@ -118,9 +118,9 @@ func TestExportSpans(t *testing.T) {
Resource: resource.New(key.String("instance", "tester-a")),
},
{
SpanContext: core.SpanContext{
TraceID: core.TraceID([16]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2}),
SpanID: core.SpanID([8]byte{0, 0, 0, 0, 0, 0, 0, 1}),
SpanContext: apitrace.SpanContext{
TraceID: apitrace.TraceID([16]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2}),
SpanID: apitrace.SpanID([8]byte{0, 0, 0, 0, 0, 0, 0, 1}),
TraceFlags: byte(1),
},
SpanKind: apitrace.SpanKindServer,

View File

@ -191,11 +191,11 @@ func TestNewRawExporterWithAgentShouldFailIfEndpointInvalid(t *testing.T) {
func Test_spanDataToThrift(t *testing.T) {
now := time.Now()
traceID, _ := core.TraceIDFromHex("0102030405060708090a0b0c0d0e0f10")
spanID, _ := core.SpanIDFromHex("0102030405060708")
traceID, _ := apitrace.TraceIDFromHex("0102030405060708090a0b0c0d0e0f10")
spanID, _ := apitrace.SpanIDFromHex("0102030405060708")
linkTraceID, _ := core.TraceIDFromHex("0102030405060709090a0b0c0d0e0f11")
linkSpanID, _ := core.SpanIDFromHex("0102030405060709")
linkTraceID, _ := apitrace.TraceIDFromHex("0102030405060709090a0b0c0d0e0f11")
linkSpanID, _ := apitrace.SpanIDFromHex("0102030405060709")
eventNameValue := "event-test"
keyValue := "value"
@ -215,7 +215,7 @@ func Test_spanDataToThrift(t *testing.T) {
{
name: "no parent",
data: &export.SpanData{
SpanContext: core.SpanContext{
SpanContext: apitrace.SpanContext{
TraceID: traceID,
SpanID: spanID,
},
@ -224,7 +224,7 @@ func Test_spanDataToThrift(t *testing.T) {
EndTime: now,
Links: []apitrace.Link{
{
SpanContext: core.SpanContext{
SpanContext: apitrace.SpanContext{
TraceID: linkTraceID,
SpanID: linkSpanID,
},

View File

@ -40,14 +40,14 @@ func TestExporter_ExportSpan(t *testing.T) {
// setup test span
now := time.Now()
traceID, _ := core.TraceIDFromHex("0102030405060708090a0b0c0d0e0f10")
spanID, _ := core.SpanIDFromHex("0102030405060708")
traceID, _ := trace.TraceIDFromHex("0102030405060708090a0b0c0d0e0f10")
spanID, _ := trace.SpanIDFromHex("0102030405060708")
keyValue := "value"
doubleValue := 123.456
resource := resource.New(key.String("rk1", "rv11"))
testSpan := &export.SpanData{
SpanContext: core.SpanContext{
SpanContext: trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
},

View File

@ -30,7 +30,6 @@ import (
"github.com/stretchr/testify/require"
"google.golang.org/grpc/codes"
"go.opentelemetry.io/otel/api/core"
"go.opentelemetry.io/otel/api/trace"
export "go.opentelemetry.io/otel/sdk/export/trace"
)
@ -137,11 +136,11 @@ func TestExportSpans(t *testing.T) {
spans := []*export.SpanData{
// parent
{
SpanContext: core.SpanContext{
TraceID: core.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F},
SpanID: core.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8},
SpanContext: trace.SpanContext{
TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F},
SpanID: trace.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8},
},
ParentSpanID: core.SpanID{},
ParentSpanID: trace.SpanID{},
SpanKind: trace.SpanKindServer,
Name: "foo",
StartTime: time.Date(2020, time.March, 11, 19, 24, 0, 0, time.UTC),
@ -153,11 +152,11 @@ func TestExportSpans(t *testing.T) {
},
// child
{
SpanContext: core.SpanContext{
TraceID: core.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F},
SpanID: core.SpanID{0xDF, 0xDE, 0xDD, 0xDC, 0xDB, 0xDA, 0xD9, 0xD8},
SpanContext: trace.SpanContext{
TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F},
SpanID: trace.SpanID{0xDF, 0xDE, 0xDD, 0xDC, 0xDB, 0xDA, 0xD9, 0xD8},
},
ParentSpanID: core.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8},
ParentSpanID: trace.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8},
SpanKind: trace.SpanKindServer,
Name: "bar",
StartTime: time.Date(2020, time.March, 11, 19, 24, 15, 0, time.UTC),

View File

@ -62,18 +62,18 @@ func toZipkinSpanContext(data *export.SpanData) zkmodel.SpanContext {
}
}
func toZipkinTraceID(traceID core.TraceID) zkmodel.TraceID {
func toZipkinTraceID(traceID trace.TraceID) zkmodel.TraceID {
return zkmodel.TraceID{
High: binary.BigEndian.Uint64(traceID[:8]),
Low: binary.BigEndian.Uint64(traceID[8:]),
}
}
func toZipkinID(spanID core.SpanID) zkmodel.ID {
func toZipkinID(spanID trace.SpanID) zkmodel.ID {
return zkmodel.ID(binary.BigEndian.Uint64(spanID[:]))
}
func toZipkinParentID(spanID core.SpanID) *zkmodel.ID {
func toZipkinParentID(spanID trace.SpanID) *zkmodel.ID {
if spanID.IsValid() {
id := toZipkinID(spanID)
return &id

View File

@ -32,11 +32,11 @@ func TestModelConversion(t *testing.T) {
inputBatch := []*export.SpanData{
// typical span data
{
SpanContext: core.SpanContext{
TraceID: core.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F},
SpanID: core.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8},
SpanContext: trace.SpanContext{
TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F},
SpanID: trace.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8},
},
ParentSpanID: core.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38},
ParentSpanID: trace.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38},
SpanKind: trace.SpanKindServer,
Name: "foo",
StartTime: time.Date(2020, time.March, 11, 19, 24, 0, 0, time.UTC),
@ -65,11 +65,11 @@ func TestModelConversion(t *testing.T) {
// span data with no parent (same as typical, but has
// invalid parent)
{
SpanContext: core.SpanContext{
TraceID: core.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F},
SpanID: core.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8},
SpanContext: trace.SpanContext{
TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F},
SpanID: trace.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8},
},
ParentSpanID: core.SpanID{},
ParentSpanID: trace.SpanID{},
SpanKind: trace.SpanKindServer,
Name: "foo",
StartTime: time.Date(2020, time.March, 11, 19, 24, 0, 0, time.UTC),
@ -97,11 +97,11 @@ func TestModelConversion(t *testing.T) {
},
// span data of unspecified kind
{
SpanContext: core.SpanContext{
TraceID: core.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F},
SpanID: core.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8},
SpanContext: trace.SpanContext{
TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F},
SpanID: trace.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8},
},
ParentSpanID: core.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38},
ParentSpanID: trace.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38},
SpanKind: trace.SpanKindUnspecified,
Name: "foo",
StartTime: time.Date(2020, time.March, 11, 19, 24, 0, 0, time.UTC),
@ -129,11 +129,11 @@ func TestModelConversion(t *testing.T) {
},
// span data of internal kind
{
SpanContext: core.SpanContext{
TraceID: core.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F},
SpanID: core.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8},
SpanContext: trace.SpanContext{
TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F},
SpanID: trace.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8},
},
ParentSpanID: core.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38},
ParentSpanID: trace.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38},
SpanKind: trace.SpanKindInternal,
Name: "foo",
StartTime: time.Date(2020, time.March, 11, 19, 24, 0, 0, time.UTC),
@ -161,11 +161,11 @@ func TestModelConversion(t *testing.T) {
},
// span data of client kind
{
SpanContext: core.SpanContext{
TraceID: core.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F},
SpanID: core.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8},
SpanContext: trace.SpanContext{
TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F},
SpanID: trace.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8},
},
ParentSpanID: core.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38},
ParentSpanID: trace.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38},
SpanKind: trace.SpanKindClient,
Name: "foo",
StartTime: time.Date(2020, time.March, 11, 19, 24, 0, 0, time.UTC),
@ -193,11 +193,11 @@ func TestModelConversion(t *testing.T) {
},
// span data of producer kind
{
SpanContext: core.SpanContext{
TraceID: core.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F},
SpanID: core.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8},
SpanContext: trace.SpanContext{
TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F},
SpanID: trace.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8},
},
ParentSpanID: core.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38},
ParentSpanID: trace.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38},
SpanKind: trace.SpanKindProducer,
Name: "foo",
StartTime: time.Date(2020, time.March, 11, 19, 24, 0, 0, time.UTC),
@ -225,11 +225,11 @@ func TestModelConversion(t *testing.T) {
},
// span data of consumer kind
{
SpanContext: core.SpanContext{
TraceID: core.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F},
SpanID: core.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8},
SpanContext: trace.SpanContext{
TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F},
SpanID: trace.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8},
},
ParentSpanID: core.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38},
ParentSpanID: trace.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38},
SpanKind: trace.SpanKindConsumer,
Name: "foo",
StartTime: time.Date(2020, time.March, 11, 19, 24, 0, 0, time.UTC),
@ -257,11 +257,11 @@ func TestModelConversion(t *testing.T) {
},
// span data with no events
{
SpanContext: core.SpanContext{
TraceID: core.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F},
SpanID: core.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8},
SpanContext: trace.SpanContext{
TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F},
SpanID: trace.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8},
},
ParentSpanID: core.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38},
ParentSpanID: trace.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38},
SpanKind: trace.SpanKindServer,
Name: "foo",
StartTime: time.Date(2020, time.March, 11, 19, 24, 0, 0, time.UTC),
@ -276,11 +276,11 @@ func TestModelConversion(t *testing.T) {
},
// span data with an "error" attribute set to "false"
{
SpanContext: core.SpanContext{
TraceID: core.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F},
SpanID: core.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8},
SpanContext: trace.SpanContext{
TraceID: trace.TraceID{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F},
SpanID: trace.SpanID{0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8},
},
ParentSpanID: core.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38},
ParentSpanID: trace.SpanID{0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38},
SpanKind: trace.SpanKindServer,
Name: "foo",
StartTime: time.Date(2020, time.March, 11, 19, 24, 0, 0, time.UTC),

View File

@ -26,7 +26,7 @@ import (
// MockSpan is a mock span used in association with MockTracer for testing purpose only.
type MockSpan struct {
sc core.SpanContext
sc apitrace.SpanContext
tracer apitrace.Tracer
Name string
}
@ -35,9 +35,9 @@ var _ apitrace.Span = (*MockSpan)(nil)
// SpanContext returns associated core.SpanContext. If the receiver is nil it returns
// an empty core.SpanContext
func (ms *MockSpan) SpanContext() core.SpanContext {
func (ms *MockSpan) SpanContext() apitrace.SpanContext {
if ms == nil {
return core.EmptySpanContext()
return apitrace.EmptySpanContext()
}
return ms.sc
}

View File

@ -20,7 +20,6 @@ import (
"encoding/binary"
"sync/atomic"
"go.opentelemetry.io/otel/api/core"
apitrace "go.opentelemetry.io/otel/api/trace"
"go.opentelemetry.io/otel/internal/trace/parent"
)
@ -62,15 +61,15 @@ func (mt *MockTracer) Start(ctx context.Context, name string, o ...apitrace.Star
op(&opts)
}
var span *MockSpan
var sc core.SpanContext
var sc apitrace.SpanContext
parentSpanContext, _, _ := parent.GetSpanContextAndLinks(ctx, opts.NewRoot)
if !parentSpanContext.IsValid() {
sc = core.SpanContext{}
sc = apitrace.SpanContext{}
_, _ = rand.Read(sc.TraceID[:])
if mt.Sampled {
sc.TraceFlags = core.TraceFlagsSampled
sc.TraceFlags = apitrace.TraceFlagsSampled
}
} else {
sc = parentSpanContext

View File

@ -22,7 +22,7 @@ import (
"go.opentelemetry.io/otel/api/trace"
)
func GetSpanContextAndLinks(ctx context.Context, ignoreContext bool) (core.SpanContext, bool, []trace.Link) {
func GetSpanContextAndLinks(ctx context.Context, ignoreContext bool) (trace.SpanContext, bool, []trace.Link) {
lsctx := trace.SpanFromContext(ctx).SpanContext()
rsctx := trace.RemoteSpanContextFromContext(ctx)
@ -30,7 +30,7 @@ func GetSpanContextAndLinks(ctx context.Context, ignoreContext bool) (core.SpanC
links := addLinkIfValid(nil, lsctx, "current")
links = addLinkIfValid(links, rsctx, "remote")
return core.EmptySpanContext(), false, links
return trace.EmptySpanContext(), false, links
}
if lsctx.IsValid() {
return lsctx, false, nil
@ -38,10 +38,10 @@ func GetSpanContextAndLinks(ctx context.Context, ignoreContext bool) (core.SpanC
if rsctx.IsValid() {
return rsctx, true, nil
}
return core.EmptySpanContext(), false, nil
return trace.EmptySpanContext(), false, nil
}
func addLinkIfValid(links []trace.Link, sc core.SpanContext, kind string) []trace.Link {
func addLinkIfValid(links []trace.Link, sc trace.SpanContext, kind string) []trace.Link {
if !sc.IsValid() {
return links
}

View File

@ -54,7 +54,7 @@ func Inject(ctx context.Context, metadata *metadata.MD) {
// Extract returns the correlation context and span context that
// another service encoded in the gRPC metadata object with Inject.
// This function is meant to be used on incoming requests.
func Extract(ctx context.Context, metadata *metadata.MD) ([]core.KeyValue, core.SpanContext) {
func Extract(ctx context.Context, metadata *metadata.MD) ([]core.KeyValue, trace.SpanContext) {
ctx = propagation.ExtractHTTP(ctx, global.Propagators(), &metadataSupplier{
metadata: metadata,
})

View File

@ -32,7 +32,7 @@ var (
)
// Returns the Attributes, Context Entries, and SpanContext that were encoded by Inject.
func Extract(ctx context.Context, req *http.Request) ([]core.KeyValue, []core.KeyValue, core.SpanContext) {
func Extract(ctx context.Context, req *http.Request) ([]core.KeyValue, []core.KeyValue, trace.SpanContext) {
ctx = propagation.ExtractHTTP(ctx, global.Propagators(), req.Header)
attrs := []core.KeyValue{

View File

@ -22,7 +22,6 @@ import (
"net/http/httptest"
"testing"
"go.opentelemetry.io/otel/api/core"
"go.opentelemetry.io/otel/api/global"
"go.opentelemetry.io/otel/api/propagation"
"go.opentelemetry.io/otel/api/trace"
@ -37,7 +36,7 @@ func TestTransportBasics(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := propagation.ExtractHTTP(r.Context(), global.Propagators(), r.Header)
span := trace.RemoteSpanContextFromContext(ctx)
tgtID, err := core.SpanIDFromHex(fmt.Sprintf("%016x", id))
tgtID, err := trace.SpanIDFromHex(fmt.Sprintf("%016x", id))
if err != nil {
t.Fatalf("Error converting id to SpanID: %s", err.Error())
}

View File

@ -48,8 +48,8 @@ type SpanBatcher interface {
// SpanData contains all the information collected by a span.
type SpanData struct {
SpanContext core.SpanContext
ParentSpanID core.SpanID
SpanContext apitrace.SpanContext
ParentSpanID apitrace.SpanID
SpanKind apitrace.SpanKind
Name string
StartTime time.Time

View File

@ -21,7 +21,6 @@ import (
"testing"
"time"
"go.opentelemetry.io/otel/api/core"
apitrace "go.opentelemetry.io/otel/api/trace"
export "go.opentelemetry.io/otel/sdk/export/trace"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
@ -203,7 +202,7 @@ func generateSpan(t *testing.T, parallel bool, tr apitrace.Tracer, option testOp
for i := 0; i < option.genNumSpans; i++ {
binary.BigEndian.PutUint64(sc.TraceID[0:8], uint64(i+1))
wg.Add(1)
f := func(sc core.SpanContext) {
f := func(sc apitrace.SpanContext) {
ctx := apitrace.ContextWithRemoteSpanContext(context.Background(), sc)
_, span := tr.Start(ctx, option.name)
span.End()
@ -218,10 +217,10 @@ func generateSpan(t *testing.T, parallel bool, tr apitrace.Tracer, option testOp
wg.Wait()
}
func getSpanContext() core.SpanContext {
tid, _ := core.TraceIDFromHex("01020304050607080102040810203040")
sid, _ := core.SpanIDFromHex("0102040810203040")
return core.SpanContext{
func getSpanContext() apitrace.SpanContext {
tid, _ := apitrace.TraceIDFromHex("01020304050607080102040810203040")
sid, _ := apitrace.SpanIDFromHex("0102040810203040")
return apitrace.SpanContext{
TraceID: tid,
SpanID: sid,
TraceFlags: 0x1,

View File

@ -18,7 +18,6 @@ import (
"context"
"testing"
"go.opentelemetry.io/otel/api/core"
"go.opentelemetry.io/otel/api/key"
apitrace "go.opentelemetry.io/otel/api/trace"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
@ -134,8 +133,8 @@ func BenchmarkSpanWithAttributes_all_2x(b *testing.B) {
}
func BenchmarkTraceID_DotString(b *testing.B) {
t, _ := core.TraceIDFromHex("0000000000000001000000000000002a")
sc := core.SpanContext{TraceID: t}
t, _ := apitrace.TraceIDFromHex("0000000000000001000000000000002a")
sc := apitrace.SpanContext{TraceID: t}
want := "0000000000000001000000000000002a"
for i := 0; i < b.N; i++ {
@ -146,7 +145,7 @@ func BenchmarkTraceID_DotString(b *testing.B) {
}
func BenchmarkSpanID_DotString(b *testing.B) {
sc := core.SpanContext{SpanID: core.SpanID{1}}
sc := apitrace.SpanContext{SpanID: apitrace.SpanID{1}}
want := "0100000000000000"
for i := 0; i < b.N; i++ {
if got := sc.SpanID.String(); got != want {

View File

@ -18,7 +18,8 @@ import (
"math/rand"
"sync"
"go.opentelemetry.io/otel/api/core"
"go.opentelemetry.io/otel/api/trace"
"go.opentelemetry.io/otel/sdk/trace/internal"
)
@ -30,20 +31,20 @@ type defaultIDGenerator struct {
var _ internal.IDGenerator = &defaultIDGenerator{}
// NewSpanID returns a non-zero span ID from a randomly-chosen sequence.
func (gen *defaultIDGenerator) NewSpanID() core.SpanID {
func (gen *defaultIDGenerator) NewSpanID() trace.SpanID {
gen.Lock()
defer gen.Unlock()
sid := core.SpanID{}
sid := trace.SpanID{}
gen.randSource.Read(sid[:])
return sid
}
// NewTraceID returns a non-zero trace ID from a randomly-chosen sequence.
// mu should be held while this function is called.
func (gen *defaultIDGenerator) NewTraceID() core.TraceID {
func (gen *defaultIDGenerator) NewTraceID() trace.TraceID {
gen.Lock()
defer gen.Unlock()
tid := core.TraceID{}
tid := trace.TraceID{}
gen.randSource.Read(tid[:])
return tid
}

View File

@ -15,10 +15,12 @@
// Package internal provides trace internals.
package internal
import "go.opentelemetry.io/otel/api/core"
import (
"go.opentelemetry.io/otel/api/trace"
)
// IDGenerator allows custom generators for TraceId and SpanId.
type IDGenerator interface {
NewTraceID() core.TraceID
NewSpanID() core.SpanID
NewTraceID() trace.TraceID
NewSpanID() trace.SpanID
}

View File

@ -30,9 +30,9 @@ type Sampler interface {
// SamplingParameters contains the values passed to a Sampler.
type SamplingParameters struct {
ParentContext core.SpanContext
TraceID core.TraceID
SpanID core.SpanID
ParentContext api.SpanContext
TraceID api.TraceID
SpanID api.SpanID
Name string
HasRemoteParent bool
Kind api.SpanKind

View File

@ -17,18 +17,19 @@ package trace_test
import (
"testing"
"go.opentelemetry.io/otel/api/core"
"go.opentelemetry.io/otel/api/trace"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
)
func TestAlwaysParentSampleWithParentSampled(t *testing.T) {
sampler := sdktrace.AlwaysParentSample()
traceID, _ := core.TraceIDFromHex("4bf92f3577b34da6a3ce929d0e0e4736")
spanID, _ := core.SpanIDFromHex("00f067aa0ba902b7")
parentCtx := core.SpanContext{
traceID, _ := trace.TraceIDFromHex("4bf92f3577b34da6a3ce929d0e0e4736")
spanID, _ := trace.SpanIDFromHex("00f067aa0ba902b7")
parentCtx := trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
TraceFlags: core.TraceFlagsSampled,
TraceFlags: trace.TraceFlagsSampled,
}
if sampler.ShouldSample(sdktrace.SamplingParameters{ParentContext: parentCtx}).Decision != sdktrace.RecordAndSampled {
t.Error("Sampling decision should be RecordAndSampled")
@ -37,9 +38,9 @@ func TestAlwaysParentSampleWithParentSampled(t *testing.T) {
func TestAlwaysParentSampleWithParentNotSampled(t *testing.T) {
sampler := sdktrace.AlwaysParentSample()
traceID, _ := core.TraceIDFromHex("4bf92f3577b34da6a3ce929d0e0e4736")
spanID, _ := core.SpanIDFromHex("00f067aa0ba902b7")
parentCtx := core.SpanContext{
traceID, _ := trace.TraceIDFromHex("4bf92f3577b34da6a3ce929d0e0e4736")
spanID, _ := trace.SpanIDFromHex("00f067aa0ba902b7")
parentCtx := trace.SpanContext{
TraceID: traceID,
SpanID: spanID,
}

View File

@ -18,7 +18,6 @@ import (
"context"
"testing"
"go.opentelemetry.io/otel/api/core"
apitrace "go.opentelemetry.io/otel/api/trace"
export "go.opentelemetry.io/otel/sdk/export/trace"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
@ -58,9 +57,9 @@ func TestSimpleSpanProcessorOnEnd(t *testing.T) {
tp.RegisterSpanProcessor(ssp)
tr := tp.Tracer("SimpleSpanProcessor")
tid, _ := core.TraceIDFromHex("01020304050607080102040810203040")
sid, _ := core.SpanIDFromHex("0102040810203040")
sc := core.SpanContext{
tid, _ := apitrace.TraceIDFromHex("01020304050607080102040810203040")
sid, _ := apitrace.SpanIDFromHex("0102040810203040")
sc := apitrace.SpanContext{
TraceID: tid,
SpanID: sid,
TraceFlags: 0x1,

View File

@ -45,7 +45,7 @@ type span struct {
// SpanContext, so that the trace ID is propagated.
data *export.SpanData
mu sync.Mutex // protects the contents of *data (but not the pointer value.)
spanContext core.SpanContext
spanContext apitrace.SpanContext
// attributes are capped at configured limit. When the capacity is reached an oldest entry
// is removed to create room for a new entry.
@ -67,9 +67,9 @@ type span struct {
var _ apitrace.Span = &span{}
func (s *span) SpanContext() core.SpanContext {
func (s *span) SpanContext() apitrace.SpanContext {
if s == nil {
return core.EmptySpanContext()
return apitrace.EmptySpanContext()
}
return s.spanContext
}
@ -212,9 +212,9 @@ func (s *span) SetName(name string) {
s.data.Name = name
// SAMPLING
noParent := !s.data.ParentSpanID.IsValid()
var ctx core.SpanContext
var ctx apitrace.SpanContext
if noParent {
ctx = core.EmptySpanContext()
ctx = apitrace.EmptySpanContext()
} else {
// FIXME: Where do we get the parent context from?
// From SpanStore?
@ -303,14 +303,14 @@ func (s *span) addChild() {
s.mu.Unlock()
}
func startSpanInternal(tr *tracer, name string, parent core.SpanContext, remoteParent bool, o apitrace.StartConfig) *span {
func startSpanInternal(tr *tracer, name string, parent apitrace.SpanContext, remoteParent bool, o apitrace.StartConfig) *span {
var noParent bool
span := &span{}
span.spanContext = parent
cfg := tr.provider.config.Load().(*Config)
if parent == core.EmptySpanContext() {
if parent == apitrace.EmptySpanContext() {
span.spanContext.TraceID = cfg.IDGenerator.NewTraceID()
noParent = true
}
@ -370,7 +370,7 @@ func startSpanInternal(tr *tracer, name string, parent core.SpanContext, remoteP
type samplingData struct {
noParent bool
remoteParent bool
parent core.SpanContext
parent apitrace.SpanContext
name string
cfg *Config
span *span
@ -403,13 +403,13 @@ func makeSamplingDecision(data samplingData) SamplingResult {
Links: data.links,
})
if sampled.Decision == RecordAndSampled {
spanContext.TraceFlags |= core.TraceFlagsSampled
spanContext.TraceFlags |= apitrace.TraceFlagsSampled
} else {
spanContext.TraceFlags &^= core.TraceFlagsSampled
spanContext.TraceFlags &^= apitrace.TraceFlagsSampled
}
return sampled
}
if data.parent.TraceFlags&core.TraceFlagsSampled != 0 {
if data.parent.TraceFlags&apitrace.TraceFlagsSampled != 0 {
return SamplingResult{Decision: RecordAndSampled}
}
return SamplingResult{Decision: NotRecord}

View File

@ -38,13 +38,13 @@ import (
)
var (
tid core.TraceID
sid core.SpanID
tid apitrace.TraceID
sid apitrace.SpanID
)
func init() {
tid, _ = core.TraceIDFromHex("01020304050607080102040810203040")
sid, _ = core.SpanIDFromHex("0102040810203040")
tid, _ = apitrace.TraceIDFromHex("01020304050607080102040810203040")
sid, _ = apitrace.SpanIDFromHex("0102040810203040")
}
func TestTracerFollowsExpectedAPIBehaviour(t *testing.T) {
@ -195,12 +195,12 @@ func TestSampling(t *testing.T) {
for i := 0; i < total; i++ {
ctx := context.Background()
if tc.parent {
psc := core.SpanContext{
psc := apitrace.SpanContext{
TraceID: idg.NewTraceID(),
SpanID: idg.NewSpanID(),
}
if tc.sampledParent {
psc.TraceFlags = core.TraceFlagsSampled
psc.TraceFlags = apitrace.TraceFlagsSampled
}
ctx = apitrace.ContextWithRemoteSpanContext(ctx, psc)
}
@ -231,7 +231,7 @@ func TestStartSpanWithParent(t *testing.T) {
tr := tp.Tracer("SpanWithParent")
ctx := context.Background()
sc1 := core.SpanContext{
sc1 := apitrace.SpanContext{
TraceID: tid,
SpanID: sid,
TraceFlags: 0x1,
@ -246,7 +246,7 @@ func TestStartSpanWithParent(t *testing.T) {
t.Error(err)
}
sc2 := core.SpanContext{
sc2 := apitrace.SpanContext{
TraceID: tid,
SpanID: sid,
TraceFlags: 0x1,
@ -283,7 +283,7 @@ func TestSetSpanAttributesOnStart(t *testing.T) {
}
want := &export.SpanData{
SpanContext: core.SpanContext{
SpanContext: apitrace.SpanContext{
TraceID: tid,
TraceFlags: 0x1,
},
@ -312,7 +312,7 @@ func TestSetSpanAttributes(t *testing.T) {
}
want := &export.SpanData{
SpanContext: core.SpanContext{
SpanContext: apitrace.SpanContext{
TraceID: tid,
TraceFlags: 0x1,
},
@ -347,7 +347,7 @@ func TestSetSpanAttributesOverLimit(t *testing.T) {
}
want := &export.SpanData{
SpanContext: core.SpanContext{
SpanContext: apitrace.SpanContext{
TraceID: tid,
TraceFlags: 0x1,
},
@ -392,7 +392,7 @@ func TestEvents(t *testing.T) {
}
want := &export.SpanData{
SpanContext: core.SpanContext{
SpanContext: apitrace.SpanContext{
TraceID: tid,
TraceFlags: 0x1,
},
@ -442,7 +442,7 @@ func TestEventsOverLimit(t *testing.T) {
}
want := &export.SpanData{
SpanContext: core.SpanContext{
SpanContext: apitrace.SpanContext{
TraceID: tid,
TraceFlags: 0x1,
},
@ -469,8 +469,8 @@ func TestLinks(t *testing.T) {
k2v2 := key.New("key2").String("value2")
k3v3 := key.New("key3").String("value3")
sc1 := core.SpanContext{TraceID: core.TraceID([16]byte{1, 1}), SpanID: core.SpanID{3}}
sc2 := core.SpanContext{TraceID: core.TraceID([16]byte{1, 1}), SpanID: core.SpanID{3}}
sc1 := apitrace.SpanContext{TraceID: apitrace.TraceID([16]byte{1, 1}), SpanID: apitrace.SpanID{3}}
sc2 := apitrace.SpanContext{TraceID: apitrace.TraceID([16]byte{1, 1}), SpanID: apitrace.SpanID{3}}
span := startSpan(tp, "Links",
apitrace.LinkedTo(sc1, key.New("key1").String("value1")),
@ -486,7 +486,7 @@ func TestLinks(t *testing.T) {
}
want := &export.SpanData{
SpanContext: core.SpanContext{
SpanContext: apitrace.SpanContext{
TraceID: tid,
TraceFlags: 0x1,
},
@ -508,9 +508,9 @@ func TestLinksOverLimit(t *testing.T) {
te := &testExporter{}
cfg := Config{MaxLinksPerSpan: 2}
sc1 := core.SpanContext{TraceID: core.TraceID([16]byte{1, 1}), SpanID: core.SpanID{3}}
sc2 := core.SpanContext{TraceID: core.TraceID([16]byte{1, 1}), SpanID: core.SpanID{3}}
sc3 := core.SpanContext{TraceID: core.TraceID([16]byte{1, 1}), SpanID: core.SpanID{3}}
sc1 := apitrace.SpanContext{TraceID: apitrace.TraceID([16]byte{1, 1}), SpanID: apitrace.SpanID{3}}
sc2 := apitrace.SpanContext{TraceID: apitrace.TraceID([16]byte{1, 1}), SpanID: apitrace.SpanID{3}}
sc3 := apitrace.SpanContext{TraceID: apitrace.TraceID([16]byte{1, 1}), SpanID: apitrace.SpanID{3}}
tp, _ := NewProvider(WithConfig(cfg), WithSyncer(te))
@ -529,7 +529,7 @@ func TestLinksOverLimit(t *testing.T) {
}
want := &export.SpanData{
SpanContext: core.SpanContext{
SpanContext: apitrace.SpanContext{
TraceID: tid,
TraceFlags: 0x1,
},
@ -554,7 +554,7 @@ func TestSetSpanName(t *testing.T) {
ctx := context.Background()
want := "SpanName-1"
ctx = apitrace.ContextWithRemoteSpanContext(ctx, core.SpanContext{
ctx = apitrace.ContextWithRemoteSpanContext(ctx, apitrace.SpanContext{
TraceID: tid,
SpanID: sid,
TraceFlags: 1,
@ -582,7 +582,7 @@ func TestSetSpanStatus(t *testing.T) {
}
want := &export.SpanData{
SpanContext: core.SpanContext{
SpanContext: apitrace.SpanContext{
TraceID: tid,
TraceFlags: 0x1,
},
@ -604,8 +604,8 @@ func cmpDiff(x, y interface{}) string {
cmp.AllowUnexported(export.Event{}))
}
func remoteSpanContext() core.SpanContext {
return core.SpanContext{
func remoteSpanContext() apitrace.SpanContext {
return apitrace.SpanContext{
TraceID: tid,
SpanID: sid,
TraceFlags: 1,
@ -614,7 +614,7 @@ func remoteSpanContext() core.SpanContext {
// checkChild is test utility function that tests that c has fields set appropriately,
// given that it is a child span of p.
func checkChild(p core.SpanContext, apiSpan apitrace.Span) error {
func checkChild(p apitrace.SpanContext, apiSpan apitrace.Span) error {
s := apiSpan.(*span)
if s == nil {
return fmt.Errorf("got nil child span, want non-nil")
@ -681,7 +681,7 @@ func endSpan(te *testExporter, span apitrace.Span) (*export.SpanData, error) {
if !got.SpanContext.SpanID.IsValid() {
return nil, fmt.Errorf("exporting span: expected nonzero SpanID")
}
got.SpanContext.SpanID = core.SpanID{}
got.SpanContext.SpanID = apitrace.SpanID{}
if !checkTime(&got.StartTime) {
return nil, fmt.Errorf("exporting span: expected nonzero StartTime")
}
@ -833,12 +833,12 @@ func TestExecutionTracerTaskEnd(t *testing.T) {
s.executionTracerTaskEnd = executionTracerTaskEnd
spans = append(spans, s) // never sample
tID, _ := core.TraceIDFromHex("0102030405060708090a0b0c0d0e0f")
sID, _ := core.SpanIDFromHex("0001020304050607")
tID, _ := apitrace.TraceIDFromHex("0102030405060708090a0b0c0d0e0f")
sID, _ := apitrace.SpanIDFromHex("0001020304050607")
ctx := context.Background()
ctx = apitrace.ContextWithRemoteSpanContext(ctx,
core.SpanContext{
apitrace.SpanContext{
TraceID: tID,
SpanID: sID,
TraceFlags: 0,
@ -925,7 +925,7 @@ func TestRecordError(t *testing.T) {
}
want := &export.SpanData{
SpanContext: core.SpanContext{
SpanContext: apitrace.SpanContext{
TraceID: tid,
TraceFlags: 0x1,
},
@ -969,7 +969,7 @@ func TestRecordErrorWithStatus(t *testing.T) {
}
want := &export.SpanData{
SpanContext: core.SpanContext{
SpanContext: apitrace.SpanContext{
TraceID: tid,
TraceFlags: 0x1,
},
@ -1008,7 +1008,7 @@ func TestRecordErrorNil(t *testing.T) {
}
want := &export.SpanData{
SpanContext: core.SpanContext{
SpanContext: apitrace.SpanContext{
TraceID: tid,
TraceFlags: 0x1,
},
@ -1075,7 +1075,7 @@ func TestWithResource(t *testing.T) {
}
want := &export.SpanData{
SpanContext: core.SpanContext{
SpanContext: apitrace.SpanContext{
TraceID: tid,
TraceFlags: 0x1,
},