@@ -74,32 +74,33 @@ TGetLabelsResponse ProcessGetLabelsResponse(NYql::IHTTPGateway::TResult&& respon
74
74
TGetLabelsResult result;
75
75
76
76
if (response.CurlResponseCode != CURLE_OK) {
77
- return TGetLabelsResponse (TStringBuilder{} << " Error while sending list metric names request to monitoring api: " << response.Issues .ToOneLineString () << " (curl status: " << curl_easy_strerror (response.CurlResponseCode ) << " )" );
77
+ return TGetLabelsResponse (TStringBuilder{} << " Monitoring api get labels response: " << response.Issues .ToOneLineString () <<
78
+ " , internal code: " << static_cast <int >(response.CurlResponseCode ));
78
79
}
79
80
80
81
if (response.Content .HttpResponseCode < 200 || response.Content .HttpResponseCode >= 300 ) {
81
- return TGetLabelsResponse (TStringBuilder{} << " Error while sending list metric names request to monitoring api: " << response.Content .data () << " (http status: " << response.Content .HttpResponseCode << " )" );
82
+ return TGetLabelsResponse (TStringBuilder{} << " Monitoring api get labels response: " << response.Content .data () <<
83
+ " , internal code: " << response.Content .HttpResponseCode );
82
84
}
83
85
84
86
NJson::TJsonValue json;
85
87
try {
86
88
NJson::ReadJsonTree (response.Content .data (), &json, /* throwOnError*/ true );
87
89
} catch (const std::exception& e) {
88
- return TGetLabelsResponse (TStringBuilder{} << " Failed to parse response from monitoring api: " << e. what () );
90
+ return TGetLabelsResponse (" Monitoring api get labels response is not a valid json " );
89
91
}
90
92
91
93
if (!json.IsMap () || !json.Has (" names" ) || !json[" names" ].IsArray ()) {
92
- return TGetLabelsResponse (" Invalid result from monitoring api " );
94
+ return TGetLabelsResponse (" Monitoring api get labels response doesn't contain requested info " );
93
95
}
94
96
95
97
const auto names = json[" names" ].GetArray ();
96
98
97
99
for (const auto & name : names) {
98
100
if (!name.IsString ()) {
99
- return TGetLabelsResponse (" Invalid label names from monitoring api" );
100
- } else {
101
- result.Labels .push_back (name.GetString ());
101
+ return TGetLabelsResponse (" Monitoring api get labels response contains invalid label names" );
102
102
}
103
+ result.Labels .push_back (name.GetString ());
103
104
}
104
105
for (const auto & [key, selector] : knownSelectors) {
105
106
result.Labels .push_back (key);
@@ -112,37 +113,39 @@ TListMetricsResponse ProcessListMetricsResponse(NYql::IHTTPGateway::TResult&& re
112
113
TListMetricsResult result;
113
114
114
115
if (response.CurlResponseCode != CURLE_OK) {
115
- return TListMetricsResponse (TStringBuilder{} << " Error while sending list metrics request to monitoring api: " << response.Issues .ToOneLineString ());
116
+ return TListMetricsResponse (TStringBuilder{} << " Monitoring api list metrics response: " << response.Issues .ToOneLineString () <<
117
+ " , internal code: " << static_cast <int >(response.CurlResponseCode ));
116
118
}
117
119
118
120
if (response.Content .HttpResponseCode < 200 || response.Content .HttpResponseCode >= 300 ) {
119
- return TListMetricsResponse (TStringBuilder{} << " Error while sending list metrics request to monitoring api: " << response.Content .data ());
121
+ return TListMetricsResponse (TStringBuilder{} << " Monitoring api list metrics response: " << response.Content .data () <<
122
+ " , internal code: " << response.Content .HttpResponseCode );
120
123
}
121
124
122
125
NJson::TJsonValue json;
123
126
try {
124
127
NJson::ReadJsonTree (response.Content .data (), &json, /* throwOnError*/ true );
125
128
} catch (const std::exception& e) {
126
- return TListMetricsResponse (TStringBuilder{} << " Failed to parse response from monitoring api: " << e. what () );
129
+ return TListMetricsResponse (" Monitoring api list metrics response is not a valid json " );
127
130
}
128
131
129
132
if (!json.IsMap () || !json.Has (" result" ) || !json.Has (" page" )) {
130
- return TListMetricsResponse (" Invalid list metrics result from monitoring api " );
133
+ return TListMetricsResponse (" Monitoring api list metrics response doesn't contain requested info " );
131
134
}
132
135
133
136
const auto pagesInfo = json[" page" ];
134
137
if (!pagesInfo.IsMap () ||
135
138
!pagesInfo.Has (" pagesCount" ) || !pagesInfo[" pagesCount" ].IsInteger () ||
136
139
!pagesInfo.Has (" totalCount" ) || !pagesInfo[" totalCount" ].IsInteger ()) {
137
- return TListMetricsResponse (" Invalid paging info from monitoring api " );
140
+ return TListMetricsResponse (" Monitoring api list metrics response doesn't contain paging info " );
138
141
}
139
142
140
143
result.PagesCount = pagesInfo[" pagesCount" ].GetInteger ();
141
144
result.TotalCount = pagesInfo[" totalCount" ].GetInteger ();
142
145
143
146
for (const auto & metricObj : json[" result" ].GetArray ()) {
144
147
if (!metricObj.IsMap () || !metricObj.Has (" labels" ) || !metricObj[" labels" ].IsMap () || !metricObj.Has (" type" ) || !metricObj[" type" ].IsString ()) {
145
- return TListMetricsResponse (" Invalid list metrics result from monitoring api " );
148
+ return TListMetricsResponse (" Monitoring api list metrics response contains invalid metrics " );
146
149
}
147
150
148
151
TSelectors selectors;
@@ -173,22 +176,24 @@ TGetPointsCountResponse ProcessGetPointsCountResponse(NYql::IHTTPGateway::TResul
173
176
}
174
177
}
175
178
176
- return TGetPointsCountResponse (TStringBuilder () << " Error while sending points count request to monitoring api: " << issues);
179
+ return TGetPointsCountResponse (TStringBuilder () << " Monitoring api points count response: " << issues <<
180
+ " , internal code: " << static_cast <int >(response.CurlResponseCode ));
177
181
}
178
182
179
183
if (response.Content .HttpResponseCode < 200 || response.Content .HttpResponseCode >= 300 ) {
180
- return TGetPointsCountResponse (TStringBuilder{} << " Error while sending points count request to monitoring api: " << response.Content .data ());
184
+ return TGetPointsCountResponse (TStringBuilder{} << " Monitoring api points count response: " << response.Content .data () <<
185
+ " , internal code: " << response.Content .HttpResponseCode );
181
186
}
182
187
183
188
NJson::TJsonValue json;
184
189
try {
185
190
NJson::ReadJsonTree (response.Content .data (), &json, /* throwOnError*/ true );
186
191
} catch (const std::exception& e) {
187
- return TGetPointsCountResponse (TStringBuilder{} << " Failed to parse points count response from monitoring api: " << e. what () );
192
+ return TGetPointsCountResponse (" Monitoring api points count response is not a valid json " );
188
193
}
189
194
190
195
if (!json.IsMap () || !json.Has (" scalar" ) || !json[" scalar" ].IsInteger ()) {
191
- return TGetPointsCountResponse (" Invalid points count result from monitoring api " );
196
+ return TGetPointsCountResponse (" Monitoring api points count response doesn't contain requested info " );
192
197
}
193
198
194
199
result.PointsCount = json[" scalar" ].GetInteger () + downsampledPointsCount;
@@ -200,15 +205,15 @@ TGetDataResponse ProcessGetDataResponse(NYdbGrpc::TGrpcStatus&& status, ReadResp
200
205
TGetDataResult result;
201
206
202
207
if (!status.Ok ()) {
203
- TString error = TStringBuilder{} << " Error while sending data request to monitoring api : " << status.Msg ;
208
+ TString error = TStringBuilder{} << " Monitoring api get data response : " << status.Msg ;
204
209
if (status.GRpcStatusCode == grpc::StatusCode::RESOURCE_EXHAUSTED || status.GRpcStatusCode == grpc::StatusCode::UNAVAILABLE) {
205
210
return TGetDataResponse (error, EStatus::STATUS_RETRIABLE_ERROR);
206
211
}
207
212
return TGetDataResponse (error);
208
213
}
209
214
210
215
if (response.response_per_query_size () != 1 ) {
211
- return TGetDataResponse (" Invalid get data repsonse size from monitoring api " );
216
+ return TGetDataResponse (" Monitoring api get data response is invalid " );
212
217
}
213
218
214
219
const auto & responseValue = response.response_per_query ()[0 ];
@@ -579,7 +584,7 @@ class TSolomonAccessorClient : public ISolomonAccessorClient, public std::enable
579
584
fullSelectors[labelName] = {" =" , " -" };
580
585
}
581
586
}
582
- return selectors ;
587
+ return fullSelectors ;
583
588
}
584
589
585
590
TString BuildSelectorsProgram (const TSelectors& selectors, bool useNewFormat = false ) const {
0 commit comments