Conversation
…al building script.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ 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 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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'sENABLE_PUSHfromOTELCPP_WITH_PROMETHEUS_PUSHwhen defined (defaulting toOFF), disable IWYU/clang-tidy on thepushtarget when enabled, add aFATAL_ERRORguard if the push target is unexpectedly built while the flag is off, and clean up theENABLE_PUSHcache entry afterward. - In
ci/do_ci.sh, enable-DOTELCPP_WITH_PROMETHEUS_PUSH=ONin thecmake.maintainer.yaml.testtarget 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
pushused inset_target_properties(push ...)is correct —jupp0r/prometheus-cpp'spush/CMakeLists.txtdefines targetpushwith aliasprometheus-cpp::push, consistent with the existingcore pull civetwebhandling. ENABLE_PUSHis read at line 58 before being unset at line 67, so the deferredunsetis intentional and correct.option(ENABLE_PUSH ...)inside prometheus-cpp won't override the forced cache value.- The push library requires
CURL::libcurl; incmake.maintainer.yaml.test, curl is available because OTLP HTTP is enabled, so enabling push there is safe. OTELCPP_WITH_PROMETHEUS_PUSHis deliberately not registered viaotelcpp_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.
| -DOTELCPP_WITH_OTLP_GRPC=ON \ | ||
| -DOTELCPP_WITH_OTLP_FILE=ON \ | ||
| -DOTELCPP_WITH_PROMETHEUS=ON \ | ||
| -DOTELCPP_WITH_PROMETHEUS_PUSH=ON \ |
There was a problem hiding this comment.
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 is a follow up work for open-telemetry/opentelemetry-cpp-contrib#646
Changes
OTELCPP_WITH_PROMETHEUS_PUSHwhich 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.mdupdated for non-trivial changes