open-telemetry / open-telemetry/opentelemetry-cpp
Does otel-cpp require exception now?
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 1.4k
- Forks
- 632
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 75
Description
After upgrading to 1.29.0, building with -fno-exceptions fails with the following errors:
[ 50%] Building CXX object sdk/src/configuration/CMakeFiles/opentelemetry_configuration_core.dir/document_node.cc.o
/home/runner/work/cmake-toolset/cmake-toolset/test/third_party/packages/opentelemetry-cpp-v1.29.0/sdk/src/configuration/document_node.cc: In member function ‘std::string opentelemetry::v1::sdk::configuration::DocumentNode::DoOneSubstitution(const std::string&) const’:
/home/runner/work/cmake-toolset/cmake-toolset/test/third_party/packages/opentelemetry-cpp-v1.29.0/sdk/src/configuration/document_node.cc:116:53: error: exception handling disabled, use ‘-fexceptions’ to enable
116 | throw InvalidSchemaException(Location(), message);
| ^
/home/runner/work/cmake-toolset/cmake-toolset/test/third_party/packages/opentelemetry-cpp-v1.29.0/sdk/src/configuration/document_node.cc: In member function ‘int64_t opentelemetry::v1::sdk::configuration::DocumentNode::SignedIntegerFromString(const std::string&) const’:
/home/runner/work/cmake-toolset/cmake-toolset/test/third_party/packages/opentelemetry-cpp-v1.29.0/sdk/src/configuration/document_node.cc:269:3: error: ‘...’ handler must be the last handler for its try block [-fpermissive]
269 | catch (const std::invalid_argument &)
| ^~~~~
/home/runner/work/cmake-toolset/cmake-toolset/test/third_party/packages/opentelemetry-cpp-v1.29.0/sdk/src/configuration/document_node.cc: In member function ‘bool opentelemetry::v1::sdk::configuration::DocumentNode::BooleanFromString(const std::string&) const’:
/home/runner/work/cmake-toolset/cmake-toolset/test/third_party/packages/opentelemetry-cpp-v1.29.0/sdk/src/configuration/document_node.cc:238:1: warning: control reaches end of non-void function [-Wreturn-type]
238 | }
| ^
gmake[2]: *** [sdk/src/configuration/CMakeFiles/opentelemetry_configuration_core.dir/build.make:79: sdk/src/configuration/CMakeFiles/opentelemetry_configuration_core.dir/document_node.cc.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:923: sdk/src/configuration/CMakeFiles/opentelemetry_configuration_core.dir/all] Error 2
gmake: *** [Makefile:136: all] Error 2
'/usr/local/bin/cmake' '--build' '.' '--verbose'
Change Dir: '/home/runner/work/cmake-toolset/cmake-toolset/test/build_jobs_dir/_deps/opentelemetry_cpp-v1.29.0/linux-x86_64-gnu-13'
It looks like much of the code in the configuration module isn't guarded by OPENTELEMETRY_HAVE_EXCEPTIONS. Are exceptions now a hard requirement, or can I raise to a PR fixing this?
If a fix is welcome, I can see a few possible approaches:
- Replace all
throw XXXExceptionstatements withstd::abort()when exceptions are disabled. - Disable the configuration module entirely when exceptions are disabled.
- Rework the configuration APIs that currently throw so they report failures to the caller (e.g., via a status/result type), and log the original exception message to the global logger.It may changes a lot of APIs.
Which approach would you prefer? I'm happy to put together a PR once we agree on the direction.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with sdk/src/configuration/document_node.cc and the OPENTELEMETRY_HAVE_EXCEPTIONS guards, then reproduce the reported build with -fno-exceptions. Review the configuration module's throwing and catching paths and the existing exception policy. Done means the project has an agreed approach and the no-exceptions build either succeeds or clearly documents exceptions as required.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- api, build-system
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100