blob: aa92c8d040dbc49072606ab1ba01aa1da790ecdf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
#ifdef ENABLE_METRICS_PREVIEW
# include "opentelemetry/sdk/_metrics/controller.h"
# include "opentelemetry/sdk/_metrics/meter.h"
# include "opentelemetry/sdk/_metrics/ungrouped_processor.h"
# include <gtest/gtest.h>
# include <numeric>
# include <thread>
// #include <chrono>
namespace metrics_api = opentelemetry::metrics;
using namespace opentelemetry::sdk::common;
OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace metrics
{
class DummyExporter : public MetricsExporter
{
ExportResult Export(const std::vector<Record> &records) noexcept
{
return ExportResult::kSuccess;
}
};
TEST(Controller, Constructor)
{
std::shared_ptr<metrics_api::Meter> meter =
std::shared_ptr<metrics_api::Meter>(new Meter("Test"));
PushController alpha(meter, std::unique_ptr<MetricsExporter>(new DummyExporter),
std::shared_ptr<MetricsProcessor>(
new opentelemetry::sdk::metrics::UngroupedMetricsProcessor(false)),
.05);
auto instr = meter->NewIntCounter("test", "none", "none", true);
std::map<std::string, std::string> labels = {{"key", "value"}};
auto labelkv = opentelemetry::common::KeyValueIterableView<decltype(labels)>{labels};
alpha.start();
for (int i = 0; i < 20; i++)
{
instr->add(i, labelkv);
}
alpha.stop();
}
} // namespace metrics
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE
#endif
|