-
Notifications
You must be signed in to change notification settings - Fork 415
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] Enable building otel-cpp extensions from main repo #1937
Conversation
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.
Thanks for extending this discussion to opentelemetry-cpp.
For the motivation, validating the compatibility of a change in opentelemetry-cpp with the
content of opentelemetry-cpp-contrib is very valuable:
- this will allow to catch unintended breaking changes,
- to catch breaks early, this build must be done in CI in the main branch
for opentelemetry-cpp at least, instead of waiting on a release of
opentelemetry-cpp.
So, I agree something must be done in the opentelemetry-cpp repository to
help, because this is where the code live for the main branch.
For the technical solution, if I understand correctly, there are now
dependencies like this:
- The opentelemetry-cpp project (a.k.a top level CMakeList.txt)
- depends (
WITH_CONTRIB
) on the opentelemetry-cpp-contrib project - depends (
OPENTELEMETRY_CONTRIB_PATH
) on arbitrary code
- depends (
I have concerns about this structure.
First, a dependency from opentelemetry-cpp to opentelemetry-cpp-contrib,
no matter how optional, brings a whole new set of issues:
-
Legal:
- what is the license of every dependencies introduced by
opentelemetry-cpp-contrib ? - How about further dependencies, what is the license of NGINX ?
- Who are the copyright holders ?
- Are these licenses compatible with Apache v2 ?
- what is the license of every dependencies introduced by
-
Technical risk:
- Are all the components introduced by opentelemetry-cpp-contrib
maintained ? - Is opentelemetry-cpp-contrib using the most up to date version of the
packages it depends upon ? - Are there known security bugs ?
- How did the attack surface increased with the added dependencies ?
- Are all the components introduced by opentelemetry-cpp-contrib
I just went though this exercise internally to get approval to use
opentelemetry-cpp in the first place, and adding more dependencies to more
code will invalidate this.
This is not specific to my employer, I believe that anyone looking
to deploy opentelemetry-cpp in a production environment will (or at least
should) have the same concerns about this.
Second, I am skeptical about how this can work without having at least some
knowledge about the code included as part of contrib, and I doubt a simple
add_subdirectory() will be sufficient.
For example, I would expect that some packaging or install logic will be
adjusted, to pick items provided by opentelemetry-cpp-contrib when building
all together, and I don't see how this can work in a generic way with
different vendors providing unknown content using
OPENTELEMETRY_CONTRIB_PATH.
Alternate proposal.
Define a super_build project, with its own CMakeList.txt
Have dependencies using this structure:
- super_build
- depends on opentelemetry-cpp
- depends on opentelemetry-cpp-contrib
The makefile for this super_build can have any relevant logic,
including logic to package and install, opentelemetry-cpp and
opentelemetry-cpp-contrib, together, with knowledge of the
opentelemetry-cpp-contrib internal structure if needed.
In this layout:
- opentelemetry-cpp top level makefile will be UNCHANGED,
- opentelemetry-cpp does not depend on opentelemetry-cpp-contrib,
- the superbuild makefile can be used as an example for vendors to use.
In terms of file layout in the opentelenetry-cpp repository,
we can have for example:
- a directory
repo root/super_build
, - a file
repo root/super_build/CMakeList.txt
.
File super_build/CMakeList.txt
can:
- add the opentelemetry-cpp dependency using
ExternalProject_Add()
in CMake,
pointing torepo root/CMakeLists.txt
- add the opentelemetry-cpp dependency using
FetchContent()
in CMake
This needs further investigations (not tested obviously).
Assuming this layout works, it will:
- address the concerns I expressed,
- test that opentelemetry-cpp can actually be used in a super_build,
- show an example of super_build.
which I think will be very beneficial to everyone.
CMakeLists.txt
Outdated
@@ -534,6 +534,28 @@ if(NOT WITH_API_ONLY) | |||
endif() | |||
endif() | |||
|
|||
# Add custom vendor directory via environment variable | |||
if(DEFINED ENV{OPENTELEMETRY_CONTRIB_PATH}) |
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 prefer cmake variable or environment here?
@marcalff Thanks for your comments, and the concerns raised. These are indeed valid concerns.
While we can also make the hardcoded contrib repo github url as configurable, I don't think this is really required.
As discussed in community meeting, to keep the root CMakeLists.txt clean, I have added these changes in separate cmake file. Please let me know if you have more comments/concerns here. Thanks. |
More comments on this ... Before introducing more coupling between opentelemetry-cpp and opentelemetry-cpp-contrib (either one way or the other), I think there are preliminary tasks to complete:
Once repository are dependent, moving code around without breaking anything is going to be more complex. This is actually important to cleanup:
Assuming this is resolved, and on the proposal itself, I don't understand how it would work in practice:
The contrib repository contains:
The best place to build each part with the proper dependency on opentelemetry-cpp (API versus API+SDK), and the proper third party dependency (httpd, nginx, fluentd, geneva, prometheus) is makefiles in the contrib-cpp repository, and to setup CI in the -cpp-contrib repository itself. Even when there is low activity in -cpp-contrib, I think CI can be triggered with a cron (say, once a week), to make sure everything in -cpp-contrib still builds with -cpp, and that tests still pass, on a regular basis. |
I'd like to reactivate this PR. The title says enable building otcpp extension, but seems the content then focused on our contrib repo? I think this should not be limited to contrib repo, instead of it can be any user provided repo. So probably we call it For dependencies, I think this mono build approach doesn't invert the contrib -> main dependency as this is optional. The |
Thanks @ThomsonTan for reopening this. I have made it more generic, and not fetching the contrib repo anymore: And either of these env-variables should be set now: OPENTELEMETRY_EXTERNAL_COMPONENT_PATH - The local path to external component. |
Co-authored-by: Tom Tan <[email protected]>
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.
The original request was to build both opentelemetry-cpp and opentelemetry-cpp-contrib together, to test -cpp-contrib is not broken by -cpp changes.
Are there plans to add a new build in CI (in -cpp) that will use this ?
I removed my initial request for changes to unblock this, to re evaluate the proposal. To discuss in SIG meeting, do not merge yet. |
@marcalff we will discuss this further in SIG meeting on this. But for testing side, I think we don't need -cpp-contrib to our main CI as validation. That can be a separate issue if we need it. For this PR, we provide an extension mechanism to build customer provided extension like exporter. So no need to pull in any contrib exporter for testing, probably we can create a simple exporter example to acts as customer provided exporter. The test will focus on the build extension method instead of any specific customer exporter. |
While we discussed this shortly in earlier community meeting, would like to have wider discussion over the PR and in next community meeting.
Change summary:
WITH_CONTRIB
to allow building contrib repo from main repo.OPENTELEMETRY_CONTRIB_PATH
env-variable,The motivation behind the change is to
As an example, the build and distribution process of Geneva/stats exporter as (currently) documented here can become much simpler with this change.