Skip to content
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

Provide a CMake target for prometheus_exporter_utils #2566

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions exporters/prometheus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,25 @@ target_link_libraries(
opentelemetry_exporter_prometheus
PUBLIC opentelemetry_metrics prometheus-cpp::pull prometheus-cpp::core)

# We create a separate target for utils library
add_library(
opentelemetry_exporter_prometheus_utils
src/exporter_utils.cc)

set_target_properties(opentelemetry_exporter_prometheus_utils
PROPERTIES EXPORT_NAME prometheus_exporter_utils)
set_target_version(opentelemetry_exporter_prometheus_utils)

target_include_directories(
opentelemetry_exporter_prometheus_utils
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
"$<INSTALL_INTERFACE:include>")

list(APPEND PROMETHEUS_EXPORTER_TARGETS opentelemetry_exporter_prometheus_utils)
target_link_libraries(
opentelemetry_exporter_prometheus_utils
PUBLIC opentelemetry_metrics prometheus-cpp::core)

Copy link
Member

Choose a reason for hiding this comment

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

Targets are also added in cmake config -

set(_OPENTELEMETRY_CPP_LIBRARIES_TEST_TARGETS
But I am not sure of the implications in that case - as the symbols from exporter_utils.cc would be part of two target belonging to same package OPENTELEMETRY_CPP_LIBRARIES. Will let @owent comment on that :)

Copy link
Member

Choose a reason for hiding this comment

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

I don't think that should be an issue, resolving it. Sorry for confusion :)

Copy link
Member

Choose a reason for hiding this comment

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

I think we should remove src/exporter_utils.cc from and link opentelemetry_exporter_prometheus_utils into opentelemetry_exporter_prometheus if we want to split this file into a standalone target.Or there may be conflict when some components link both opentelemetry_exporter_prometheus_utils and opentelemetry_exporter_prometheus.

BTW: The documents and the component name for OPENTELEMETRY_CPP_LIBRARIES should also be added into cmake/opentelemetry-cpp-config.cmake.in.

if(OPENTELEMETRY_INSTALL)
install(
TARGETS ${PROMETHEUS_EXPORTER_TARGETS}
Expand Down