Skip to content

Commit

Permalink
fix viewer api, restore monitoring ui (#5015)
Browse files Browse the repository at this point in the history
  • Loading branch information
adameat authored May 30, 2024
1 parent f2fac86 commit 5b7a720
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
3 changes: 1 addition & 2 deletions ydb/core/viewer/json_browse.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,8 @@ class TJsonBrowse : public TActorBootstrapped<TJsonBrowse> {
}
}
TStringStream result;
result << Viewer->GetHTTPGATEWAYTIMEOUT(Event->Get());
RenderPendingRequests(result);
ctx.Send(Event->Sender, new NMon::TEvHttpInfoRes(result.Str(), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
ctx.Send(Event->Sender, new NMon::TEvHttpInfoRes(Viewer->GetHTTPGATEWAYTIMEOUT(Event->Get(), result.Str()), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
Die(ctx);
}

Expand Down
3 changes: 1 addition & 2 deletions ydb/core/viewer/json_metainfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,8 @@ class TJsonMetaInfo : public TActorBootstrapped<TJsonMetaInfo> {

void HandleTimeout(const TActorContext &ctx) {
TStringStream result;
result << Viewer->GetHTTPGATEWAYTIMEOUT(Event->Get());
RenderPendingRequests(result);
ctx.Send(Event->Sender, new NMon::TEvHttpInfoRes(result.Str(), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
ctx.Send(Event->Sender, new NMon::TEvHttpInfoRes(Viewer->GetHTTPGATEWAYTIMEOUT(Event->Get(), result.Str()), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
Die(ctx);
}

Expand Down
15 changes: 6 additions & 9 deletions ydb/core/viewer/json_query.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,11 @@ class TJsonQuery : public TViewerPipeClient<TJsonQuery> {

void Handle(NKikimrKqp::TEvQueryResponse& record) {
if (Event) {
TStringBuilder out;
NJson::TJsonValue jsonResponse;
if (record.GetYdbStatus() == Ydb::StatusIds::SUCCESS) {
MakeOkReply(out, jsonResponse, record);
MakeOkReply(jsonResponse, record);
} else {
MakeErrorReply(out, jsonResponse, record);
MakeErrorReply(jsonResponse, record);
}

if (Schema == ESchemaType::Classic && Stats.empty() && (Action.empty() || Action == "execute")) {
Expand All @@ -406,9 +405,8 @@ class TJsonQuery : public TViewerPipeClient<TJsonQuery> {
config.ValidateUtf8 = false;
config.WriteNanAsString = true;
NJson::WriteJson(&stream, &jsonResponse, config);
out << stream.Str();

ReplyAndPassAway(out);
ReplyAndPassAway(stream.Str());
} else {
TEvViewer::TEvViewerResponse* response = new TEvViewer::TEvViewerResponse();
response->Record.MutableQueryResponse()->CopyFrom(record);
Expand Down Expand Up @@ -471,8 +469,7 @@ class TJsonQuery : public TViewerPipeClient<TJsonQuery> {
}

private:
void MakeErrorReply(TStringBuilder& out, NJson::TJsonValue& jsonResponse, NKikimrKqp::TEvQueryResponse& record) {
out << Viewer->GetHTTPBADREQUEST(Event->Get(), "application/json");
void MakeErrorReply(NJson::TJsonValue& jsonResponse, NKikimrKqp::TEvQueryResponse& record) {
NJson::TJsonValue& jsonIssues = jsonResponse["issues"];

// find first deepest error
Expand All @@ -493,7 +490,7 @@ class TJsonQuery : public TViewerPipeClient<TJsonQuery> {
}
}

void MakeOkReply(TStringBuilder& out, NJson::TJsonValue& jsonResponse, NKikimrKqp::TEvQueryResponse& record) {
void MakeOkReply(NJson::TJsonValue& jsonResponse, NKikimrKqp::TEvQueryResponse& record) {
const auto& response = record.GetResponse();

if (response.ResultsSize() > 0 || response.YdbResultsSize() > 0) {
Expand All @@ -512,7 +509,7 @@ class TJsonQuery : public TViewerPipeClient<TJsonQuery> {
Ydb::Issue::IssueMessage* issue = record.MutableResponse()->AddQueryIssues();
issue->set_message(Sprintf("Convert error: %s", ex.what()));
issue->set_severity(NYql::TSeverityIds::S_ERROR);
MakeErrorReply(out, jsonResponse, record);
MakeErrorReply(jsonResponse, record);
return;
}
}
Expand Down

0 comments on commit 5b7a720

Please sign in to comment.