Skip to content

Commit b034d95

Browse files
committed
2 parents a1bad7d + 02a157a commit b034d95

File tree

15 files changed

+69
-8
lines changed

15 files changed

+69
-8
lines changed

.github/workflows/cppcheck.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ jobs:
4747
-I exporters/zipkin/include \
4848
-I ext/include \
4949
-I opentracing-shim/include \
50+
-I resource_detectors/include \
5051
-I sdk/include \
5152
-i build \
5253
-i test \

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ Increment the:
7272
* [CODE HEALTH] Fix clang-tidy special-member-functions warnings in trace
7373
[#3934](https://github.com/open-telemetry/opentelemetry-cpp/pull/3934)
7474

75+
* [TEST] CMake component install test for resource_detectors
76+
[#3940](https://github.com/open-telemetry/opentelemetry-cpp/pull/3940)
77+
7578
Important changes:
7679

7780
* [BUILD] Revisit EventLogger deprecation

INSTALL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ build configuration.
268268
| **exporters_elasticsearch**| opentelemetry-cpp::elasticsearch_log_record_exporter |
269269
| **exporters_etw** | opentelemetry-cpp::etw_exporter |
270270
| **exporters_zipkin** | opentelemetry-cpp::zipkin_trace_exporter |
271+
| **resource_detectors** | opentelemetry-cpp::resource_detectors |
271272
| **shims_opentracing** | opentelemetry-cpp::opentracing_shim |
272273

273274
## Build instructions using Bazel

ci/do_ci.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,8 @@ switch ($action) {
442442
"exporters_prometheus",
443443
"exporters_elasticsearch",
444444
"exporters_zipkin",
445-
"exporters_etw"
445+
"exporters_etw",
446+
"resource_detectors"
446447
)
447448
$EXPECTED_COMPONENTS_STRING = $EXPECTED_COMPONENTS -join ";"
448449

ci/do_ci.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,7 @@ elif [[ "$1" == "cmake.install.test" ]]; then
507507
"exporters_prometheus_builder"
508508
"exporters_elasticsearch"
509509
"exporters_zipkin"
510+
"resource_detectors"
510511
)
511512
EXPECTED_COMPONENTS_STRING=$(IFS=\;; echo "${EXPECTED_COMPONENTS[*]}")
512513
mkdir -p "${BUILD_DIR}/install_test"

cmake/templates/opentelemetry-cpp-config.cmake.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
# exporters_elasticsearch
8686
# exporters_etw
8787
# exporters_zipkin
88+
# resource_detectors
8889
# shims_opentracing
8990
#
9091
# ::
@@ -125,6 +126,7 @@
125126
# opentelemetry-cpp::elasticsearch_log_record_exporter - Imported target of COMPONENT exporters_elasticsearch
126127
# opentelemetry-cpp::etw_exporter - Imported target of COMPONENT exporters_etw
127128
# opentelemetry-cpp::zipkin_trace_exporter - Imported target of COMPONENT exporters_zipkin
129+
# opentelemetry-cpp::resource_detectors - Imported target of COMPONENT resource_detectors
128130
# opentelemetry-cpp::opentracing_shim - Imported target of COMPONENT shims_opentracing
129131
#
130132
# Additional Files Used in Component to Component and Third-Party Dependency Resolution
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright The OpenTelemetry Authors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
cmake_minimum_required(VERSION 3.16)
5+
project(opentelemetry-cpp-resource-detectors-install-test LANGUAGES CXX)
6+
7+
find_package(opentelemetry-cpp REQUIRED COMPONENTS resource_detectors)
8+
9+
find_package(GTest CONFIG REQUIRED)
10+
include(GoogleTest)
11+
12+
add_executable(resource_detectors_test
13+
${INSTALL_TEST_SRC_DIR}/test_resource_detectors.cc)
14+
target_link_libraries(
15+
resource_detectors_test PRIVATE opentelemetry-cpp::resource_detectors
16+
GTest::gtest GTest::gtest_main)
17+
18+
gtest_discover_tests(resource_detectors_test)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
#include <gtest/gtest.h>
5+
6+
#include <opentelemetry/resource_detectors/container_detector.h>
7+
#include <opentelemetry/resource_detectors/env_entity_detector.h>
8+
#include <opentelemetry/resource_detectors/process_detector.h>
9+
#include <memory>
10+
11+
TEST(ResourceDetectorsInstall, ContainerResourceDetector)
12+
{
13+
std::unique_ptr<opentelemetry::sdk::resource::ResourceDetector> detector =
14+
std::make_unique<opentelemetry::resource_detector::ContainerResourceDetector>();
15+
ASSERT_TRUE(detector != nullptr);
16+
ASSERT_NO_THROW(auto resource = detector->Detect());
17+
}
18+
19+
TEST(ResourceDetectorsInstall, EnvEntityDetector)
20+
{
21+
std::unique_ptr<opentelemetry::sdk::resource::ResourceDetector> detector =
22+
std::make_unique<opentelemetry::resource_detector::EnvEntityDetector>();
23+
ASSERT_TRUE(detector != nullptr);
24+
ASSERT_NO_THROW(auto resource = detector->Detect());
25+
}
26+
27+
TEST(ResourceDetectorsInstall, ProcessResourceDetector)
28+
{
29+
std::unique_ptr<opentelemetry::sdk::resource::ResourceDetector> detector =
30+
std::make_unique<opentelemetry::resource_detector::ProcessResourceDetector>();
31+
ASSERT_TRUE(detector != nullptr);
32+
ASSERT_NO_THROW(auto resource = detector->Detect());
33+
}

resource_detectors/BUILD

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ package(default_visibility = ["//visibility:public"])
88
otel_cc_library(
99
name = "resource_detectors",
1010
srcs = [
11-
"container_detector.cc",
12-
"container_detector_utils.cc",
13-
"env_entity_detector.cc",
14-
"process_detector.cc",
15-
"process_detector_utils.cc",
11+
"src/container_detector.cc",
12+
"src/container_detector_utils.cc",
13+
"src/env_entity_detector.cc",
14+
"src/process_detector.cc",
15+
"src/process_detector_utils.cc",
1616
],
1717
copts = ["-fexceptions"],
1818
linkopts = select({

resource_detectors/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33

44
add_library(
55
opentelemetry_resource_detectors
6-
container_detector_utils.cc container_detector.cc env_entity_detector.cc
7-
process_detector.cc process_detector_utils.cc)
6+
src/container_detector_utils.cc src/container_detector.cc
7+
src/env_entity_detector.cc src/process_detector.cc
8+
src/process_detector_utils.cc)
89

910
set_target_properties(opentelemetry_resource_detectors
1011
PROPERTIES EXPORT_NAME resource_detectors)

0 commit comments

Comments
 (0)