open-telemetry / opentelemetry-cpp

The OpenTelemetry C++ Client
https://opentelemetry.io/
Apache License 2.0
840 stars 403 forks source link

[API] Clarify expectations for C++ exceptions, and usage of noexcept methods. #3013

Open marcalff opened 1 month ago

marcalff commented 1 month ago

Several methods in the API are flagged as noexcept.

This is desirable, because adding instrumentation to an application (i.e., calling opentelemetry-cpp apis) should not make the application less stable.

In particular, any failure in the opentelemetry-cpp sdk or exporters should not propagate the exception up, taking the application down.

To comply with the noexcept contract, methods in the SDK implementation should never raise exceptions.

According to clang-tidy reports, this is not always the case.

This part should be revisited, to clarify expectations, and enforce the SDK implementation complies.

cc @msiddhu

marcalff commented 1 month ago

Related:

msiddhu commented 1 month ago

I'll work on this. Currently, there are 20 warnings flagged by clang-tidy as they may raise errors. I'll make a sheet explaining why and will come up with a cleanup. I'm busy this week but will raise a PR by late next week.