-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[receiver/sqlserver] Properly parse scientific notation numbers to ints #39905
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
[receiver/sqlserver] Properly parse scientific notation numbers to ints #39905
Conversation
} | ||
} | ||
} else { | ||
err = fmt.Errorf("no value found for column %s", columnName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically in both retrieveInt
and retrieveFloat
I've added new potential errors scenarios, but both of these methods are only called currently from a select when a column name is seen in a row. I don't believe either of the new error cases are hit today, they're an attempt at future-proofing these methods.
Also, even if they're introducing new errors, the receiver is already failing to scrape the given metric or attribute, but it's just being hidden here and metrics are recorded as zero values. The proper behavior should be to notify users of errors.
3576b7e
to
4cf22c1
Compare
…ts (open-telemetry#39905) <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description SQL Server stores large integers in scientific e notation. `strconv.ParseInt` fails to parse this and raises an error, as seen in the original filed issue. For our use case, we still want these to be considered valid integers, so before failing entirely, attempt to parse to float and convert to integer. This change also uses already existing methods, `retrieveInt` and `retrieveFloat` to be able to re-use the parsing functionality. The original issue was only for `sqlserver.database.tempdb.space`, but I believe this issue is relevant for all metrics of type `int`. <!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes open-telemetry#39124 <!--Describe what testing was performed and which tests were added.--> #### Testing Changed test values of a couple integers to ensure new functionality works. The changed values broke tests on `main` in the same way the filed bug shows, but tests are passing with this change.
Description
SQL Server stores large integers in scientific e notation.
strconv.ParseInt
fails to parse this and raises an error, as seen in the original filed issue. For our use case, we still want these to be considered valid integers, so before failing entirely, attempt to parse to float and convert to integer.This change also uses already existing methods,
retrieveInt
andretrieveFloat
to be able to re-use the parsing functionality. The original issue was only forsqlserver.database.tempdb.space
, but I believe this issue is relevant for all metrics of typeint
.Link to tracking issue
Fixes #39124
Testing
Changed test values of a couple integers to ensure new functionality works. The changed values broke tests on
main
in the same way the filed bug shows, but tests are passing with this change.