Skip to content

[RFC] Poc config yaml #2518

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

Open
wants to merge 132 commits into
base: main
Choose a base branch
from
Open

Conversation

marcalff
Copy link
Member

@marcalff marcalff commented Jan 31, 2024

Fixes #2481

Request For Comments (Proof of concept code for now)

Start with examples/yaml/main.cc

Features implemented:

Changes

Please provide a brief description of the changes here.

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

Code review

Due to the size, code review to be done block by block.
See file CODE-REVIEW-PR2518.txt for details.

REVIEW BLOCK 1: Trace Model

Files to review:

### Model

sdk/include/opentelemetry/sdk/configuration/configuration.h

#### Trace Model

sdk/include/opentelemetry/sdk/configuration/tracer_provider_configuration.h

sdk/include/opentelemetry/sdk/configuration/batch_span_processor_configuration.h
sdk/include/opentelemetry/sdk/configuration/console_span_exporter_configuration.h
sdk/include/opentelemetry/sdk/configuration/otlp_grpc_span_exporter_configuration.h
sdk/include/opentelemetry/sdk/configuration/otlp_http_span_exporter_configuration.h
sdk/include/opentelemetry/sdk/configuration/simple_span_processor_configuration.h
sdk/include/opentelemetry/sdk/configuration/span_exporter_configuration.h
sdk/include/opentelemetry/sdk/configuration/span_exporter_configuration_visitor.h
sdk/include/opentelemetry/sdk/configuration/span_limits_configuration.h
sdk/include/opentelemetry/sdk/configuration/span_processor_configuration.h
sdk/include/opentelemetry/sdk/configuration/span_processor_configuration_visitor.h
sdk/include/opentelemetry/sdk/configuration/zipkin_span_exporter_configuration.h

@marcalff marcalff requested a review from a team January 31, 2024 00:19
@marcalff marcalff marked this pull request as draft January 31, 2024 00:28
@marcalff marcalff changed the title [IGNORE ME] Poc config yaml [RFC] Poc config yaml Feb 20, 2024
Copy link

linux-foundation-easycla bot commented Mar 6, 2025

@marcalff
Copy link
Member Author

/easycla

@marcalff marcalff marked this pull request as ready for review March 20, 2025 23:53
@marcalff marcalff requested a review from a team as a code owner March 20, 2025 23:53
@marcalff marcalff added the pr:please-review This PR is ready for review label Mar 20, 2025
if(WITH_OTLP_GRPC)
include_directories(${CMAKE_SOURCE_DIR}/exporters/otlp/include)
add_definitions(-DOTEL_HAVE_OTLP_GRPC)
target_link_libraries(example_yaml opentelemetry_otlp_grpc_builder)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @marcalff, I took a look today and wanted to share some thoughts and initial observations of the cmake changes to help spark some discussion about how to fit this pr into the new cmake components introduced by #3220:

Initial Observations:
This PR introduces some new cmake targets. These targets include theopentelemetry-cpp::configuration target from sdk/src/configuration and opentelemetry-cpp::init target from sdk/src/init as well as opentelemetry-cpp::*_builder targets (ie: opentelemetry-cpp::otlp_grpc_builder) created in the respective exporter directories.

The example_yaml shows how the new targets must be linked to an executable independently (ie: the opentelemetry-cpp::init target and the opentelemetry-cpp::*_builder targets must be explicitly linked to the example).

This PR also introduces the WITH_CONFIGURATION cmake option which determines if the opentelemetry-cpp::configuration and opentelemetry-cpp::init targets are created along with the main example and tests. The opentelemetry-cpp::*_builder targets are created independent of this option and are created if the corresponding WITH_* option is on (ie: WITH_OTLP_GRPC=ON creates the opentelemetry-cpp::otlp_grpc_builder target).

Summary of the cmake component approach so far:
In the new cmake component approach from #3220, each optional component is tied to a WITH_* option and has a fixed/required set of cmake targets defined by cmake/component_definitions.cmake. This creates a strong guarantee that if a component is successfully found with find_package(opentelemetry-cpp COMPONENTS <component>), then all cmake targets associated with the component have been imported and can be linked. This enables failing fast at cmake configure time - if a required cmake target was not installed then the user’s build will fail on cmake configure instead of failing at build or run time.

Initial thoughts on options to associated new targets with components:

  • Option 1: Create a single “configuration” component and assign all new targets to it
    • Guard all configuration related targets with the WITH_CONFIGURATION option
    • Allow opentelemetry-cpp::*_builder targets to be optional based on the WITH_* options, but link them to a common opentelemetry-cpp::configuration_builders target that will be the primary interface for users
    • Add all related targets to a single component called “configuration”
    • Mark the ryml dependency as required by the configuration component.
    • Set the opentelemetry-cpp::init, opentelemetry-cpp::configuration, and opentelemetry-cpp::configuration_builders cmake targets as required for the component.
  • Option 2: Assign the new targets to existing components and allow them to be optional
    • Guard all configuration related targets with the WITH_CONFIGURATION option
    • Add init and configuration targets to the sdk component
    • Set the ryml dependency as optional for the sdk component.
    • Add the opentelemetry-cpp::*_builder targets to the components associated with the WITH_* options that guard them now.
    • Update the cmake components framework to support marking targets as optional for each component and provide some other mechanism to inform the user which targets are imported after calling find_package(opentelemetry-cpp..).

Just some initial thoughts after a quick look at the PR - there are definitely other options to consider. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option:

  • Option 3: Create a configuration_common component and optional dependent builder components
    • Add a configuration_common component that requires the ryml dependency and init and configuration targets
    • Add builder components that depend on the common component (ie: configuration_otlp_grpc) that require the builder targets

This would allow cmake usage like this:

find_package(opentelemetry-cpp COMPONENTS configuration_otlp_grpc configuration_otlp_file)
add_library(my_lib my_lib.cc)
target_link_libraries(my_lib PRIVATE
   opentelemetry-cpp::init
   opentelemetry-cpp::configuration
   opentelemetry-cpp::otlp_grpc_builder
   opentelemetry-cpp::otlp_file_builder) 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:please-review This PR is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CONFIG] Implement file configuration
4 participants