Skip to content

Commit 8fcdf8b

Browse files
amrmahdirghetia
andauthored
Send span.kind to jaeger and overwrite grpc metadata instead of using append (#441)
Co-authored-by: Rahul Patel <[email protected]>
1 parent 405a92a commit 8fcdf8b

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

exporter/trace/jaeger/jaeger.go

+1
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ func spanDataToThrift(data *export.SpanData) *gen.Span {
159159

160160
tags = append(tags, getInt64Tag("status.code", int64(data.Status)),
161161
getStringTag("status.message", data.Status.String()),
162+
getStringTag("span.kind", data.SpanKind.String()),
162163
)
163164

164165
// Ensure that if Status.Code is not OK, that we set the "error" tag on the Jaeger span.

exporter/trace/jaeger/jaeger_test.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ func Test_spanDataToThrift(t *testing.T) {
158158
doubleValue := 123.456
159159
boolTrue := true
160160
statusMessage := "Unknown"
161+
spanKind := "client"
161162

162163
tests := []struct {
163164
name string
@@ -191,7 +192,8 @@ func Test_spanDataToThrift(t *testing.T) {
191192
MessageEvents: []export.Event{
192193
{Name: eventNameValue, Attributes: []core.KeyValue{key.String("k1", keyValue)}, Time: now},
193194
},
194-
Status: codes.Unknown,
195+
Status: codes.Unknown,
196+
SpanKind: apitrace.SpanKindClient,
195197
},
196198
want: &gen.Span{
197199
TraceIdLow: 651345242494996240,
@@ -206,6 +208,7 @@ func Test_spanDataToThrift(t *testing.T) {
206208
{Key: "error", VType: gen.TagType_BOOL, VBool: &boolTrue},
207209
{Key: "status.code", VType: gen.TagType_LONG, VLong: &statusCodeValue},
208210
{Key: "status.message", VType: gen.TagType_STRING, VStr: &statusMessage},
211+
{Key: "span.kind", VType: gen.TagType_STRING, VStr: &spanKind},
209212
},
210213
References: []*gen.SpanRef{
211214
{

plugin/grpctrace/grpctrace.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package grpctrace
1616

1717
import (
1818
"context"
19-
"strings"
2019

2120
"google.golang.org/grpc/metadata"
2221

@@ -34,11 +33,14 @@ type metadataSupplier struct {
3433

3534
func (s *metadataSupplier) Get(key string) string {
3635
values := s.metadata.Get(key)
37-
return strings.Join(values, ",")
36+
if len(values) == 0 {
37+
return ""
38+
}
39+
return values[0]
3840
}
3941

4042
func (s *metadataSupplier) Set(key string, value string) {
41-
s.metadata.Append(key, value)
43+
s.metadata.Set(key, value)
4244
}
4345

4446
// Inject injects correlation context and span context into the gRPC

0 commit comments

Comments
 (0)