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

json_parser: number is always converted to float64 #33696

Closed
newly12 opened this issue Jun 21, 2024 · 1 comment · Fixed by #33699
Closed

json_parser: number is always converted to float64 #33696

newly12 opened this issue Jun 21, 2024 · 1 comment · Fixed by #33699
Labels
bug Something isn't working needs triage New item requiring triage pkg/stanza

Comments

@newly12
Copy link
Contributor

newly12 commented Jun 21, 2024

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

@newly12 newly12 added bug Something isn't working needs triage New item requiring triage labels Jun 21, 2024
Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage New item requiring triage pkg/stanza
Projects
None yet
1 participant