1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-11-23 22:34:47 +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

@@ -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())
}