open-telemetry / opentelemetry-collector-contrib

Contrib repository for the OpenTelemetry Collector
https://opentelemetry.io
Apache License 2.0
2.94k stars 2.29k forks source link

json_parser: number is always converted to float64 #33696

Closed newly12 closed 2 months ago

newly12 commented 3 months ago

Component(s)

pkg/stanza

What happened?

Description

By default both the standard json library and golang jsoniter library converts number value to float64, there is an option UseNumber from the library, with it enabled, the value will be json.Number and then v.Int64() or v.Float64() returns value in corresponding type or any parse error. It would make sense to honor the original data type from the json parser perspective.

Steps to Reproduce

use json parser to parse a sample json file. f.e. given following log line

{"int": 1, "float": 1.0}

Expected Result

int: int64(1), float: float64(1.0)

Actual Result

int: float64(1), float: float64(1.0)

Collector version

latest

Environment information

Environment

OS: (e.g., "Ubuntu 20.04") Compiler(if manually compiled): (e.g., "go 14.2")

OpenTelemetry Collector configuration

No response

Log output

No response

Additional context

No response

github-actions[bot] commented 3 months ago

Pinging code owners: