20#include "opentelemetry/sdk/metrics/meter.h"
30namespace nostd = opentelemetry::nostd;
31namespace metrics_api = opentelemetry::metrics;
32namespace metrics_sdk = opentelemetry::sdk::metrics;
41 : histogram_counter_(histogram_counter)
45 const opentelemetry::common::KeyValueIterable& tags,
46 opentelemetry::context::Context& ctx)
49 if (value > LONG_MAX) {
52 long lvalue =
static_cast<long>(value);
53 histogram_counter_->Record(lvalue, tags, ctx);
57 nostd::shared_ptr<metrics_api::Histogram<long>> histogram_counter_;
65 const std::map<std::string, std::string>&
tags)
72 if (value > LONG_MAX) {
75 long lvalue =
static_cast<long>(value);
76 histogram_counter_->Record(
77 value, opentelemetry::common::KeyValueIterableView<
decltype(tags_)>{ tags_ }, context_);
80 const std::map<std::string, std::string>
tags()
87 return histogram_counter_;
91 nostd::shared_ptr<metrics_api::Histogram<long>> histogram_counter_;
92 const std::map<std::string, std::string> tags_;
93 opentelemetry::context::Context context_{};
106 -> std::shared_ptr<value_recorder>
override
109 std::scoped_lock<std::mutex> lock(mutex_);
110 auto it = recorders_.equal_range(name);
111 if (it.first == it.second) {
118 std::make_shared<otel_value_recorder>(meter_->CreateLongHistogram(name,
"",
"us"),
124 for (
auto itr = it.first; itr != it.second; itr++) {
125 if (tags == itr->second->tags()) {
134 std::make_shared<otel_value_recorder>(it.first->second->histogram_counter(), tags) })
139 nostd::shared_ptr<metrics_api::Meter> meter_;
141 std::multimap<std::string, std::shared_ptr<otel_value_recorder>> recorders_;
Definition otel_meter.hxx:98
auto get_value_recorder(const std::string &name, const std::map< std::string, std::string > &tags) -> std::shared_ptr< value_recorder > override
Definition otel_meter.hxx:105
otel_meter(nostd::shared_ptr< metrics_api::Meter > meter)
Definition otel_meter.hxx:100
Definition otel_meter.hxx:38
void record(uint64_t value, const opentelemetry::common::KeyValueIterable &tags, opentelemetry::context::Context &ctx)
Definition otel_meter.hxx:44
otel_sync_histogram(nostd::shared_ptr< metrics_api::Histogram< long > > histogram_counter)
Definition otel_meter.hxx:40
Definition otel_meter.hxx:62
otel_value_recorder(nostd::shared_ptr< metrics_api::Histogram< long > > histogram_counter, const std::map< std::string, std::string > &tags)
Definition otel_meter.hxx:64
void record_value(std::int64_t value) override
Definition otel_meter.hxx:70
nostd::shared_ptr< metrics_api::Histogram< long > > histogram_counter()
Definition otel_meter.hxx:85
const std::map< std::string, std::string > tags()
Definition otel_meter.hxx:80