mirror of https://github.com/oxen-io/lokinet
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
790 B
C++
33 lines
790 B
C++
5 years ago
|
#include <metrics/publishers.hpp>
|
||
6 years ago
|
|
||
|
#include <gtest/gtest.h>
|
||
|
#include <gmock/gmock.h>
|
||
|
|
||
|
using namespace llarp;
|
||
|
|
||
|
TEST(MetricsPublisher, StreamPublisher)
|
||
|
{
|
||
|
metrics::Category myCategory("MyCategory");
|
||
|
metrics::Description descA(&myCategory, "MetricA");
|
||
|
metrics::Description descB(&myCategory, "MetricB");
|
||
|
|
||
|
metrics::Id metricA(&descA);
|
||
|
metrics::Id metricB(&descB);
|
||
|
|
||
|
std::stringstream stream;
|
||
|
metrics::StreamPublisher myPublisher(stream);
|
||
|
|
||
|
std::vector< metrics::Record > records;
|
||
|
|
||
|
records.emplace_back(metricA, 5, 25.0, 6.0, 25.0);
|
||
|
records.emplace_back(metricB, 2, 7.0, 3.0, 11.0);
|
||
|
|
||
|
metrics::Sample sample;
|
||
|
sample.sampleTime(absl::Now());
|
||
|
sample.pushGroup(records.data(), records.size(), absl::Seconds(5));
|
||
|
|
||
|
myPublisher.publish(sample);
|
||
|
|
||
|
std::cout << stream.str();
|
||
|
}
|