Skip to content

Add OpenTelemetry lib and metric-interfaces#588

Open
maladetska wants to merge 5 commits intoydb-platform:mainfrom
maladetska:METRICS-0
Open

Add OpenTelemetry lib and metric-interfaces#588
maladetska wants to merge 5 commits intoydb-platform:mainfrom
maladetska:METRICS-0

Conversation

@maladetska
Copy link

No description provided.

Comment on lines +7 to +20
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;
}
}
Copy link
Author

@maladetska maladetska Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это плохо, пока черновой вариант такой

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

может быть, на файлы разбить?

@github-actions
Copy link
Contributor

github-actions bot commented Feb 21, 2026

🌋 SLO Test Results

Status: 🟢 2 workloads tested • All passed

Workload Metrics Regressions Improvements Links
🚀 table-gcc 8 0 2 ReportCheck
🟢 table-clang 8 0 0 ReportCheck

Generated by ydb-slo-action

@maladetska maladetska changed the title init? Add OpenTelemetry lib Feb 24, 2026
@maladetska maladetska changed the title Add OpenTelemetry lib Add OpenTelemetry lib and metric-interfaces Feb 24, 2026
Copy link
Collaborator

@Gazizonoki Gazizonoki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Мне кажется папка open_telemetry в корне не самая удобная штука. Это же плагин к sdk, может сделаем папку plugins(extensions или еще какое-то имя) и туда положим все такие штуки (экспортеры метрик, трейсов, логов для конкретных систем и т. д.)?

И с метриками, оно вообще используется по коду? SDK уже собирает много метрик, в задаче с метриками это и есть главная сложность, как аккуратно перевести все на общий интерфейс и выкинуть library/cpp/monlib уже к черту из внешнего репозитория (это так-то внутренняя штука, вылезла в open-source ydb-cpp-sdk из-за неаккуратности)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Как-то намешано все тут. И про метрики, и про спаны

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Все еще надо разбить

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А может разделим? Тащить и метрики и трейсы сразу как-то странно, все же разные сущности. Вдруг трейсы пользователю не нужны?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Разделила, посмотри, пожалуйста

Comment on lines +163 to +167
//! Get configured metrics exporter implementation.
std::shared_ptr<NMetrics::IMetricRegistry> GetMetricExporter() const;

//! Get configured tracing exporter implementation.
std::shared_ptr<NMetrics::ITraceProvider> GetTraceExporter() const;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А зачем нам Get методы?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Все еще надо разбить

@@ -0,0 +1,3 @@
if (YDB_SDK_ENABLE_OTEL_METRICS OR YDB_SDK_ENABLE_OTEL_TRACE)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я думаю разделение должно быть прямо на уровне директорий (отдельные плагины). plugins/metrics/otel и plugins/trace/otel

std::shared_ptr<NMetrics::ITraceProvider> GetTraceExporter() const;

template<typename T>
T* GetExtensionApi() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А это точно нужно?


namespace NYdb::inline V3::NMetrics {

inline void AddOpenTelemetry(TDriverConfig& config
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А зачем эта функция? Нам может быть полезно все сразу подключать?


namespace NYdb::inline V3::NMetrics {

class TOtelMetricRegistry : public IMetricRegistry {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Comment on lines +21 to +24
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_;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это дело бы неплохо за pimpl спрятать, чтобы в хедере не было инклюда на opentelemetry/metrics/...

std::shared_ptr<ITracer> GetTracer(const std::string& name) override;

private:
opentelemetry::nostd::shared_ptr<opentelemetry::trace::TracerProvider> TracerProvider_;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

void SafeLogSpanError(const char* message) noexcept {
try {
try {
Cerr << "TQuerySpan: " << message << ": " << CurrentExceptionMessage() << Endl;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Cerr << "TQuerySpan: " << message << ": " << CurrentExceptionMessage() << Endl;
std::cerr << "TQuerySpan: " << message << ": " << CurrentExceptionMessage() << std::endl;

return;
} catch (...) {
}
Cerr << "TQuerySpan: " << message << ": (unknown)" << Endl;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants