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

[Metric API] Instrument validation error handling #1699

Open
cijothomas opened this issue May 1, 2024 · 0 comments
Open

[Metric API] Instrument validation error handling #1699

cijothomas opened this issue May 1, 2024 · 0 comments
Labels
A-metrics Area: issues related to metrics

Comments

@cijothomas
Copy link
Member

Noticed an inconsistency in the Metric API regarding the init and try_init methods for instrument initialization. The documentation for init says that it would panic when validation fails, while try_init is expected to return a Result, allowing for error handling.

However, it appears that neither method behaves as documented. Specifically, the SDK implementation seems to suppress the Err variant, invariably returning an Ok variant after logging an error, and continues to provide a valid instrument. This should be potentially be classified as a bug.

Proposing the following changes to address this:

  • Modify the SDK implementation to return a NoOp instrument instead of an actual instrument when validation fails.

Additionally, need some inputs/suggestions of the below:

  1. Considering that the Err variant is never returned, should we remove the try_init method?
  2. Alternatively, should we retain both init and try_init, ensuring they adhere to the current documentation—where init panics on invalid input, and try_init returns a Result? This would place the onus on the user to either handle the results or accept the possibility of a panic.
@cijothomas cijothomas added the A-metrics Area: issues related to metrics label May 1, 2024
@cijothomas cijothomas added this to the Metric API beta milestone May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-metrics Area: issues related to metrics
Projects
None yet
Development

No branches or pull requests

1 participant