Skip to content

Commit 717c375

Browse files
[Bug]: span tags of type int64 may lose precision jaegertracing#3958 PR No 2 (jaegertracing#4034)
### Avoid value precision loss Signed-off-by: Shubham Sawaiker [sawaikershubham@gmail.com](mailto:sawaikershubham@gmail.com) ### Which problem is this PR solving? - Resolves: jaegertracing#3958 ### Short description of the changes - avoid display value precision loss in case of value overflow Number.MAX_VALUE Previous PR was made from main branch because of which CI jobs were failing. First PR link : jaegertracing#4023 Signed-off-by: Shubham Sawaiker <sawaikershubham@gmail.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 252d198 commit 717c375

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

model/converter/json/fixtures/domain_01.json

+5
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@
5757
"vType": "FLOAT64",
5858
"vFloat64": 72.5
5959
},
60+
{
61+
"key": "javascript_limit",
62+
"vType": "INT64",
63+
"vInt64": 9223372036854775222
64+
},
6065
{
6166
"key": "blob",
6267
"vType": "BINARY",

model/converter/json/fixtures/ui_01.json

+5
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@
6262
"type": "float64",
6363
"value": 72.5
6464
},
65+
{
66+
"key": "javascript_limit",
67+
"type": "int64",
68+
"value": "9223372036854775222"
69+
},
6570
{
6671
"key": "blob",
6772
"type": "binary",

model/converter/json/from_domain.go

+9
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,18 @@
1616
package json
1717

1818
import (
19+
"fmt"
1920
"strings"
2021

2122
"github.com/jaegertracing/jaeger/model"
2223
"github.com/jaegertracing/jaeger/model/json"
2324
)
2425

26+
const (
27+
jsMaxSafeInteger = int64(1)<<53 - 1
28+
jsMinSafeInteger = -jsMaxSafeInteger
29+
)
30+
2531
// FromDomain converts model.Trace into json.Trace format.
2632
// It assumes that the domain model is valid, namely that all enums
2733
// have valid values, so that it does not need to check for errors.
@@ -122,6 +128,9 @@ func (fd fromDomain) convertKeyValues(keyValues model.KeyValues) []json.KeyValue
122128
value = kv.Bool()
123129
case model.Int64Type:
124130
value = kv.Int64()
131+
if kv.Int64() > jsMaxSafeInteger || kv.Int64() < jsMinSafeInteger {
132+
value = fmt.Sprintf("%d", value)
133+
}
125134
case model.Float64Type:
126135
value = kv.Float64()
127136
case model.BinaryType:

0 commit comments

Comments
 (0)