From 741afa5aebca8c903e5c55da9237c8596fd938f4 Mon Sep 17 00:00:00 2001 From: Dudnik Pavel Date: Tue, 10 Dec 2024 17:13:13 +0700 Subject: [PATCH 1/2] Reduce condition --- otlp/src/otlp/logs/logger.cpp | 4 ++-- otlp/src/otlp/logs/logger.hpp | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/otlp/src/otlp/logs/logger.cpp b/otlp/src/otlp/logs/logger.cpp index ab8ca98b27f0..dbe966fa8c4a 100644 --- a/otlp/src/otlp/logs/logger.cpp +++ b/otlp/src/otlp/logs/logger.cpp @@ -230,10 +230,10 @@ void Logger::SendingLoop(Queue::Consumer& consumer, LogClient& log_client, Trace ); } while (consumer.Pop(action, deadline)); - if (config_.logs_sink == SinkType::kBoth || config_.logs_sink == SinkType::kOtlp) { + if (config_.logs_sink & SinkType::kOtlp) { DoLog(log_request, log_client); } - if (config_.tracing_sink == SinkType::kBoth || config_.tracing_sink == SinkType::kOtlp) { + if (config_.tracing_sink & SinkType::kOtlp) { DoTrace(trace_request, trace_client); } } diff --git a/otlp/src/otlp/logs/logger.hpp b/otlp/src/otlp/logs/logger.hpp index 2c0040ac8481..22df4b0adebc 100644 --- a/otlp/src/otlp/logs/logger.hpp +++ b/otlp/src/otlp/logs/logger.hpp @@ -17,7 +17,11 @@ USERVER_NAMESPACE_BEGIN namespace otlp { -enum class SinkType { kBoth, kDefault, kOtlp }; +enum class SinkType : uint8_t { + kDefault = 0x1, + kOtlp = 0x2, + kBoth = kDefault | kOtlp, +}; SinkType Parse(const yaml_config::YamlConfig& value, formats::parse::To); From e464db952feca14bc6f6142987d7e96a44b30605 Mon Sep 17 00:00:00 2001 From: Dudnik Pavel Date: Tue, 10 Dec 2024 19:48:19 +0700 Subject: [PATCH 2/2] Fix --- otlp/src/otlp/logs/logger.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/otlp/src/otlp/logs/logger.cpp b/otlp/src/otlp/logs/logger.cpp index dbe966fa8c4a..b505385b769c 100644 --- a/otlp/src/otlp/logs/logger.cpp +++ b/otlp/src/otlp/logs/logger.cpp @@ -230,10 +230,10 @@ void Logger::SendingLoop(Queue::Consumer& consumer, LogClient& log_client, Trace ); } while (consumer.Pop(action, deadline)); - if (config_.logs_sink & SinkType::kOtlp) { + if (static_cast(config_.logs_sink) & static_cast(SinkType::kOtlp)) { DoLog(log_request, log_client); } - if (config_.tracing_sink & SinkType::kOtlp) { + if (static_cast(config_.tracing_sink) & static_cast(SinkType::kOtlp)) { DoTrace(trace_request, trace_client); } }