-
Notifications
You must be signed in to change notification settings - Fork 438
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
[BUILD] Transitive dependency issue with the otlp http exporter #2154
Conversation
@astitcher Thanks for the report and PR. @owent Could you take a look, and let me know if release 1.9.1 needs to wait for this fix ? (I don't know CMake well enough to assess the fix) Thanks. |
If this works I'd love to get it into 0.9.1 as we've been trying to release qpid-proton 0.39 and this will depend on some changes to our examples to use the otlp http exporter instead of the jaeger exporter which is now deprecated. But we can't get OT to build and work correctly in our CI builds with qpid-proton yet. |
I assume you meant 1.9.1 Please adjust the formatting for CMakeLists.txt, to fix the CI Format failure. From the CI log:
|
Oops, yes - confused by the qpid-proton current version numbering! |
Will do and force push. However I'm a little confused because I'm looking at the diff for my change and it has the identical leading spaces as the previous lines - has the CI format checker changed since the original lines went in? |
The misspell failure seems to be a CI failure not related to the change in the PR |
@@ -113,8 +113,8 @@ if(WITH_OTLP_HTTP) | |||
|
|||
target_link_libraries( | |||
opentelemetry_exporter_otlp_http_client | |||
PUBLIC opentelemetry_sdk opentelemetry_proto opentelemetry_http_client_curl |
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.
opentelemetry_exporter_otlp_http_client use the headers of opentelemetry_sdk and opentelemetry_ext.I believe it would be better to keep public link opentelemetry_sdk and opentelemetry_ext and private link opentelemetry_proto, opentelemetry_http_client_curl and nlohmann_json.
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.
This makes sense - I think I lazily just made everything private instead of looking more carefully. Thanks for the review.
I've made the requested changes and repushed the PR |
exporters/otlp/CMakeLists.txt
Outdated
@@ -113,8 +113,9 @@ if(WITH_OTLP_HTTP) | |||
|
|||
target_link_libraries( | |||
opentelemetry_exporter_otlp_http_client | |||
PUBLIC opentelemetry_sdk opentelemetry_proto opentelemetry_http_client_curl | |||
nlohmann_json::nlohmann_json) | |||
PUBLIC opentelemetry_sdk |
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 would be better to public link to opentelemetry_ext
, because opentelemetry_exporter_otlp_http_client
use the headers of http client.
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.
But is that relevant to my change as it wasn't there in the first place?
Also looking at the installed ot libraries there doesn't seem to be a libopentelemetry_ext.so library, so what does this public linkage mean? Without an actual library surely the most this could be would be an INTERFACE dependency?
But maybe I'm misunderstanding what you mean
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.
Yes, opentelemetry_ext is a interface target.It's created in https://github.com/open-telemetry/opentelemetry-cpp/blob/main/ext/CMakeLists.txt and can be used to tell other targets where to find the headers of ext.Especially when users use add_subdirectory to import optelemetry.
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.
So you'd like me to add it as a dependency even though it wasn't there before I made my change - I can do that, but it seems a bit unfair to hold up my PR because of a previously missing dependency.
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.
Sorry for that, but we did not previously miss this dependency. The reason for this is that opentelemetry_ext
is publicly linked to opentelemetry_http_client_curl
in https://github.com/open-telemetry/opentelemetry-cpp/blob/main/ext/src/http/client/curl/CMakeLists.txt. Additionally, opentelemetry_ext
will be implicitly publicly linked by target_link_libraries(opentelemetry_exporter_otlp_http_client PUBLIC opentelemetry_http_client_curl)
. However, after we privately link opentelemetry_http_client_curl
to opentelemetry_exporter_otlp_http_client
, the dependency will become invisible to other targets that use target_link_libraries(<TARGET_NAME> PUBLIC|PRIVATE opentelemetry_exporter_otlp_http_client )
.
This change may break certain use cases.
Currently, we lack unit tests for this type of scenario. I think we can add these tests in the future and in other PRs and issues.
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.
Ok - that's fair enough.
Although I'm a little curious about the fine grained internal parts of OT because doing it this way implies that you could have only some of them instlled on a system, but the extensive internal dependencies seems to me to mean that the options for this are actually much more limited and OT actually in practice tends to be more of a monolith. Albeit with some exceptions around the exporters.
I do understand that the intent is that the API itself is entirely header file and standalone, but in practice you always need an implementation and some exporters anyway, and these seem much more monolithic.
Sorry if this is a bit ranty but I'm just finding that working with the OT internal dependencies to be very unintuitive and difficult seeing that it is a large project with lots of internal dependencies that are hiding external ones that are hard to deal with.
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.
Yes, we use cmake CONFIG and modern cmake targets to resolve dependencies.Many components are optional but some of them depend each other. We hope users just concerns the components they use and the depended component can be added automatically.We use target_link_libraries(A PUBLIC B)
in cmake and deps
setting in bazel.They are similar.
Another force push to fix the cmake format lint complaint (that linter is annoyingly picky and unpredictable) |
Please avoid using force push if you can, it makes the review harder. Multiple commits will all be squashed at the end when merging to main, it is not an issue. For spurious CI failures like spell check, no need to worry about them, I will restart the CI to clear them, as I have done before. Thanks for the review comments, you are the expert in this area. Once a revised patch is both:
I will happily merge it to main and make a release right away for 1.9.1 |
Just to confirm that this version of the change works for me. |
Actually I was mistaken - it turns out that this new version of the change does not work for me, and I think that the header file structure of the otlp http exporters can never work with the packaged version of protobuf for any ubuntu lts or released version of Red Hat. This is because the It is not clear to me if there is a need to actually be exporting the protobuf types out of |
We can use |
I think even in this case the cmake configure process can't know what you will use just what it is possible for you to use! So it still needs to make sure that the dependencies are there and are linked into the final executable.
The issue here is that the application author needs to know that they need to use With the very most recent versions of protobuf this seems to be fixed as protobuf itself now provides cmake config without requiring the explicit |
As a workaround I'm going to try adding |
@marcalff I can now confirm that with my workaround to qpid-proton this PR does now build correctly for me under ubuntu 22.04. So merging this and releasing 1.9.1 would be a great help to us! |
Thanks @astitcher In my understanding, @owent comments have been addressed, so I expect he will be able to approve this PR. Due to the time zone difference, looking to merge most likely tomorrow. |
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 and thanks
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, thanks for the fix and testing.
If we build otel-cpp as shared libraries, and link opentelemetry_proto, opentelemetry_http_client_curl and nlohmann_json privately into opentelemetry_exporter_otlp_http_client, these components and protobuf will not be exported as
Agree and thanks. I raise a new issue to track this optimization.We hope users only use factories to create OTLP exporters, so all the dependencies in headers should be public.We have already used
The lateset version of protobuf also need users to use |
Fixes #2153
Changes
Change nlohmann_json and protobuf dependencies of the otlp http exporter to be private not public so that applications/libraries linking with this exporter don't need to have the cmake config nor the header files for them present in their builds.
##Comments
As far as I can see these don't need to be public or even interface dependencies because they are only used by the exporter itself in its own code. They aren't exposed either by the exporter header files by a transitive include or by the header files mentioning a symbol that is only in one of these libraries.
Using this change allows my builds to proceed.