Skip to content

Commit

Permalink
Prometheus unit test (#1461)
Browse files Browse the repository at this point in the history
  • Loading branch information
esigo authored Jul 28, 2022
1 parent 3a8f913 commit e4f3a9c
Show file tree
Hide file tree
Showing 6 changed files with 970 additions and 0 deletions.
61 changes: 61 additions & 0 deletions exporters/prometheus/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,64 @@ cc_library(
"@com_github_jupp0r_prometheus_cpp//pull",
],
)

cc_library(
name = "prometheus_test_helper",
hdrs = [
"test/prometheus_test_helper.h",
],
tags = ["prometheus"],
deps = [
"//api",
"//sdk:headers",
"//sdk/src/trace",
],
)

cc_test(
name = "prometheus_exporter_test",
srcs = [
"test/exporter_test.cc",
],
tags = [
"prometheus",
"test",
],
deps = [
":prometheus_exporter",
":prometheus_test_helper",
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "prometheus_collector_test",
srcs = [
"test/collector_test.cc",
],
tags = [
"prometheus",
"test",
],
deps = [
":prometheus_collector",
":prometheus_test_helper",
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "prometheus_exporter_utils_test",
srcs = [
"test/exporter_utils_test.cc",
],
tags = [
"prometheus",
"test",
],
deps = [
":prometheus_exporter_utils",
":prometheus_test_helper",
"@com_google_googletest//:gtest_main",
],
)
11 changes: 11 additions & 0 deletions exporters/prometheus/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,15 @@ if(WITH_METRICS_PREVIEW)
TEST_PREFIX exporter.
TEST_LIST ${testname})
endforeach()
else()
foreach(testname exporter_test collector_test exporter_utils_test)
add_executable(${testname} "${testname}.cc")
target_link_libraries(
${testname} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}
prometheus_exporter prometheus-cpp::pull)
gtest_add_tests(
TARGET ${testname}
TEST_PREFIX exporter.
TEST_LIST ${testname})
endforeach()
endif()
Loading

1 comment on commit e4f3a9c

@github-actions
Copy link

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'OpenTelemetry-cpp api Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: e4f3a9c Previous: 3a8f913 Ratio
BM_NaiveSpinLockThrashing/2/process_time/real_time 1.0112532862910517 ms/iter 0.2596667993848569 ms/iter 3.89

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.