-
Notifications
You must be signed in to change notification settings - Fork 440
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
Add WITH_API_ONLY CMake option #778
Conversation
This enables easily building/using OpenTelemetry as a header-only library. When enabled, SDK/EXT/examples are not built. Fixes open-telemetry#751
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM . Thank you for change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need add a bazel target in parity with WITH_API_ONLY
?
Codecov Report
@@ Coverage Diff @@
## main #778 +/- ##
=======================================
Coverage 95.95% 95.95%
=======================================
Files 176 176
Lines 7172 7172
=======================================
Hits 6882 6882
Misses 290 290 |
Good point. I thought we should be able to build a single target just by specifying that target in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a question here. Have you tried:
cmake --build . --target opentelemetry_api
instead?
In #751 I tried both |
Bazel would be problematic. In Bazel build - you can exclude the directories from build at command line using I think even for CMake - it's possible to specify just the |
@lidavidm - I have a similar setup outside of CMake and Bazel with MSBuild, where just recursively cloning the contents of You could have also used FetchContent in your project, then added the paths to the folders using You'd definitely need |
We intend to only use the Span/Tracer, essentially, as we are a library and plan to be embedded into other applications. Linking all of OpenTelemetry isn't desirable there, and we don't even want to configure an exporter. (As far as I can see, this should be ok - the downstream application can link to the exporter and configure things.) Also, even if we do pull in SDK, we probably do not want all the exporters, ext, etc. which are also unavoidable right now. But as much as possible, we'd like to avoid building anything, so that we can easily support our platforms (this came up while I was trying to get OpenTelemetry into our CI). And I'd like to avoid adding to the build time as much as possible. If OpenTelemetry is guaranteeing that the contents of the API directory are basically usable as-is, then that's fine too. |
@maxgolov Strangely I don't see both opentelemetry_sdk and opentelemetry_api targets while listing all the available targets using |
We should fix it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine. Perhaps, long-term we need to fix the opentelemetry_api
target to just use that. API target is also expected to give you detail of what types are used on API surface...
I think for DLL on Windows that'd be absl::variant
and nostd::span
; for statically linked lib, and/or for header-only alternate SDK implementations this may be std::variant
and std::span
. If you are not intaking those defines from opentelemetry_api
target, then your objects won't link against the SDK.
opentelemetry_api
CMake target is expected to populate the necessary build flags for dependent projects. Maybe we need to get to the point when we provide dynamic linking interface stubs instead, such as .a
and .lib
files for Unix and Windows respectively. Plus the set of API headers with that, in a package. That'd be in Release v1.1 or later.
@lidavidm - please rerun |
Thanks for pointing me there, I've fixed the formatting. |
Fixes #751
Changes
This adds a WITH_API_ONLY CMake option so downstream projects can easily build/use OpenTelemetry as a header-only library. When enabled, SDK/EXT/examples are not built. Bazel is not supported, and flags for individual subcomponents are not exposed (as they have interlinked dependencies and it's likely not as useful/common to separate them out that way).
For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changes (not a major change)