Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[jaeger] Stop ignoring uints #945

Merged
merged 2 commits into from
Jul 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions exporters/trace/jaeger/jaeger.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,22 @@ func keyValueToTag(keyValue kv.KeyValue) *gen.Tag {
VLong: &i,
VType: gen.TagType_LONG,
}
case value.UINT32:
i := int64(keyValue.Value.AsUint32())
tag = &gen.Tag{
Key: string(keyValue.Key),
VLong: &i,
VType: gen.TagType_LONG,
}
case value.UINT64:
// we'll ignore the value if it overflows
if i := int64(keyValue.Value.AsUint64()); i >= 0 {
tag = &gen.Tag{
Key: string(keyValue.Key),
VLong: &i,
VType: gen.TagType_LONG,
}
}
case value.FLOAT32:
f := float64(keyValue.Value.AsFloat32())
tag = &gen.Tag{
Expand Down
7 changes: 5 additions & 2 deletions exporters/trace/jaeger/jaeger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package jaeger
import (
"context"
"encoding/binary"
"math"
"os"
"sort"
"testing"
Expand Down Expand Up @@ -213,6 +214,7 @@ func Test_spanDataToThrift(t *testing.T) {
keyValue := "value"
statusCodeValue := int64(2)
doubleValue := 123.456
uintValue := int64(123)
boolTrue := true
statusMessage := "this is a problem"
spanKind := "client"
Expand Down Expand Up @@ -245,8 +247,8 @@ func Test_spanDataToThrift(t *testing.T) {
Attributes: []kv.KeyValue{
kv.String("key", keyValue),
kv.Float64("double", doubleValue),
// Jaeger doesn't handle Uint tags, this should be ignored.
kv.Uint64("ignored", 123),
kv.Uint64("uint", uint64(uintValue)),
kv.Uint64("overflows", math.MaxUint64),
},
MessageEvents: []export.Event{
{Name: eventNameValue, Attributes: []kv.KeyValue{kv.String("k1", keyValue)}, Time: now},
Expand All @@ -266,6 +268,7 @@ func Test_spanDataToThrift(t *testing.T) {
Tags: []*gen.Tag{
{Key: "double", VType: gen.TagType_DOUBLE, VDouble: &doubleValue},
{Key: "key", VType: gen.TagType_STRING, VStr: &keyValue},
{Key: "uint", VType: gen.TagType_LONG, VLong: &uintValue},
{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},
Expand Down