diff options
author | mokhotskii <mokhotskii@ydb.tech> | 2022-12-20 15:15:12 +0300 |
---|---|---|
committer | mokhotskii <mokhotskii@ydb.tech> | 2022-12-20 15:15:12 +0300 |
commit | c837319be21082507754b20651443a97e0c75d18 (patch) | |
tree | 7e3b198f87ec148f4f8e298718e771a24fa5370b | |
parent | efc2cddd93e8fed0ed26ef60377f40818c4de1bf (diff) | |
download | ydb-c837319be21082507754b20651443a97e0c75d18.tar.gz |
Revert deletion of deprecated proxy metrics
Revert "Remove deprecated metrics"
This reverts commit 4630b40575f2f0a9d988559b4e4f41f410d96904.
-rw-r--r-- | ydb/core/http_proxy/custom_metrics.h | 92 | ||||
-rw-r--r-- | ydb/core/http_proxy/http_req.cpp | 24 |
2 files changed, 111 insertions, 5 deletions
diff --git a/ydb/core/http_proxy/custom_metrics.h b/ydb/core/http_proxy/custom_metrics.h index b4bd16edad..318f790be9 100644 --- a/ydb/core/http_proxy/custom_metrics.h +++ b/ydb/core/http_proxy/custom_metrics.h @@ -16,24 +16,52 @@ void FillOutputCustomMetrics(const TProtoResult& result, const THttpRequestConte Y_UNUSED(result, httpContext, ctx); } -TVector<std::pair<TString, TString>> BuildLabels(const TString& method, const THttpRequestContext& httpContext, const TString& name) { +TVector<std::pair<TString, TString>> BuildLabels(const TString& method, const THttpRequestContext& httpContext, const TString& name, bool setStreamPrefix = false) { + if (setStreamPrefix) { + if (method.empty()) { + return {{"cloud", httpContext.CloudId}, {"folder", httpContext.FolderId}, + {"database", httpContext.DatabaseId}, {"stream", httpContext.StreamName}, + {"name", name}}; + } + return {{"method", method}, {"cloud", httpContext.CloudId}, {"folder", httpContext.FolderId}, + {"database", httpContext.DatabaseId}, {"stream", httpContext.StreamName}, + {"name", name}}; + } if (method.empty()) { - return { {"database", httpContext.DatabaseName}, {"cloud_id", httpContext.CloudId}, + return {{"database", httpContext.DatabaseName}, {"cloud_id", httpContext.CloudId}, {"folder_id", httpContext.FolderId}, {"database_id", httpContext.DatabaseId}, {"topic", httpContext.StreamName}, {"name", name}}; } - return { {"database", httpContext.DatabaseName}, {"method", method}, {"cloud_id", httpContext.CloudId}, + return {{"database", httpContext.DatabaseName}, {"method", method}, {"cloud_id", httpContext.CloudId}, {"folder_id", httpContext.FolderId}, {"database_id", httpContext.DatabaseId}, {"topic", httpContext.StreamName}, {"name", name}}; } +static const bool setStreamPrefix{true}; + template <> void FillInputCustomMetrics<PutRecordsRequest>(const PutRecordsRequest& request, const THttpRequestContext& httpContext, const TActorContext& ctx) { + /* deprecated metric: */ ctx.Send(MakeMetricsServiceID(), + new TEvServerlessProxy::TEvCounter{request.records_size(), true, true, + BuildLabels("", httpContext, "stream.incoming_records_per_second", setStreamPrefix) + }); + i64 bytes = 0; for (auto& rec : request.records()) { bytes += rec.data().size() + rec.partition_key().size() + rec.explicit_hash_key().size(); } + + /* deprecated metric */ ctx.Send(MakeMetricsServiceID(), + new TEvServerlessProxy::TEvCounter{bytes, true, true, + BuildLabels("", httpContext, "stream.incoming_bytes_per_second", setStreamPrefix) + }); + + /* deprecated metric: */ ctx.Send(MakeMetricsServiceID(), + new TEvServerlessProxy::TEvCounter{bytes, true, true, + BuildLabels("", httpContext, "stream.put_records.bytes_per_second", setStreamPrefix) + }); + ctx.Send(MakeMetricsServiceID(), new TEvServerlessProxy::TEvCounter{bytes, true, true, BuildLabels("PutRecords", httpContext, "api.http.data_streams.request.bytes") @@ -42,6 +70,14 @@ void FillInputCustomMetrics<PutRecordsRequest>(const PutRecordsRequest& request, template <> void FillInputCustomMetrics<PutRecordRequest>(const PutRecordRequest& request, const THttpRequestContext& httpContext, const TActorContext& ctx) { + /* deprecated metric: */ ctx.Send(MakeMetricsServiceID(), + new TEvServerlessProxy::TEvCounter{1, true, true, + BuildLabels("", httpContext, "stream.incoming_records_per_second", setStreamPrefix) + }); + /* deprecated metric: */ ctx.Send(MakeMetricsServiceID(), + new TEvServerlessProxy::TEvCounter{1, true, true, + BuildLabels("", httpContext, "stream.put_record.records_per_second", setStreamPrefix) + }); ctx.Send(MakeMetricsServiceID(), new TEvServerlessProxy::TEvCounter{1, true, true, BuildLabels("", httpContext, "api.http.data_streams.put_record.messages") @@ -49,6 +85,14 @@ void FillInputCustomMetrics<PutRecordRequest>(const PutRecordRequest& request, c i64 bytes = request.data().size() + request.partition_key().size() + request.explicit_hash_key().size(); + /* deprecated metric: */ ctx.Send(MakeMetricsServiceID(), + new TEvServerlessProxy::TEvCounter{bytes, true, true, + BuildLabels("", httpContext, "stream.incoming_bytes_per_second", setStreamPrefix) + }); + /* deprecated metric: */ ctx.Send(MakeMetricsServiceID(), + new TEvServerlessProxy::TEvCounter{bytes, true, true, + BuildLabels("", httpContext, "stream.put_record.bytes_per_second", setStreamPrefix) + }); ctx.Send(MakeMetricsServiceID(), new TEvServerlessProxy::TEvCounter{bytes, true, true, BuildLabels("PutRecord", httpContext, "api.http.data_streams.request.bytes") @@ -59,8 +103,10 @@ void FillInputCustomMetrics<PutRecordRequest>(const PutRecordRequest& request, c template <> void FillOutputCustomMetrics<PutRecordResult>(const PutRecordResult& result, const THttpRequestContext& httpContext, const TActorContext& ctx) { Y_UNUSED(result); - Y_UNUSED(httpContext); - Y_UNUSED(ctx); + /* deprecated metric: */ ctx.Send(MakeMetricsServiceID(), + new TEvServerlessProxy::TEvCounter{1, true, true, + BuildLabels("", httpContext, "stream.put_record.success_per_second", setStreamPrefix) + }); } @@ -69,17 +115,33 @@ void FillOutputCustomMetrics<PutRecordsResult>(const PutRecordsResult& result, c i64 failed = result.failed_record_count(); i64 success = result.records_size() - failed; if (success > 0) { + /* deprecated metric: */ ctx.Send(MakeMetricsServiceID(), + new TEvServerlessProxy::TEvCounter{1, true, true, + BuildLabels("", httpContext, "stream.put_records.success_per_second", setStreamPrefix) + }); + /* deprecated metric: */ ctx.Send(MakeMetricsServiceID(), + new TEvServerlessProxy::TEvCounter{success, true, true, + BuildLabels("", httpContext, "stream.put_records.successfull_records_per_second", setStreamPrefix) + }); ctx.Send(MakeMetricsServiceID(), new TEvServerlessProxy::TEvCounter{success, true, true, BuildLabels("", httpContext, "api.http.data_streams.put_records.successfull_messages") }); } + /* deprecated metric: */ ctx.Send(MakeMetricsServiceID(), + new TEvServerlessProxy::TEvCounter{result.records_size(), true, true, + BuildLabels("", httpContext, "stream.put_records.total_records_per_second", setStreamPrefix) + }); ctx.Send(MakeMetricsServiceID(), new TEvServerlessProxy::TEvCounter{result.records_size(), true, true, BuildLabels("", httpContext, "api.http.data_streams.put_records.total_messages") }); if (failed > 0) { + /* deprecated metric: */ ctx.Send(MakeMetricsServiceID(), + new TEvServerlessProxy::TEvCounter{failed, true, true, + BuildLabels("", httpContext, "streams.put_records.failed_records_per_second", setStreamPrefix) + }); ctx.Send(MakeMetricsServiceID(), new TEvServerlessProxy::TEvCounter{failed, true, true, BuildLabels("", httpContext, "api.http.data_streams.put_records.failed_messages") @@ -100,6 +162,26 @@ void FillOutputCustomMetrics<GetRecordsResult>(const GetRecordsResult& result, c ; }); + /* deprecated metric: */ ctx.Send(MakeMetricsServiceID(), + new TEvServerlessProxy::TEvCounter{1, true, true, + BuildLabels("", httpContext, "stream.get_records.success_per_second", setStreamPrefix)} + ); + /* deprecated metric: */ ctx.Send(MakeMetricsServiceID(), + new TEvServerlessProxy::TEvCounter{records_n, true, true, + BuildLabels("", httpContext, "stream.get_records.records_per_second", setStreamPrefix)} + ); + /* deprecated metric: */ ctx.Send(MakeMetricsServiceID(), + new TEvServerlessProxy::TEvCounter{bytes, true, true, + BuildLabels("", httpContext, "stream.get_records.bytes_per_second", setStreamPrefix)} + ); + /* deprecated metric: */ ctx.Send(MakeMetricsServiceID(), + new TEvServerlessProxy::TEvCounter{records_n, true, true, + BuildLabels("", httpContext, "stream.outgoing_records_per_second", setStreamPrefix)} + ); + /* deprecated metric: */ ctx.Send(MakeMetricsServiceID(), + new TEvServerlessProxy::TEvCounter{bytes, true, true, + BuildLabels("", httpContext, "stream.outgoing_bytes_per_second", setStreamPrefix)} + ); ctx.Send(MakeMetricsServiceID(), new TEvServerlessProxy::TEvCounter{records_n, true, true, BuildLabels("", httpContext, "api.http.data_streams.get_records.messages")} diff --git a/ydb/core/http_proxy/http_req.cpp b/ydb/core/http_proxy/http_req.cpp index 3dcaaf4829..da0088023b 100644 --- a/ydb/core/http_proxy/http_req.cpp +++ b/ydb/core/http_proxy/http_req.cpp @@ -394,6 +394,18 @@ namespace NKikimr::NHttpProxy { } void ReplyWithError(const TActorContext& ctx, NYdb::EStatus status, const TString& errorText) { + /* deprecated metric: */ ctx.Send(MakeMetricsServiceID(), + new TEvServerlessProxy::TEvCounter{ + 1, true, true, + {{"method", Method}, + {"cloud", HttpContext.CloudId}, + {"folder", HttpContext.FolderId}, + {"database", HttpContext.DatabaseId}, + {"stream", HttpContext.StreamName}, + {"code", TStringBuilder() << (int)StatusToHttpCode(status)}, + {"name", "api.http.errors_per_second"}} + }); + ctx.Send(MakeMetricsServiceID(), new TEvServerlessProxy::TEvCounter{ 1, true, true, @@ -434,6 +446,10 @@ namespace NKikimr::NHttpProxy { } FillInputCustomMetrics<TProtoRequest>(Request, HttpContext, ctx); + /* deprecated metric: */ ctx.Send(MakeMetricsServiceID(), + new TEvServerlessProxy::TEvCounter{1, true, true, + BuildLabels(Method, HttpContext, "api.http.requests_per_second", setStreamPrefix) + }); ctx.Send(MakeMetricsServiceID(), new TEvServerlessProxy::TEvCounter{1, true, true, BuildLabels(Method, HttpContext, "api.http.data_streams.request.count") @@ -448,6 +464,10 @@ namespace NKikimr::NHttpProxy { void ReportLatencyCounters(const TActorContext& ctx) { TDuration dur = ctx.Now() - StartTime; + /* deprecated metric: */ ctx.Send(MakeMetricsServiceID(), + new TEvServerlessProxy::TEvHistCounter{static_cast<i64>(dur.MilliSeconds()), 1, + BuildLabels(Method, HttpContext, "api.http.requests_duration_milliseconds", setStreamPrefix) + }); ctx.Send(MakeMetricsServiceID(), new TEvServerlessProxy::TEvHistCounter{static_cast<i64>(dur.MilliSeconds()), 1, BuildLabels(Method, HttpContext, "api.http.data_streams.response.duration_milliseconds") @@ -463,6 +483,10 @@ namespace NKikimr::NHttpProxy { *(dynamic_cast<TProtoResult*>(ev->Get()->Message.Get())), HttpContext, ctx); ReportLatencyCounters(ctx); + /* deprecated metric: */ ctx.Send(MakeMetricsServiceID(), + new TEvServerlessProxy::TEvCounter{1, true, true, + BuildLabels(Method, HttpContext, "api.http.success_per_second", setStreamPrefix) + }); ctx.Send(MakeMetricsServiceID(), new TEvServerlessProxy::TEvCounter{ 1, true, true, |