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

[Bug]: span tags of type int64 may lose precision #3958 PR No 2 #4034

Merged
merged 13 commits into from
Nov 9, 2022
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
5 changes: 5 additions & 0 deletions model/converter/json/fixtures/domain_01.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
"vType": "FLOAT64",
"vFloat64": 72.5
},
{
"key": "javascript_limit",
"vType": "INT64",
"vInt64": 9223372036854775222
},
{
"key": "blob",
"vType": "BINARY",
Expand Down
5 changes: 5 additions & 0 deletions model/converter/json/fixtures/ui_01.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@
"type": "float64",
"value": 72.5
},
{
"key": "javascript_limit",
"type": "int64",
"value": "9223372036854775222"
},
{
"key": "blob",
"type": "binary",
Expand Down
9 changes: 9 additions & 0 deletions model/converter/json/from_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@
package json

import (
"fmt"
"strings"

"github.com/jaegertracing/jaeger/model"
"github.com/jaegertracing/jaeger/model/json"
)

const (
jsMaxSafeInteger = int64(1)<<53 - 1
jsMinSafeInteger = -jsMaxSafeInteger
)

// FromDomain converts model.Trace into json.Trace format.
// It assumes that the domain model is valid, namely that all enums
// have valid values, so that it does not need to check for errors.
Expand Down Expand Up @@ -122,6 +128,9 @@ func (fd fromDomain) convertKeyValues(keyValues model.KeyValues) []json.KeyValue
value = kv.Bool()
case model.Int64Type:
value = kv.Int64()
if kv.Int64() > jsMaxSafeInteger || kv.Int64() < jsMinSafeInteger {
value = fmt.Sprintf("%d", value)
}
case model.Float64Type:
value = kv.Float64()
case model.BinaryType:
Expand Down