diff --git a/exporter/trace/jaeger/jaeger.go b/exporter/trace/jaeger/jaeger.go index 80cb516b505..5cc83e362f9 100644 --- a/exporter/trace/jaeger/jaeger.go +++ b/exporter/trace/jaeger/jaeger.go @@ -159,6 +159,7 @@ func spanDataToThrift(data *export.SpanData) *gen.Span { tags = append(tags, getInt64Tag("status.code", int64(data.Status)), getStringTag("status.message", data.Status.String()), + getStringTag("span.kind", data.SpanKind.String()), ) // Ensure that if Status.Code is not OK, that we set the "error" tag on the Jaeger span. diff --git a/exporter/trace/jaeger/jaeger_test.go b/exporter/trace/jaeger/jaeger_test.go index e0bbdb763ce..17b2d37ab05 100644 --- a/exporter/trace/jaeger/jaeger_test.go +++ b/exporter/trace/jaeger/jaeger_test.go @@ -158,6 +158,7 @@ func Test_spanDataToThrift(t *testing.T) { doubleValue := 123.456 boolTrue := true statusMessage := "Unknown" + spanKind := "client" tests := []struct { name string @@ -191,7 +192,8 @@ func Test_spanDataToThrift(t *testing.T) { MessageEvents: []export.Event{ {Name: eventNameValue, Attributes: []core.KeyValue{key.String("k1", keyValue)}, Time: now}, }, - Status: codes.Unknown, + Status: codes.Unknown, + SpanKind: apitrace.SpanKindClient, }, want: &gen.Span{ TraceIdLow: 651345242494996240, @@ -206,6 +208,7 @@ func Test_spanDataToThrift(t *testing.T) { {Key: "error", VType: gen.TagType_BOOL, VBool: &boolTrue}, {Key: "status.code", VType: gen.TagType_LONG, VLong: &statusCodeValue}, {Key: "status.message", VType: gen.TagType_STRING, VStr: &statusMessage}, + {Key: "span.kind", VType: gen.TagType_STRING, VStr: &spanKind}, }, References: []*gen.SpanRef{ { diff --git a/plugin/grpctrace/grpctrace.go b/plugin/grpctrace/grpctrace.go index 05e6f05e646..a60ec380574 100644 --- a/plugin/grpctrace/grpctrace.go +++ b/plugin/grpctrace/grpctrace.go @@ -16,7 +16,6 @@ package grpctrace import ( "context" - "strings" "google.golang.org/grpc/metadata" @@ -34,11 +33,14 @@ type metadataSupplier struct { func (s *metadataSupplier) Get(key string) string { values := s.metadata.Get(key) - return strings.Join(values, ",") + if len(values) == 0 { + return "" + } + return values[0] } func (s *metadataSupplier) Set(key string, value string) { - s.metadata.Append(key, value) + s.metadata.Set(key, value) } // Inject injects correlation context and span context into the gRPC