mirror of https://github.com/Icinga/icinga2.git
HttpServerConnection: log request processing time as well
This commit is contained in:
parent
6c03598678
commit
b6874cc8d4
|
@ -18,6 +18,7 @@
|
||||||
#include "base/timer.hpp"
|
#include "base/timer.hpp"
|
||||||
#include "base/tlsstream.hpp"
|
#include "base/tlsstream.hpp"
|
||||||
#include "base/utility.hpp"
|
#include "base/utility.hpp"
|
||||||
|
#include <chrono>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
@ -493,6 +494,7 @@ void HttpServerConnection::ProcessMessages(boost::asio::yield_context yc)
|
||||||
{
|
{
|
||||||
namespace beast = boost::beast;
|
namespace beast = boost::beast;
|
||||||
namespace http = beast::http;
|
namespace http = beast::http;
|
||||||
|
namespace ch = std::chrono;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/* Do not reset the buffer in the state machine.
|
/* Do not reset the buffer in the state machine.
|
||||||
|
@ -518,6 +520,7 @@ void HttpServerConnection::ProcessMessages(boost::asio::yield_context yc)
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Seen = Utility::GetTime();
|
m_Seen = Utility::GetTime();
|
||||||
|
auto start (ch::steady_clock::now());
|
||||||
|
|
||||||
auto& request (parser.get());
|
auto& request (parser.get());
|
||||||
|
|
||||||
|
@ -541,13 +544,14 @@ void HttpServerConnection::ProcessMessages(boost::asio::yield_context yc)
|
||||||
|
|
||||||
Log logMsg (LogInformation, "HttpServerConnection");
|
Log logMsg (LogInformation, "HttpServerConnection");
|
||||||
|
|
||||||
logMsg << "Request: " << request.method_string() << ' ' << request.target()
|
logMsg << "Request " << request.method_string() << ' ' << request.target()
|
||||||
<< " (from " << m_PeerAddress
|
<< " (from " << m_PeerAddress
|
||||||
<< "), user: " << (authenticatedUser ? authenticatedUser->GetName() : "<unauthenticated>")
|
<< "), user: " << (authenticatedUser ? authenticatedUser->GetName() : "<unauthenticated>")
|
||||||
<< ", agent: " << request[http::field::user_agent]; //operator[] - Returns the value for a field, or "" if it does not exist.
|
<< ", agent: " << request[http::field::user_agent]; //operator[] - Returns the value for a field, or "" if it does not exist.
|
||||||
|
|
||||||
Defer addRespCode ([&response, &logMsg]() {
|
Defer addRespCode ([&response, start, &logMsg]() {
|
||||||
logMsg << ", status: " << response.result() << ").";
|
logMsg << ", status: " << response.result() << ") took "
|
||||||
|
<< ch::duration_cast<ch::milliseconds>(ch::steady_clock::now() - start).count() << "ms.";
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!HandleAccessControl(*m_Stream, request, response, yc)) {
|
if (!HandleAccessControl(*m_Stream, request, response, yc)) {
|
||||||
|
|
Loading…
Reference in New Issue