[exporters/otlp/otlpmetric] Wrap upload metrics error to provide additional context #3974
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've recently been investigating an unstructured error message that was being logged in a service that uses OTel tracing and metrics. The error message I was seeing looked like this:
After spending significant time working through the code to identify where this was being logged, and what the root cause was, I've identified the issue. This PR is not related to the actual issue (this isn't an OTel issue), but it does make a small change to where the error is being handled to wrap the error to provide additional context information. This also aligns it with the error wrapping happening several lines below. With this change, the above message becomes:
Knowing that this error originated in the metrics exporter and specifically as part of the upload functionality would have saved me a lot of time. Hopefully, this small change will save others some time in the future.