You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-08-10 22:31:50 +02:00
Send span.kind to jaeger and overwrite grpc metadata instead of using append (#441)
Co-authored-by: Rahul Patel <rghetia@yahoo.com>
This commit is contained in:
@@ -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.
|
||||
|
@@ -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{
|
||||
{
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user