]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/api/test/metrics/noop_sync_instrument_test.cc
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / api / test / metrics / noop_sync_instrument_test.cc
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 #ifndef ENABLE_METRICS_PREVIEW
5
6 # include <gtest/gtest.h>
7 # include <map>
8 # include "opentelemetry/metrics/noop.h"
9
10 TEST(Counter, Add)
11 {
12 std::shared_ptr<opentelemetry::metrics::Counter<long>> counter{
13 new opentelemetry::metrics::NoopCounter<long>("test", "none", "unitless")};
14
15 std::map<std::string, std::string> labels = {{"k1", "v1"}};
16 EXPECT_NO_THROW(counter->Add(10l, labels));
17 EXPECT_NO_THROW(counter->Add(10l, labels, opentelemetry::context::Context{}));
18 EXPECT_NO_THROW(counter->Add(2l));
19 EXPECT_NO_THROW(counter->Add(2l, opentelemetry::context::Context{}));
20 EXPECT_NO_THROW(counter->Add(10l, {{"k1", "1"}, {"k2", 2}}));
21 EXPECT_NO_THROW(counter->Add(10l, {{"k1", "1"}, {"k2", 2}}, opentelemetry::context::Context{}));
22 }
23
24 TEST(histogram, Record)
25 {
26 std::shared_ptr<opentelemetry::metrics::Histogram<long>> counter{
27 new opentelemetry::metrics::NoopHistogram<long>("test", "none", "unitless")};
28
29 std::map<std::string, std::string> labels = {{"k1", "v1"}};
30 EXPECT_NO_THROW(counter->Record(10l, labels, opentelemetry::context::Context{}));
31 EXPECT_NO_THROW(counter->Record(2l, opentelemetry::context::Context{}));
32 EXPECT_NO_THROW(
33 counter->Record(10l, {{"k1", "1"}, {"k2", 2}}, opentelemetry::context::Context{}));
34 }
35
36 TEST(UpDownCountr, Record)
37 {
38 std::shared_ptr<opentelemetry::metrics::UpDownCounter<long>> counter{
39 new opentelemetry::metrics::NoopUpDownCounter<long>("test", "none", "unitless")};
40
41 std::map<std::string, std::string> labels = {{"k1", "v1"}};
42 EXPECT_NO_THROW(counter->Add(10l, labels));
43 EXPECT_NO_THROW(counter->Add(10l, labels, opentelemetry::context::Context{}));
44 EXPECT_NO_THROW(counter->Add(2l));
45 EXPECT_NO_THROW(counter->Add(2l, opentelemetry::context::Context{}));
46 EXPECT_NO_THROW(counter->Add(10l, {{"k1", "1"}, {"k2", 2}}));
47 EXPECT_NO_THROW(counter->Add(10l, {{"k1", "1"}, {"k2", 2}}, opentelemetry::context::Context{}));
48 }
49
50 #endif