Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ build configuration.
| | opentelemetry-cpp::trace |
| | opentelemetry-cpp::metrics |
| | opentelemetry-cpp::logs |
| | opentelemetry-cpp::configuration_core (EXPERIMENTAL: Programmatic configuration) |
| **configuration** | opentelemetry-cpp::configuration (EXPERIMENTAL: YAML configuration) |
| **ext_common** | opentelemetry-cpp::ext |
| **ext_http_curl** | opentelemetry-cpp::http_client_curl |
| **ext_dll** | opentelemetry-cpp::opentelemetry_cpp |
Expand Down
5 changes: 0 additions & 5 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -493,16 +493,11 @@ elif [[ "$1" == "cmake.install.test" ]]; then
"ext_http_curl"
"exporters_in_memory"
"exporters_ostream"
"exporters_ostream_builder"
"exporters_otlp_common"
"exporters_otlp_file"
"exporters_otlp_file_builder"
"exporters_otlp_grpc"
"exporters_otlp_grpc_builder"
"exporters_otlp_http"
"exporters_otlp_http_builder"
"exporters_prometheus"
"exporters_prometheus_builder"
"exporters_elasticsearch"
"exporters_zipkin"
"resource_detectors"
Expand Down
30 changes: 27 additions & 3 deletions cmake/find-package-support-functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,29 @@
include("${CMAKE_CURRENT_LIST_DIR}/component-definitions.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/thirdparty-dependency-definitions.cmake")

#-------------------------------------------------------------------------
# Function to resolve deprecated component names to their aliases.
# Components without an alias are removed from the list
#-------------------------------------------------------------------------
function(resolve_deprecated_components requested_components_inout)
set(_result ${${requested_components_inout}})
foreach(_COMPONENT IN LISTS ${requested_components_inout})
if(${_COMPONENT} IN_LIST OTEL_DEPRECATED_COMPONENTS_LIST)
set(_alias_var "COMPONENT_${_COMPONENT}_DEPRECATED_ALIAS")
if(DEFINED ${_alias_var})
message(DEPRECATION "opentelemetry-cpp: component `${_COMPONENT}` is deprecated, use `${${_alias_var}}` instead.")
list(REMOVE_ITEM _result ${_COMPONENT})
list(APPEND _result ${${_alias_var}})
else()
message(DEPRECATION "opentelemetry-cpp: component `${_COMPONENT}` is deprecated with no replacement.")
list(REMOVE_ITEM _result ${_COMPONENT})
endif()
endif()
endforeach()
list(REMOVE_DUPLICATES _result)
set(${requested_components_inout} "${_result}" PARENT_SCOPE)
endfunction()

#-------------------------------------------------------------------------
# Function to get installed components.
#-------------------------------------------------------------------------
Expand Down Expand Up @@ -33,7 +56,6 @@ function(get_dependent_components component_in dependent_components_out)
set(${dependent_components_out} ${result} PARENT_SCOPE)
endfunction()


