Add OpenTelemetry lib and metric-interfaces#588
Add OpenTelemetry lib and metric-interfaces#588maladetska wants to merge 5 commits intoydb-platform:mainfrom
Conversation
| void ParseEndpoint(const std::string& endpoint, std::string& host, int& port) { | ||
| auto pos = endpoint.find(':'); | ||
| if (pos != std::string::npos) { | ||
| host = endpoint.substr(0, pos); | ||
| try { | ||
| port = std::stoi(endpoint.substr(pos + 1)); | ||
| } catch (...) { | ||
| port = 2135; | ||
| } | ||
| } else { | ||
| host = endpoint; | ||
| port = 2135; | ||
| } | ||
| } |
There was a problem hiding this comment.
это плохо, пока черновой вариант такой
There was a problem hiding this comment.
может быть, на файлы разбить?
beec910 to
a102d53
Compare
🌋 SLO Test ResultsStatus: 🟢 2 workloads tested • All passed
Generated by ydb-slo-action |
Gazizonoki
left a comment
There was a problem hiding this comment.
Мне кажется папка open_telemetry в корне не самая удобная штука. Это же плагин к sdk, может сделаем папку plugins(extensions или еще какое-то имя) и туда положим все такие штуки (экспортеры метрик, трейсов, логов для конкретных систем и т. д.)?
И с метриками, оно вообще используется по коду? SDK уже собирает много метрик, в задаче с метриками это и есть главная сложность, как аккуратно перевести все на общий интерфейс и выкинуть library/cpp/monlib уже к черту из внешнего репозитория (это так-то внутренняя штука, вылезла в open-source ydb-cpp-sdk из-за неаккуратности)
There was a problem hiding this comment.
Как-то намешано все тут. И про метрики, и про спаны
open_telemetry/CMakeLists.txt
Outdated
There was a problem hiding this comment.
А может разделим? Тащить и метрики и трейсы сразу как-то странно, все же разные сущности. Вдруг трейсы пользователю не нужны?
There was a problem hiding this comment.
Разделила, посмотри, пожалуйста
| //! Get configured metrics exporter implementation. | ||
| std::shared_ptr<NMetrics::IMetricRegistry> GetMetricExporter() const; | ||
|
|
||
| //! Get configured tracing exporter implementation. | ||
| std::shared_ptr<NMetrics::ITraceProvider> GetTraceExporter() const; |
There was a problem hiding this comment.
А зачем нам Get методы?
| @@ -0,0 +1,3 @@ | |||
| if (YDB_SDK_ENABLE_OTEL_METRICS OR YDB_SDK_ENABLE_OTEL_TRACE) | |||
There was a problem hiding this comment.
Я думаю разделение должно быть прямо на уровне директорий (отдельные плагины). plugins/metrics/otel и plugins/trace/otel
| std::shared_ptr<NMetrics::ITraceProvider> GetTraceExporter() const; | ||
|
|
||
| template<typename T> | ||
| T* GetExtensionApi() { |
|
|
||
| namespace NYdb::inline V3::NMetrics { | ||
|
|
||
| inline void AddOpenTelemetry(TDriverConfig& config |
There was a problem hiding this comment.
А зачем эта функция? Нам может быть полезно все сразу подключать?
|
|
||
| namespace NYdb::inline V3::NMetrics { | ||
|
|
||
| class TOtelMetricRegistry : public IMetricRegistry { |
| opentelemetry::nostd::shared_ptr<opentelemetry::metrics::MeterProvider> MeterProvider_; | ||
| opentelemetry::nostd::shared_ptr<opentelemetry::metrics::Meter> Meter_; | ||
| std::mutex HistogramViewsLock_; | ||
| std::unordered_set<std::string> HistogramViews_; |
There was a problem hiding this comment.
Это дело бы неплохо за pimpl спрятать, чтобы в хедере не было инклюда на opentelemetry/metrics/...
| std::shared_ptr<ITracer> GetTracer(const std::string& name) override; | ||
|
|
||
| private: | ||
| opentelemetry::nostd::shared_ptr<opentelemetry::trace::TracerProvider> TracerProvider_; |
| void SafeLogSpanError(const char* message) noexcept { | ||
| try { | ||
| try { | ||
| Cerr << "TQuerySpan: " << message << ": " << CurrentExceptionMessage() << Endl; |
There was a problem hiding this comment.
| Cerr << "TQuerySpan: " << message << ": " << CurrentExceptionMessage() << Endl; | |
| std::cerr << "TQuerySpan: " << message << ": " << CurrentExceptionMessage() << std::endl; |
| return; | ||
| } catch (...) { | ||
| } | ||
| Cerr << "TQuerySpan: " << message << ": (unknown)" << Endl; |
No description provided.