Skip to content

[BUILD] Allow user to enable prometheus-cpp::push when using internal building script. - #4653

Open
owent wants to merge 1 commit into
open-telemetry:mainfrom
owent:allow_to_set_configure_options_for_promethues
Open

owent wants to merge 1 commit into
open-telemetry:mainfrom
owent:allow_to_set_configure_options_for_promethues

Conversation

@owent

@owent owent commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

This is a follow up work for open-telemetry/opentelemetry-cpp-contrib#646

Changes

  • Add OTELCPP_WITH_PROMETHEUS_PUSH which allow to enable prometheus-cpp::push when reusing the build script from otel-cpp.

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

@codecov

codecov Bot commented Sep 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.65%. Comparing base (754928d) to head (685baf7).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4653      +/-   ##
==========================================
- Coverage   86.66%   86.65%   -0.00%     
==========================================
  Files         525      525              
  Lines       20481    20481              
==========================================
- Hits        17748    17746       -2     
- Misses       2733     2735       +2     

see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@owent
owent marked this pull request as ready for review September 30, 2026 10:19
Copilot AI balanced review requested due to automatic review settings September 30, 2026 10:19
@owent
owent requested a review from a team as a code owner September 30, 2026 10:19

@marcalff marcalff left a comment

Copy link
Copy Markdown
Member

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

It changes third-party dependency build configuration (FetchContent/ENABLE_PUSH) and adds a FATAL_ERROR path intended for external script consumers, which warrants human verification across build configurations that cannot be executed here.

Review effort: Balanced
Findings: None

What changed in this PR

This PR adds a build-time hook, OTELCPP_WITH_PROMETHEUS_PUSH, so that consumers who reuse opentelemetry-cpp's internal CMake scripts (e.g., the opentelemetry-cpp-contrib repo, continuing the work from contrib #646) can opt into building the prometheus-cpp::push component. Previously ENABLE_PUSH was hard-forced to OFF in cmake/prometheus-cpp.cmake, making the push library unavailable through the fetched/built prometheus-cpp path.

Changes:

  • In cmake/prometheus-cpp.cmake, derive prometheus-cpp's ENABLE_PUSH from OTELCPP_WITH_PROMETHEUS_PUSH when defined (defaulting to OFF), disable IWYU/clang-tidy on the push target when enabled, add a FATAL_ERROR guard if the push target is unexpectedly built while the flag is off, and clean up the ENABLE_PUSH cache entry afterward.
  • In ci/do_ci.sh, enable -DOTELCPP_WITH_PROMETHEUS_PUSH=ON in the cmake.maintainer.yaml.test target to exercise the new build path.
File Description
cmake/​prometheus-cpp.cmake Makes ENABLE_PUSH configurable via OTELCPP_WITH_PROMETHEUS_PUSH, sanitizes the push target's IWYU/clang-tidy properties, adds a safety guard, and unsets the cache var.
ci/​do_ci.sh Enables the new push flag in the maintainer YAML test so the push build path is covered in CI.

Notes from investigation (no code comments warranted):

  • The raw target name push used in set_target_properties(push ...) is correct — jupp0r/prometheus-cpp's push/CMakeLists.txt defines target push with alias prometheus-cpp::push, consistent with the existing core pull civetweb handling.
  • ENABLE_PUSH is read at line 58 before being unset at line 67, so the deferred unset is intentional and correct. option(ENABLE_PUSH ...) inside prometheus-cpp won't override the forced cache value.
  • The push library requires CURL::libcurl; in cmake.maintainer.yaml.test, curl is available because OTLP HTTP is enabled, so enabling push there is safe.
  • OTELCPP_WITH_PROMETHEUS_PUSH is deliberately not registered via otelcpp_option_flag/printed in the STATUS summary; since opentelemetry-cpp itself does not consume the push exporter, registering it as a first-class user option could mislead, so this omission is reasonable rather than a convention violation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@marcalff marcalff changed the title Allow user to enable prometheus-cpp::push component when using internal building script. [BUILD] Allow user to enable prometheus-cpp::push component when using internal building script. Sep 30, 2026
@marcalff marcalff changed the title [BUILD] Allow user to enable prometheus-cpp::push component when using internal building script. [BUILD] Allow user to enable prometheus-cpp::push when using internal building script. Sep 30, 2026
Comment thread ci/do_ci.sh
-DOTELCPP_WITH_OTLP_GRPC=ON \
-DOTELCPP_WITH_OTLP_FILE=ON \
-DOTELCPP_WITH_PROMETHEUS=ON \
-DOTELCPP_WITH_PROMETHEUS_PUSH=ON \

@lalitb lalitb Sep 30, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit - Could we make this job build Prometheus from source? It currently uses an already-installed version, so the new option is ignored and the code added here isn't tested.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants