Skip to content

Commit 93e8d46

Browse files
author
ivan-skryabin
committed
feat core: add response body length tag
commit_hash:986ec6907438837bba5f609f71c15f3b9a5f9aca
1 parent 425bc11 commit 93e8d46

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

core/src/server/middlewares/handler_adapter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ namespace {
3030
constexpr utils::StringLiteral kTracingTypeRequest = "request";
3131
constexpr utils::StringLiteral kTracingBody = "body";
3232
constexpr utils::StringLiteral kTracingUri = "uri";
33+
constexpr utils::StringLiteral kTracingRequestBodyLength = "request_body_length";
3334

3435
constexpr utils::StringLiteral kAcceptLanguageTag = "acceptlang";
3536

@@ -149,7 +150,7 @@ void HandlerAdapter::LogRequest(const http::HttpRequest& request, request::Reque
149150
logging::LogExtra log_extra{
150151
{tracing::kHttpMetaType, meta_type},
151152
{tracing::kType, kTracingTypeRequest},
152-
{"request_body_length", request.RequestBody().length()},
153+
{kTracingRequestBodyLength, request.RequestBody().length()},
153154
{kTracingBody, handler_.GetRequestBodyForLoggingChecked(request, context, request.RequestBody())},
154155
{kTracingUri, handler_.GetUrlForLoggingChecked(request, context)},
155156
{tracing::kHttpMethod, request.GetMethodStr()},

core/src/server/middlewares/tracing.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ namespace {
2828
constexpr utils::StringLiteral kTracingTypeResponse = "response";
2929
constexpr utils::StringLiteral kTracingBody = "body";
3030
constexpr utils::StringLiteral kTracingUri = "uri";
31+
constexpr utils::StringLiteral kTracingResponseBodyLength = "response_body_length";
3132

3233
std::string GetHeadersLogString(const http::HttpResponse& response) {
3334
std::string result;
@@ -177,6 +178,7 @@ void Tracing::EnrichLogs(
177178
std::string{kTracingBody},
178179
handler_.GetResponseDataForLoggingChecked(request, context, response.GetData())
179180
);
181+
span.AddNonInheritableTag(std::string{kTracingResponseBodyLength}, response.GetData().length());
180182
}
181183
span.AddNonInheritableTag(std::string{kTracingUri}, handler_.GetUrlForLoggingChecked(request, context));
182184
} catch (const std::exception& ex) {

0 commit comments

Comments
 (0)