You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In case of any errors, either a faulty route which throws an exception or requests to a non-existing route, the interceptor chain behaves differently than on requests to routes which responds properly.
In a normal situation the ApplicationSendPipeline is executed during the execution of the ApplicationCallPipeline, which enables us to trace an entire request/response situation using e.g. the Monitoring phase:
Because we are executing within the ApplicationCallPipeline we get the added bonus that our log messages gets enriched with stuff like CallId.
However, when an error occurs (because the route does not exist, or the handler threw an exception) the ApplicationCallPipeline gets interrupted. Then some error handling is done by the DefaultEnginePipeline which tries to set a reasonable status code (404 in case of a non-existing route, 500 in case of exceptions) and logs the exception (no CallId here!).
But because the ApplicationCallPipeline got interrupted, the Monitoring interceptor from above has already exited, so it did never get a chance to act on the response code set by DefaultEnginePipeline.
After DefaultEnginePipeline has done its thing, the ApplicationSendPipeline is executed with the new response. And because ApplicationSendPipeline does not share any attributes with the ApplicationCallPipeline, we do not get the bonus of having things like CallId.
In short, it's hard to properly log a request with the resulting status code, with things like CallId. Because if we want to handle the quirks I've just mentioned, we have to do something like:
På grunn av at ktor håndterer innkommende kall ulikt om det er en route som finnes, eller om det er en route som kaster exception, eller om routen ikke finnes i det hele tatt,
har vi sett behovet for å håndtere logging av kall selv. CallLogging-featuren vil bare logge tilfeller hvor routen finnes og kallet er OK (ingen exception som kastes), eller tilfeller hvor routen ikke finnes i det hele tatt. Den håndterer altså ikke tilfeller hvor routen kaster exception, men dette er fordi ktor selv har en mangelfull håndtering av dette.
Se ktorio/ktor#1186 for mer utfyllende informasjon.
In case of any errors, either a faulty route which throws an exception or requests to a non-existing route, the interceptor chain behaves differently than on requests to routes which responds properly.
In a normal situation the
ApplicationSendPipeline
is executed during the execution of theApplicationCallPipeline
, which enables us to trace an entire request/response situation using e.g. theMonitoring
phase:Because we are executing within the
ApplicationCallPipeline
we get the added bonus that our log messages gets enriched with stuff likeCallId
.However, when an error occurs (because the route does not exist, or the handler threw an exception) the
ApplicationCallPipeline
gets interrupted. Then some error handling is done by theDefaultEnginePipeline
which tries to set a reasonable status code (404 in case of a non-existing route, 500 in case of exceptions) and logs the exception (noCallId
here!).But because the
ApplicationCallPipeline
got interrupted, theMonitoring
interceptor from above has already exited, so it did never get a chance to act on the response code set byDefaultEnginePipeline
.After
DefaultEnginePipeline
has done its thing, theApplicationSendPipeline
is executed with the new response. And becauseApplicationSendPipeline
does not share any attributes with theApplicationCallPipeline
, we do not get the bonus of having things likeCallId
.In short, it's hard to properly log a request with the resulting status code, with things like
CallId
. Because if we want to handle the quirks I've just mentioned, we have to do something like:The text was updated successfully, but these errors were encountered: