Skip to content

Commit

Permalink
fat core: reduce condition in OTLP
Browse files Browse the repository at this point in the history
Tests: протестировано CI

Pull Request resolved: #783
commit_hash:e32e10903d4744aa1ec341724962fbd30f7b0141
  • Loading branch information
nepridumalnik authored and apolukhin committed Dec 23, 2024
1 parent a024fdd commit 3d9fdec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 3 additions & 2 deletions otlp/src/otlp/logs/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <userver/utils/encoding/tskv_parser_read.hpp>
#include <userver/utils/overloaded.hpp>
#include <userver/utils/text_light.hpp>
#include <userver/utils/underlying_value.hpp>

USERVER_NAMESPACE_BEGIN

Expand Down Expand Up @@ -230,10 +231,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 (utils::UnderlyingValue(config_.logs_sink) & utils::UnderlyingValue(SinkType::kOtlp)) {
DoLog(log_request, log_client);
}
if (config_.tracing_sink == SinkType::kBoth || config_.tracing_sink == SinkType::kOtlp) {
if (utils::UnderlyingValue(config_.tracing_sink) & utils::UnderlyingValue(SinkType::kOtlp)) {
DoTrace(trace_request, trace_client);
}
}
Expand Down
7 changes: 6 additions & 1 deletion otlp/src/otlp/logs/logger.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <cstdint>
#include <memory>
#include <variant>

Expand All @@ -17,7 +18,11 @@ USERVER_NAMESPACE_BEGIN

namespace otlp {

enum class SinkType { kBoth, kDefault, kOtlp };
enum class SinkType : std::uint8_t {
kDefault = 0x1,
kOtlp = 0x2,
kBoth = kDefault | kOtlp,
};

SinkType Parse(const yaml_config::YamlConfig& value, formats::parse::To<SinkType>);

Expand Down

0 comments on commit 3d9fdec

Please sign in to comment.