summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkseleznyov <[email protected]>2026-07-13 13:15:19 +0300
committerGitHub <[email protected]>2026-07-13 13:15:19 +0300
commitf633e1653c6d6e824b60ab6dbaff802d4b8d2d38 (patch)
tree6f8532a19397afeb09a7356065c253dff1776664
parent2c54681d6be70884b7d5100c00845bc34437a1b0 (diff)
[YDB_LOG] Migrate core/viewer (#44123)
Co-authored-by: Ilnaz Nizametdinov <[email protected]>
-rw-r--r--ydb/core/viewer/json_pipe_req.cpp10
-rw-r--r--ydb/core/viewer/log.h9
-rw-r--r--ydb/core/viewer/viewer.cpp5
-rw-r--r--ydb/core/viewer/viewer_compute.h3
-rw-r--r--ydb/core/viewer/viewer_describe.h5
-rw-r--r--ydb/core/viewer/viewer_graph.h4
-rw-r--r--ydb/core/viewer/viewer_groups.h11
-rw-r--r--ydb/core/viewer/viewer_multipart_counter.h17
-rw-r--r--ydb/core/viewer/viewer_simple_counter.h19
-rw-r--r--ydb/core/viewer/viewer_sse_counter.h17
-rw-r--r--ydb/core/viewer/viewer_topic_data.cpp28
11 files changed, 86 insertions, 42 deletions
diff --git a/ydb/core/viewer/json_pipe_req.cpp b/ydb/core/viewer/json_pipe_req.cpp
index 1535222261c..96cea501f90 100644
--- a/ydb/core/viewer/json_pipe_req.cpp
+++ b/ydb/core/viewer/json_pipe_req.cpp
@@ -4,6 +4,8 @@
#include <library/cpp/json/json_writer.h>
#include <util/generic/overloaded.h>
+#define YDB_LOG_THIS_FILE_COMPONENT NKikimrServices::VIEWER
+
namespace NKikimr::NViewer {
template<typename T>
@@ -1159,7 +1161,10 @@ void TViewerPipeClient::RequestDone(i32 requests) {
return;
}
if (requests > DataRequests) {
- BLOG_ERROR("Requests count mismatch: " << requests << " > " << DataRequests);
+ YDB_LOG_ERROR("Request count mismatch",
+ {"logPrefix", GetLogPrefix()},
+ {"request", requests},
+ {"dataRequests", DataRequests});
if (Span) {
Span.Event("Requests count mismatch");
}
@@ -1200,7 +1205,8 @@ void TViewerPipeClient::Cancelled() {
if (PassedAway) {
return;
}
- BLOG_D("Request cancelled");
+ YDB_LOG_DEBUG("Request cancelled",
+ {"logPrefix", GetLogPrefix()});
AddEvent("Cancelled");
PassAway();
}
diff --git a/ydb/core/viewer/log.h b/ydb/core/viewer/log.h
index da5229ff0c6..a1cd88affd5 100644
--- a/ydb/core/viewer/log.h
+++ b/ydb/core/viewer/log.h
@@ -9,12 +9,3 @@ inline TString GetLogPrefix() {
}
}
-
-#define BLOG_D(stream) LOG_DEBUG_S(*TlsActivationContext, NKikimrServices::VIEWER, GetLogPrefix() << stream)
-#define BLOG_I(stream) LOG_INFO_S(*TlsActivationContext, NKikimrServices::VIEWER, GetLogPrefix() << stream)
-#define BLOG_W(stream) LOG_WARN_S(*TlsActivationContext, NKikimrServices::VIEWER, GetLogPrefix() << stream)
-#define BLOG_NOTICE(stream) LOG_NOTICE_S(*TlsActivationContext, NKikimrServices::VIEWER, GetLogPrefix() << stream)
-#define BLOG_ERROR(stream) LOG_ERROR_S(*TlsActivationContext, NKikimrServices::VIEWER, GetLogPrefix() << stream)
-#define BLOG_CRIT(stream) LOG_CRIT_S(*TlsActivationContext, NKikimrServices::VIEWER, GetLogPrefix() << stream)
-#define BLOG_TRACE(stream) LOG_TRACE_S(*TlsActivationContext, NKikimrServices::VIEWER, GetLogPrefix() << stream)
-#define Y_ENSURE_LOG(cond, stream) if (!(cond)) { BLOG_ERROR("Failed condition \"" << #cond << "\" " << stream); }
diff --git a/ydb/core/viewer/viewer.cpp b/ydb/core/viewer/viewer.cpp
index 405ad9640b4..e70c12dadc4 100644
--- a/ydb/core/viewer/viewer.cpp
+++ b/ydb/core/viewer/viewer.cpp
@@ -25,6 +25,8 @@
#include <yql/essentials/public/issue/yql_issue_message.h>
#include <ydb/public/api/protos/ydb_monitoring.pb.h>
+#define YDB_LOG_THIS_FILE_COMPONENT NKikimrServices::VIEWER
+
template<>
void Out<std::vector<ui32>>(IOutputStream& o, const std::vector<ui32>& v) {
for (size_t i = 0; i < v.size(); ++i) {
@@ -836,7 +838,8 @@ private:
if (actor) {
Register(actor);
} else {
- BLOG_ERROR("Unable to process EvViewerRequest");
+ YDB_LOG_ERROR("Unable to process EvViewerRequest",
+ {"logPrefix", GetLogPrefix()});
Send(ev->Sender, new TEvViewer::TEvViewerResponse(), 0, ev->Cookie);
}
}
diff --git a/ydb/core/viewer/viewer_compute.h b/ydb/core/viewer/viewer_compute.h
index 2a5355a00b4..8026ed78f62 100644
--- a/ydb/core/viewer/viewer_compute.h
+++ b/ydb/core/viewer/viewer_compute.h
@@ -259,7 +259,8 @@ public:
}
void Handle(TEvHive::TEvResponseHiveNodeStats::TPtr& ev) {
- BLOG_TRACE("ProcessNodeIds()");
+ YDB_LOG_TRACE_COMP(NKikimrServices::VIEWER, "ProcessNodeIds",
+ {"logPrefix", GetLogPrefix()});
auto nodeStats = ev->Get()->Record.GetNodeStats();
if (NeedNodesSorting() && Sort == ESort::NodeId && !IsNodeFilter()) {
diff --git a/ydb/core/viewer/viewer_describe.h b/ydb/core/viewer/viewer_describe.h
index 5c78d0da39d..467232c55a5 100644
--- a/ydb/core/viewer/viewer_describe.h
+++ b/ydb/core/viewer/viewer_describe.h
@@ -434,7 +434,10 @@ public:
json["PathDescription"]["ExternalTableDescription"]["Content"][key] = array;
}
} catch (...) {
- BLOG_CRIT("Сan't unpack content for external table: " << sourceType << ", error: " << CurrentExceptionMessage());
+ YDB_LOG_CRIT_COMP(NKikimrServices::VIEWER, "Сan't unpack content for external table",
+ {"logPrefix", GetLogPrefix()},
+ {"sourceType", sourceType},
+ {"error", CurrentExceptionMessage()});
}
}
diff --git a/ydb/core/viewer/viewer_graph.h b/ydb/core/viewer/viewer_graph.h
index de5de41ba1d..4621b831858 100644
--- a/ydb/core/viewer/viewer_graph.h
+++ b/ydb/core/viewer/viewer_graph.h
@@ -22,7 +22,9 @@ public:
{}
void Bootstrap() override {
- BLOG_TRACE("Graph received request for " << Event->Get()->Request.GetUri());
+ YDB_LOG_TRACE_COMP(NKikimrServices::VIEWER, "Graph received request",
+ {"logPrefix", GetLogPrefix()},
+ {"uri", Event->Get()->Request.GetUri()});
const auto& params(Event->Get()->Request.GetParams());
NKikimrGraph::TEvGetMetrics getRequest;
if (params.Has("target")) {
diff --git a/ydb/core/viewer/viewer_groups.h b/ydb/core/viewer/viewer_groups.h
index 72f7853fb84..945c3850251 100644
--- a/ydb/core/viewer/viewer_groups.h
+++ b/ydb/core/viewer/viewer_groups.h
@@ -1542,7 +1542,11 @@ public:
}
group->EncryptionMode = pool->GetEncryptionMode();
} else {
- BLOG_W("Storage pool not found for group " << group->GroupId << " box " << group->BoxId << " pool " << group->PoolId);
+ YDB_LOG_WARN_COMP(NKikimrServices::VIEWER, "Storage pool not found",
+ {"logPrefix", GetLogPrefix()},
+ {"groupId", group->GroupId},
+ {"boxId", group->BoxId},
+ {"poolId", group->PoolId});
}
}
}
@@ -1703,7 +1707,10 @@ public:
}
auto itNavigateKeySetResult = NavigateKeySetResult.find(pathId);
if (itNavigateKeySetResult == NavigateKeySetResult.end()) {
- BLOG_W("Invalid NavigateKeySetResult PathId: " << pathId << " Path: " << CanonizePath(ev->Get()->Request->ResultSet.begin()->Path));
+ YDB_LOG_WARN_COMP(NKikimrServices::VIEWER, "Invalid NavigateKeySetResult",
+ {"logPrefix", GetLogPrefix()},
+ {"pathId", pathId},
+ {"path", CanonizePath(ev->Get()->Request->ResultSet.begin()->Path)});
return RequestDone();
}
auto& navigateResult(itNavigateKeySetResult->second);
diff --git a/ydb/core/viewer/viewer_multipart_counter.h b/ydb/core/viewer/viewer_multipart_counter.h
index 0d2b6117fc2..1646c6091fe 100644
--- a/ydb/core/viewer/viewer_multipart_counter.h
+++ b/ydb/core/viewer/viewer_multipart_counter.h
@@ -37,7 +37,12 @@ public:
if (params.Has("content_type")) {
ContentType = params.Get("content_type");
}
- BLOG_D("Started MaxCounter: " << MaxCounter << ", Period: " << Period << ", FailChance: " << FailChance << ", ContentType: " << ContentType);
+ YDB_LOG_DEBUG_COMP(NKikimrServices::VIEWER, "Started",
+ {"logPrefix", GetLogPrefix()},
+ {"maxCounter", MaxCounter},
+ {"period", Period},
+ {"failChance", FailChance},
+ {"contentType", ContentType});
HttpResponse = HttpEvent->Get()->Request->CreateResponseString(Viewer->GetChunkedHTTPOK(GetRequest(), "multipart/x-mixed-replace;boundary=boundary"));
Send(HttpEvent->Sender, new NHttp::TEvHttpProxy::TEvHttpOutgoingResponse(HttpResponse));
Become(&TThis::StateWork, TDuration::MilliSeconds(Period), new TEvents::TEvWakeup());
@@ -46,11 +51,14 @@ public:
void HandleTimer() {
++Counter;
if (FailChance > 0 && ((ui32)NPrivate::TRandom() % 100) < FailChance) {
- BLOG_D("Simulate fail");
+ YDB_LOG_DEBUG_COMP(NKikimrServices::VIEWER, "Simulate fail",
+ {"logPrefix", GetLogPrefix()});
Send(HttpEvent->Sender, new NHttp::TEvHttpProxy::TEvHttpOutgoingDataChunk("failed"));
return ReplyAndPassAway();
} else {
- BLOG_D("Counter: " << Counter);
+ YDB_LOG_DEBUG_COMP(NKikimrServices::VIEWER, "Dump counter",
+ {"logPrefix", GetLogPrefix()},
+ {"counter", Counter});
TStringBuilder content;
content << "{\"Counter\":" << Counter << "}";
TStringBuilder data;
@@ -72,7 +80,8 @@ public:
}
void ReplyAndPassAway() override {
- BLOG_D("Done");
+ YDB_LOG_DEBUG_COMP(NKikimrServices::VIEWER, "Done",
+ {"logPrefix", GetLogPrefix()});
HttpEvent.Reset(); // to avoid double reply
TBase::ReplyAndPassAway("ok");
}
diff --git a/ydb/core/viewer/viewer_simple_counter.h b/ydb/core/viewer/viewer_simple_counter.h
index 5209ae101aa..3abf33e7a99 100644
--- a/ydb/core/viewer/viewer_simple_counter.h
+++ b/ydb/core/viewer/viewer_simple_counter.h
@@ -33,7 +33,11 @@ public:
MaxCounter = std::clamp<ui32>(FromStringWithDefault(params.Get("max_counter"), MaxCounter), 1, 100000);
Period = std::clamp<ui32>(FromStringWithDefault(params.Get("period"), Period), 1, 100000);
FailChance = std::clamp<ui32>(FromStringWithDefault(params.Get("fail_chance"), FailChance), 0, 100);
- BLOG_D("Started MaxCounter: " << MaxCounter << ", Period: " << Period << ", FailChance: " << FailChance);
+ YDB_LOG_DEBUG_COMP(NKikimrServices::VIEWER, "Started",
+ {"logPrefix", GetLogPrefix()},
+ {"maxCounter", MaxCounter},
+ {"period", Period},
+ {"failChance", FailChance});
Send(HttpEvent->Sender, new NHttp::TEvHttpProxy::TEvSubscribeForCancel(), IEventHandle::FlagTrackDelivery);
HttpResponse = HttpEvent->Get()->Request->CreateResponseString(Viewer->GetChunkedHTTPOK(GetRequest(), "text/plain"));
Send(HttpEvent->Sender, new NHttp::TEvHttpProxy::TEvHttpOutgoingResponse(HttpResponse));
@@ -43,11 +47,14 @@ public:
void HandleTimer() {
++Counter;
if (FailChance > 0 && ((ui32)NPrivate::TRandom() % 100) < FailChance) {
- BLOG_D("Simulate fail");
+ YDB_LOG_DEBUG_COMP(NKikimrServices::VIEWER, "Simulate fail",
+ {"logPrefix", GetLogPrefix()});
Send(HttpEvent->Sender, new NHttp::TEvHttpProxy::TEvHttpOutgoingDataChunk("failed"));
return ReplyAndPassAway();
}
- BLOG_D("Counter: " << Counter);
+ YDB_LOG_DEBUG_COMP(NKikimrServices::VIEWER, "Dump counter",
+ {"logPrefix", GetLogPrefix()},
+ {"counter", Counter});
auto dataChunk = HttpResponse->CreateDataChunk(TStringBuilder() << Counter << "\n");
if (Counter >= MaxCounter) {
dataChunk->SetEndOfData();
@@ -61,7 +68,8 @@ public:
}
void Cancelled() {
- BLOG_D("Cancelled");
+ YDB_LOG_DEBUG_COMP(NKikimrServices::VIEWER, "Cancelled",
+ {"logPrefix", GetLogPrefix()});
ReplyAndPassAway();
}
@@ -72,7 +80,8 @@ public:
}
void ReplyAndPassAway() override {
- BLOG_D("Done");
+ YDB_LOG_DEBUG_COMP(NKikimrServices::VIEWER, "Done",
+ {"logPrefix", GetLogPrefix()});
HttpEvent.Reset(); // to avoid double reply
TBase::ReplyAndPassAway("ok");
}
diff --git a/ydb/core/viewer/viewer_sse_counter.h b/ydb/core/viewer/viewer_sse_counter.h
index fdf6288fccf..2a6f27b3665 100644
--- a/ydb/core/viewer/viewer_sse_counter.h
+++ b/ydb/core/viewer/viewer_sse_counter.h
@@ -39,7 +39,12 @@ public:
if (params.Has("content_type")) {
ContentType = params.Get("content_type");
}
- BLOG_D("Started MaxCounter: " << MaxCounter << ", Period: " << Period << ", FailChance: " << FailChance << ", ContentType: " << ContentType);
+ YDB_LOG_DEBUG_COMP(NKikimrServices::VIEWER, "Started",
+ {"logPrefix", GetLogPrefix()},
+ {"maxCounter", MaxCounter},
+ {"period", Period},
+ {"failChance", FailChance},
+ {"contentType", ContentType});
HttpResponse = HttpEvent->Get()->Request->CreateResponseString(Viewer->GetChunkedHTTPOK(GetRequest(), "text/event-stream"));
Send(HttpEvent->Sender, new NHttp::TEvHttpProxy::TEvHttpOutgoingResponse(HttpResponse));
if (KeepAlivePeriod) {
@@ -52,11 +57,14 @@ public:
if (ev->Get()->Tag == 0) {
++Counter;
if (FailChance > 0 && ((ui32)NPrivate::TRandom() % 100) < FailChance) {
- BLOG_D("Simulate fail");
+ YDB_LOG_DEBUG_COMP(NKikimrServices::VIEWER, "Simulate fail",
+ {"logPrefix", GetLogPrefix()});
Send(HttpEvent->Sender, new NHttp::TEvHttpProxy::TEvHttpOutgoingDataChunk("failed"));
return ReplyAndPassAway();
} else {
- BLOG_D("Counter: " << Counter);
+ YDB_LOG_DEBUG_COMP(NKikimrServices::VIEWER, "Dump counter",
+ {"logPrefix", GetLogPrefix()},
+ {"counter", Counter});
TStringBuilder content;
content << "event: counter\n";
content << "data: {\"Counter\":" << Counter << "}\n\n";
@@ -83,7 +91,8 @@ public:
}
void ReplyAndPassAway() override {
- BLOG_D("Done");
+ YDB_LOG_DEBUG_COMP(NKikimrServices::VIEWER, "Done",
+ {"logPrefix", GetLogPrefix()});
HttpEvent.Reset(); // to avoid double reply
TBase::ReplyAndPassAway("ok");
}
diff --git a/ydb/core/viewer/viewer_topic_data.cpp b/ydb/core/viewer/viewer_topic_data.cpp
index 6a6bf15cd66..6318dd43027 100644
--- a/ydb/core/viewer/viewer_topic_data.cpp
+++ b/ydb/core/viewer/viewer_topic_data.cpp
@@ -6,6 +6,8 @@
#include <ydb/public/sdk/cpp/include/ydb-cpp-sdk/client/topic/codecs.h>
#include <ydb/services/lib/auth/auth_helpers.h>
+#define YDB_LOG_THIS_FILE_COMPONENT NKikimrServices::VIEWER
+
namespace NKikimr::NViewer {
void TTopicData::HandleDescribe(TEvTxProxySchemeCache::TEvNavigateKeySetResult::TPtr& ev) {
@@ -230,12 +232,13 @@ void TTopicData::FillProtoResponse(ui64 maxTotalSize) {
try {
auto decompressed = codec->DecompressData(dataChunk.GetData());
if (decompressed.Messages.empty()) {
- BLOG_ERROR("Topic data decompression failed"
- << ": path=" << TopicPath
- << ", partition=" << PartitionId
- << ", offset=" << r.GetOffset()
- << ", codec=" << dataChunk.GetCodec()
- << ", error=No messages in decompressed data");
+ YDB_LOG_ERROR("Topic data decompression failed",
+ {"logPrefix", GetLogPrefix()},
+ {"path", TopicPath},
+ {"partition", PartitionId},
+ {"offset", r.GetOffset()},
+ {"codec", dataChunk.GetCodec()},
+ {"error", "No messages in decompressed data"});
return ReplyAndPassAway(GetHTTPINTERNALERROR("text/plain", "Message decompression failed"));
}
@@ -271,12 +274,13 @@ void TTopicData::FillProtoResponse(ui64 maxTotalSize) {
}
continue;
} catch (...) {
- BLOG_ERROR("Topic data decompression failed"
- << ": path=" << TopicPath
- << ", partition=" << PartitionId
- << ", offset=" << r.GetOffset()
- << ", codec=" << dataChunk.GetCodec()
- << ", error=" << CurrentExceptionMessage());
+ YDB_LOG_ERROR("Topic data decompression failed",
+ {"logPrefix", GetLogPrefix()},
+ {"path", TopicPath},
+ {"partition", PartitionId},
+ {"offset", r.GetOffset()},
+ {"codec", dataChunk.GetCodec()},
+ {"error", CurrentExceptionMessage()});
return ReplyAndPassAway(GetHTTPINTERNALERROR("text/plain", "Message decompression failed"));
}
} else {