#-------------------------------------------------------------------------
# Function to get requested components.
#-------------------------------------------------------------------------
Expand All @@ -44,8 +66,10 @@ function(get_requested_components installed_components_in requested_components_o
message(DEBUG "get_requested_components: No components explicitly requested. Importing all installed components including: ${result}")
set(${requested_components_out} ${result} PARENT_SCOPE)
else()
message(DEBUG "get_requested_components: Components requested: ${opentelemetry-cpp_FIND_COMPONENTS}")
foreach(_COMPONENT IN LISTS opentelemetry-cpp_FIND_COMPONENTS)
set(REQUESTED_COMPONENTS ${opentelemetry-cpp_FIND_COMPONENTS})
message(DEBUG "get_requested_components: Components requested: ${REQUESTED_COMPONENTS}")
resolve_deprecated_components(REQUESTED_COMPONENTS)
foreach(_COMPONENT IN LISTS REQUESTED_COMPONENTS)
if(NOT ${_COMPONENT} IN_LIST OTEL_BUILT_COMPONENTS_LIST)
message(ERROR " get_requested_components: Component `${_COMPONENT}` is not a built component of the opentelemetry-cpp package. Built components include: ${OTEL_BUILT_COMPONENTS_LIST}")
return()
Expand Down
52 changes: 46 additions & 6 deletions cmake/otel-install-functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -317,28 +317,42 @@ endfunction()

#-----------------------------------------------------------------------
# otel_add_component:
# Adds a component to the list of components to be installed. A component name and list of targest are required.
# Adds a component to the list of components to be installed. A component name and list of targets are required.
# Optional files can be added to the component by specifying a directory, destination and matching pattern.
# Each target is assigned to the component and its dependencies are identified based on the LINK_LIBRARIES property.
# An alias target is also created for each target in the form of PROJECT_NAME::TARGET_EXPORT_NAME.
# DEPRECATED_NAMES lists old component names that are redirected to this component with a deprecation warning.
# DEPRECATED marks a component that has been fully removed with no replacement (no TARGETS required).
# Usage:
# otel_add_component(
# COMPONENT <component_name>
# [DEPRECATED_NAMES <old_name1> <old_name2> ...]
# TARGETS <target1> <target2> ...
# FILES_DIRECTORY <directory>
# FILES_DESTINATION <destination>
# FILES_MATCHING <matching>)
# [FILES_DIRECTORY <directory>
# FILES_DESTINATION <destination>
# FILES_MATCHING <matching>])
# otel_add_component(
# COMPONENT <removed_component_name>
# DEPRECATED)
#-----------------------------------------------------------------------
function(otel_add_component)
set(optionArgs )
set(optionArgs DEPRECATED)
set(oneValueArgs COMPONENT FILES_DIRECTORY FILES_DESTINATION)
set(multiValueArgs TARGETS FILES_MATCHING)
set(multiValueArgs TARGETS FILES_MATCHING DEPRECATED_NAMES)
cmake_parse_arguments(_OTEL_ADD_COMP "${optionArgs}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")

if(NOT _OTEL_ADD_COMP_COMPONENT)
message(FATAL_ERROR "otel_add_component: COMPONENT is required")
endif()

if(_OTEL_ADD_COMP_DEPRECATED)
get_property(_deprecated_components DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY OTEL_DEPRECATED_COMPONENTS_LIST)
list(APPEND _deprecated_components "${_OTEL_ADD_COMP_COMPONENT}")
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY OTEL_DEPRECATED_COMPONENTS_LIST "${_deprecated_components}")
message(DEBUG " DEPRECATED: ${_OTEL_ADD_COMP_COMPONENT} (no replacement)")
return()
endif()

if(NOT _OTEL_ADD_COMP_TARGETS)
message(FATAL_ERROR "otel_add_component: TARGETS is required")
endif()
Expand Down Expand Up @@ -378,6 +392,16 @@ function(otel_add_component)
FILES_MATCHING ${_OTEL_ADD_COMP_FILES_MATCHING}
COMPONENT_DEPENDS ${_COMPONENT_DEPENDS}
THIRDPARTY_DEPENDS ${_THIRDPARTY_DEPENDS})

foreach(_DEP_NAME IN LISTS _OTEL_ADD_COMP_DEPRECATED_NAMES)
get_property(_deprecated_components DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY OTEL_DEPRECATED_COMPONENTS_LIST)
list(APPEND _deprecated_components "${_DEP_NAME}")
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY OTEL_DEPRECATED_COMPONENTS_LIST "${_deprecated_components}")
set_property(DIRECTORY ${PROJECT_SOURCE_DIR}
PROPERTY OTEL_COMPONENT_DEPRECATED_ALIAS_${_DEP_NAME}
"${_OTEL_ADD_COMP_COMPONENT}")
message(DEBUG " DEPRECATED_NAME: ${_DEP_NAME} -> ${_OTEL_ADD_COMP_COMPONENT}")
endforeach()
endfunction()

#-----------------------------------------------------------------------
Expand Down Expand Up @@ -420,6 +444,22 @@ function(otel_install_components)
_otel_populate_component_thirdparty_depends_block(${_COMPONENT} OTEL_COMPONENTS_THIRDPARTY_DEPENDENCIES_BLOCK)
endforeach()

message(STATUS "Install DEPRECATED COMPONENTS")
get_property(OTEL_DEPRECATED_COMPONENTS_LIST DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY OTEL_DEPRECATED_COMPONENTS_LIST)

set(OTEL_COMPONENTS_DEPRECATED_ALIASES_BLOCK "")
foreach(_DEP_COMP IN LISTS OTEL_DEPRECATED_COMPONENTS_LIST)
get_property(_alias DIRECTORY ${PROJECT_SOURCE_DIR}
PROPERTY OTEL_COMPONENT_DEPRECATED_ALIAS_${_DEP_COMP})
if(_alias)
message(STATUS " Deprecated COMPONENT ${_DEP_COMP} -> ${_alias}")
string(APPEND OTEL_COMPONENTS_DEPRECATED_ALIASES_BLOCK
"set(COMPONENT_${_DEP_COMP}_DEPRECATED_ALIAS ${_alias})\n")
else()
message(STATUS " Deprecated COMPONENT ${_DEP_COMP} (no replacement)")
endif()
endforeach()

