You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe your environment
I've been reviewing code again, and discovered concerning amount of "catch (...)". I've raised this issue back here -> #4039 (comment) so I wonder if the community is okay with this approach.
From my experience "catch (...)" tends to hide real bad bugs under the rug and makes post-mortem debugging much harder.
Steps to reproduce
N/A
What is the expected behavior?
Have almost no "catch (...)", if needed introduce otel specific exceptions to throw.
What is the actual behavior?
Have too many "catch (...)" which can lead to hidden and hard to find errors.
Additional context
N/A
Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.
What is the expected behavior?
Have almost no "catch (...)", if needed introduce otel specific exceptions to throw.
This is not the expected behavior.
The excepted behavior is that opentelemetry-cpp will not take the application down, no matter how bad it fails internally, including on bad_alloc, and yes, the code is not there yet.
This is why things like StartSpan() are marked noexcept, these must not fail.
I do agree with you this can hide other errors that we should know about, see, and then fix.
Maybe the code should log errors caught (in the SDK and exporters, where we can log to somewhere, but not in the API), but the try/catch is likely to stay.
This issue was discussed in the SIG meeting today. Where possible in the SDK we should catch explicit exceptions by type and log them. There are cases where an exception catch all block is needed because the exception type is unknown to opentelemetry-cpp. This is the case with callers of user callbacks (e.g. Configurators, Observable instruments, ...).
The SDK global logger currently allocates memory by constructing a stringstream and may itself throw exceptions. A noexcept diagnostic tool/logger to report exceptions is needed.
Thanks folks! I don't have good suggestions tbh. I've integrated this into some of our internal apps, and my only worry is that we might not get a crashdump where it was needed, or simply have bad data (doesn't have to be opentelemetry's fault, could be like random memory stomp). We are /EHsc users (AFAIK using mix of clang-cl/msvc).
But I'm glad this was discussed, at least just clarify some of these. (for example bad_alloc makes sense to be handled by configuration for example to gracefully handle this case)
Activity
malkia commentedon Oct 13, 2026
marcalff commentedon Oct 13, 2026
@malkia
This is not the expected behavior.
The excepted behavior is that opentelemetry-cpp will not take the application down, no matter how bad it fails internally, including on
bad_alloc, and yes, the code is not there yet.This is why things like
StartSpan()are markednoexcept, these must not fail.I do agree with you this can hide other errors that we should know about, see, and then fix.
Maybe the code should log errors caught (in the SDK and exporters, where we can log to somewhere, but not in the API), but the try/catch is likely to stay.
Do you have any suggestion about how to proceed ?
marcalff commentedon Oct 13, 2026
See related:
dbarker commentedon Oct 14, 2026
This issue was discussed in the SIG meeting today. Where possible in the SDK we should catch explicit exceptions by type and log them. There are cases where an exception catch all block is needed because the exception type is unknown to opentelemetry-cpp. This is the case with callers of user callbacks (e.g. Configurators, Observable instruments, ...).
The SDK global logger currently allocates memory by constructing a stringstream and may itself throw exceptions. A noexcept diagnostic tool/logger to report exceptions is needed.
malkia commentedon Oct 14, 2026
Thanks folks! I don't have good suggestions tbh. I've integrated this into some of our internal apps, and my only worry is that we might not get a crashdump where it was needed, or simply have bad data (doesn't have to be opentelemetry's fault, could be like random memory stomp). We are
/EHscusers (AFAIK using mix of clang-cl/msvc).But I'm glad this was discussed, at least just clarify some of these. (for example bad_alloc makes sense to be handled by configuration for example to gracefully handle this case)