Skip to content

Commit

Permalink
[jaeger] Stop ignoring uints (#945)
Browse files Browse the repository at this point in the history
* Stop ignoring uints

* Ignore values that overflow
  • Loading branch information
mhr3 authored Jul 17, 2020
1 parent 4f3fab3 commit d6ad4d4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
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

0 comments on commit d6ad4d4

Please sign in to comment.