configure_file(
"${PROJECT_SOURCE_DIR}/cmake/templates/component-definitions.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake/component-definitions.cmake"
Expand Down
11 changes: 11 additions & 0 deletions cmake/templates/component-definitions.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@

# Configured from opentelemetry-cpp/cmake/component-definitions.cmake.in

# ----------------------------------------------------------------------
# Deprecated components
# ----------------------------------------------------------------------
set(OTEL_DEPRECATED_COMPONENTS_LIST @OTEL_DEPRECATED_COMPONENTS_LIST@)

# ----------------------------------------------------------------------
# Deprecated component aliases (deprecated_name -> replacement_name)
# ----------------------------------------------------------------------

@OTEL_COMPONENTS_DEPRECATED_ALIASES_BLOCK@

# ----------------------------------------------------------------------
# opentelmetry-cpp Built COMPONENT list
# ----------------------------------------------------------------------
Expand Down
13 changes: 13 additions & 0 deletions cmake/templates/opentelemetry-cpp-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
# COMPONENTS
# api
# sdk
# configuration
# ext_common
# ext_http_curl
# ext_dll
Expand All @@ -88,6 +89,14 @@
# resource_detectors
# shims_opentracing
#
# DEPRECATED COMPONENTS
# exporters_otlp_builder_utils - targets moved to COMPONENT exporters_otlp_common
# exporters_otlp_file_builder - targets moved to COMPONENT exporters_otlp_file
# exporters_otlp_http_builder - targets moved to COMPONENT exporters_otlp_http
# exporters_otlp_grpc_builder - targets moved to COMPONENT exporters_otlp_grpc
# exporters_ostream_builder - targets moved to COMPONENT exporters_ostream
# exporters_prometheus_builder - targets moved to COMPONENT exporters_prometheus
# --------------------
# ::
#
# TARGETS
Expand All @@ -99,6 +108,8 @@
# opentelemetry-cpp::trace - Imported target of COMPONENT sdk
# opentelemetry-cpp::metrics - Imported target of COMPONENT sdk
# opentelemetry-cpp::logs - Imported target of COMPONENT sdk
# opentelemetry-cpp::configuration_core - Imported target of COMPONENT sdk
# opentelemetry-cpp::configuration - Imported target of COMPONENT configuration
# opentelemetry-cpp::ext - Imported target of COMPONENT ext_common
# opentelemetry-cpp::http_client_curl - Imported target of COMPONENT ext_http_curl
# opentelemetry-cpp::opentelemetry_cpp - Imported target of COMPONENT ext_dll
Expand Down Expand Up @@ -143,6 +154,7 @@
# - **Protobuf**
# - **gRPC**
# - **prometheus-cpp**
# - **ryml**
# - **OpenTracing**
#
# **Found using the CMake MODULE search mode:**
Expand Down Expand Up @@ -214,6 +226,7 @@ endforeach()
# TRUE if all variables listed contain valid results, e.g. valid file paths.
include("FindPackageHandleStandardArgs")

set(${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS ${_REQUESTED_COMPONENTS})
set(${CMAKE_FIND_PACKAGE_NAME}_CONFIG ${CMAKE_CURRENT_LIST_FILE})

find_package_handle_standard_args(
Expand Down
29 changes: 3 additions & 26 deletions exporters/ostream/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,41 +155,18 @@ list(APPEND OPENTELEMETRY_OSTREAM_BUILDER_TARGETS
otel_add_component(
COMPONENT
exporters_ostream
TARGETS
${OPENTELEMETRY_OSTREAM_TARGETS}
FILES_DIRECTORY
"include/opentelemetry/exporters/ostream"
FILES_DESTINATION
"include/opentelemetry/exporters"
FILES_MATCHING
PATTERN
"*.h"
PATTERN
"console_log_record_builder.h"
EXCLUDE
PATTERN
"console_push_metric_builder.h"
EXCLUDE
PATTERN
"console_span_builder.h"
EXCLUDE)

otel_add_component(
COMPONENT
DEPRECATED_NAMES
exporters_ostream_builder
TARGETS
${OPENTELEMETRY_OSTREAM_TARGETS}
${OPENTELEMETRY_OSTREAM_BUILDER_TARGETS}
FILES_DIRECTORY
"include/opentelemetry/exporters/ostream"
FILES_DESTINATION
"include/opentelemetry/exporters"
FILES_MATCHING
PATTERN
"console_log_record_builder.h"
PATTERN
"console_push_metric_builder.h"
PATTERN
"console_span_builder.h")
"*.h")

if(OPENTELEMETRY_INSTALL)
opentelemetry_add_pkgconfig(
Expand Down
Loading
Loading