1717
1818#pragma once
1919
20- #include " opentelemetry/sdk/metrics/meter.h"
2120#include < couchbase/metrics/meter.hxx>
2221
22+ #include < opentelemetry/context/context.h>
23+ #include < opentelemetry/metrics/meter.h>
24+ #include < opentelemetry/metrics/sync_instruments.h>
25+
2326#include < algorithm>
24- #include < iostream>
25- #include < thread>
27+ #include < mutex>
2628#include < utility>
2729
28- using couchbase::metrics::meter;
29- using couchbase::metrics::value_recorder;
30-
31- namespace nostd = opentelemetry::nostd;
32- namespace metrics_api = opentelemetry::metrics;
33- namespace metrics_sdk = opentelemetry::sdk::metrics;
34-
3530namespace couchbase ::metrics
3631{
3732
3833class otel_sync_histogram
3934{
4035public:
41- otel_sync_histogram (nostd::shared_ptr<metrics_api::Histogram<std::uint64_t >> histogram_counter)
42- : histogram_counter_(histogram_counter)
36+ explicit otel_sync_histogram (
37+ opentelemetry::nostd::shared_ptr<opentelemetry::metrics::Histogram<std::uint64_t >>
38+ histogram_counter)
39+ : histogram_counter_{ std::move (histogram_counter) }
4340 {
4441 }
4542
@@ -51,17 +48,19 @@ public:
5148 }
5249
5350private:
54- nostd::shared_ptr<metrics_api::Histogram<std::uint64_t >> histogram_counter_;
51+ opentelemetry::nostd::shared_ptr<opentelemetry::metrics::Histogram<std::uint64_t >>
52+ histogram_counter_;
5553 std::mutex mutex_;
5654};
5755
5856class otel_value_recorder : public couchbase ::metrics::value_recorder
5957{
6058public:
6159 explicit otel_value_recorder (
62- nostd::shared_ptr<metrics_api::Histogram<std::uint64_t >> histogram_counter,
60+ opentelemetry::nostd::shared_ptr<opentelemetry::metrics::Histogram<std::uint64_t >>
61+ histogram_counter,
6362 const std::map<std::string, std::string>& tags)
64- : histogram_counter_(histogram_counter)
63+ : histogram_counter_{ std::move (histogram_counter) }
6564 , tags_(tags)
6665 {
6766 }
@@ -73,18 +72,20 @@ public:
7372 uvalue, opentelemetry::common::KeyValueIterableView<decltype (tags_)>{ tags_ }, context_);
7473 }
7574
76- const std::map<std::string, std::string> tags ()
75+ [[nodiscard]] auto tags () const -> const std::map<std::string, std::string>&
7776 {
7877 return tags_;
7978 }
8079
81- nostd::shared_ptr<metrics_api::Histogram<std::uint64_t >> histogram_counter ()
80+ auto histogram_counter ()
81+ -> opentelemetry::nostd::shared_ptr<opentelemetry::metrics::Histogram<std::uint64_t>>
8282 {
8383 return histogram_counter_;
8484 }
8585
8686private:
87- nostd::shared_ptr<metrics_api::Histogram<std::uint64_t >> histogram_counter_;
87+ opentelemetry::nostd::shared_ptr<opentelemetry::metrics::Histogram<std::uint64_t >>
88+ histogram_counter_;
8889 const std::map<std::string, std::string> tags_;
8990 opentelemetry::context::Context context_{};
9091 std::mutex mutex_;
@@ -93,8 +94,8 @@ private:
9394class otel_meter : public couchbase ::metrics::meter
9495{
9596public:
96- explicit otel_meter (nostd::shared_ptr<metrics_api ::Meter> meter)
97- : meter_(meter)
97+ explicit otel_meter (opentelemetry:: nostd::shared_ptr<opentelemetry::metrics ::Meter> meter)
98+ : meter_{ std::move (meter) }
9899 {
99100 }
100101
@@ -132,7 +133,7 @@ public:
132133 }
133134
134135private:
135- nostd::shared_ptr<metrics_api ::Meter> meter_;
136+ opentelemetry:: nostd::shared_ptr<opentelemetry::metrics ::Meter> meter_;
136137 std::mutex mutex_;
137138 std::multimap<std::string, std::shared_ptr<otel_value_recorder>> recorders_;
138139};
0 commit comments