mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-04-23 11:58:56 +02:00
export Links in Jaeger exporter. (#173)
This commit is contained in:
parent
b1bb19aa80
commit
ab58cae33b
@ -182,16 +182,18 @@ func spanDataToThrift(data *trace.SpanData) *gen.Span {
|
|||||||
Fields: fields,
|
Fields: fields,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
//TODO: [rghetia] add links.
|
|
||||||
//
|
var refs []*gen.SpanRef
|
||||||
//var refs []*gen.SpanRef
|
for _, link := range data.Links {
|
||||||
//for _, link := range data.Links {
|
refs = append(refs, &gen.SpanRef{
|
||||||
// refs = append(refs, &gen.SpanRef{
|
TraceIdHigh: int64(link.TraceID.High),
|
||||||
// TraceIdHigh: bytesToInt64(link.TraceID[0:8]),
|
TraceIdLow: int64(link.TraceID.Low),
|
||||||
// TraceIdLow: bytesToInt64(link.TraceID[8:16]),
|
SpanId: int64(link.SpanID),
|
||||||
// SpanId: bytesToInt64(link.SpanID[:]),
|
// TODO(paivagustavo): properly set the reference type when specs are defined
|
||||||
// })
|
// see https://github.com/open-telemetry/opentelemetry-specification/issues/65
|
||||||
//}
|
RefType: gen.SpanRefType_CHILD_OF,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return &gen.Span{
|
return &gen.Span{
|
||||||
TraceIdHigh: int64(data.SpanContext.TraceID.High),
|
TraceIdHigh: int64(data.SpanContext.TraceID.High),
|
||||||
@ -204,8 +206,7 @@ func spanDataToThrift(data *trace.SpanData) *gen.Span {
|
|||||||
Duration: data.EndTime.Sub(data.StartTime).Nanoseconds() / 1000,
|
Duration: data.EndTime.Sub(data.StartTime).Nanoseconds() / 1000,
|
||||||
Tags: tags,
|
Tags: tags,
|
||||||
Logs: logs,
|
Logs: logs,
|
||||||
// TODO: goes with Links.
|
References: refs,
|
||||||
// References: refs,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,8 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
apitrace "go.opentelemetry.io/api/trace"
|
||||||
|
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
|
|
||||||
@ -34,6 +36,9 @@ func Test_spanDataToThrift(t *testing.T) {
|
|||||||
traceID := core.TraceID{High: 0x0102030405060708, Low: 0x090a0b0c0d0e0f10}
|
traceID := core.TraceID{High: 0x0102030405060708, Low: 0x090a0b0c0d0e0f10}
|
||||||
spanID := uint64(0x0102030405060708)
|
spanID := uint64(0x0102030405060708)
|
||||||
|
|
||||||
|
linkTraceID := core.TraceID{High: 0x0102030405060709, Low: 0x090a0b0c0d0e0f11}
|
||||||
|
linkSpanID := uint64(0x0102030405060709)
|
||||||
|
|
||||||
keyValue := "value"
|
keyValue := "value"
|
||||||
statusCodeValue := int64(2)
|
statusCodeValue := int64(2)
|
||||||
doubleValue := float64(123.456)
|
doubleValue := float64(123.456)
|
||||||
@ -55,6 +60,14 @@ func Test_spanDataToThrift(t *testing.T) {
|
|||||||
Name: "/foo",
|
Name: "/foo",
|
||||||
StartTime: now,
|
StartTime: now,
|
||||||
EndTime: now,
|
EndTime: now,
|
||||||
|
Links: []apitrace.Link{
|
||||||
|
apitrace.Link{
|
||||||
|
SpanContext: core.SpanContext{
|
||||||
|
TraceID: linkTraceID,
|
||||||
|
SpanID: linkSpanID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
Attributes: []core.KeyValue{
|
Attributes: []core.KeyValue{
|
||||||
{
|
{
|
||||||
Key: core.Key{Name: "key"},
|
Key: core.Key{Name: "key"},
|
||||||
@ -82,6 +95,14 @@ func Test_spanDataToThrift(t *testing.T) {
|
|||||||
{Key: "status.code", VType: gen.TagType_LONG, VLong: &statusCodeValue},
|
{Key: "status.code", VType: gen.TagType_LONG, VLong: &statusCodeValue},
|
||||||
{Key: "status.message", VType: gen.TagType_STRING, VStr: &statusMessage},
|
{Key: "status.message", VType: gen.TagType_STRING, VStr: &statusMessage},
|
||||||
},
|
},
|
||||||
|
References: []*gen.SpanRef{
|
||||||
|
&gen.SpanRef{
|
||||||
|
RefType: gen.SpanRefType_CHILD_OF,
|
||||||
|
TraceIdLow: int64(linkTraceID.Low),
|
||||||
|
TraceIdHigh: int64(linkTraceID.High),
|
||||||
|
SpanId: int64(linkSpanID),
|
||||||
|
},
|
||||||
|
},
|
||||||
// TODO [rghetia]: check Logs when event is added.
|
// TODO [rghetia]: check Logs when event is added.
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user