Interface RequestLogBuilder
- All Superinterfaces:
RequestLogAccess
Updates a
RequestLog
with newly available information.-
Method Summary
Modifier and TypeMethodDescriptionvoid
addChild
(RequestLogAccess child) Adds the specifiedRequestLogAccess
so that the logs are propagated from thechild
.void
authenticatedUser
(String authenticatedUser) Sets the remote user of the request if it's authenticated.void
defer
(RequestLogProperty property) Allows setting the specifiedRequestLogProperty
even afterendResponse()
orendResponse(Throwable)
called.void
defer
(RequestLogProperty... properties) Allows setting the specifiedRequestLogProperty
s even afterendResponse()
orendResponse(Throwable)
called.void
defer
(Iterable<RequestLogProperty> properties) Allows setting the specifiedRequestLogProperty
s even afterendResponse()
orendResponse(Throwable)
called.void
Finishes the collection of theRequest
information.void
endRequest
(long requestEndTimeNanos) Finishes the collection of theRequest
information.void
endRequest
(Throwable requestCause) Finishes the collection of theRequest
information.void
endRequest
(Throwable requestCause, long requestEndTimeNanos) Finishes the collection of theRequest
information.void
Finishes the collection of theResponse
information.void
endResponse
(long responseEndTimeNanos) Finishes the collection of theResponse
information.void
endResponse
(Throwable responseCause) Finishes the collection of theResponse
information.void
endResponse
(Throwable responseCause, long responseEndTimeNanos) Finishes the collection of theResponse
information.void
Fills the response-side logs from the last added child.void
increaseRequestLength
(long deltaBytes) Increases theRequestOnlyLog.requestLength()
bydeltaBytes
.void
void
increaseResponseLength
(long deltaBytes) Increases theRequestLog.responseLength()
bydeltaBytes
.void
boolean
isDeferred
(RequestLogProperty property) boolean
isDeferred
(RequestLogProperty... properties) Returnstrue
if all of the specifiedRequestLogProperty
s have been deferred withdefer(RequestLogProperty)
.boolean
isDeferred
(Iterable<RequestLogProperty> properties) Returnstrue
if all of the specifiedRequestLogProperty
s have been deferred withdefer(RequestLogProperty)
.void
Sets the human-readable name of theRequest
, such as RPC method name, annotated service method name or HTTP method name.void
Sets the human-readable service name and method name of theRequest
such as: A service and method name for gRPC and Thrift An innermost class and method name for annotated service A path pattern and HTTP method name forHttpService
This property is often used as a meter tag or distributed trace's span name.void
requestContent
(@Nullable Object requestContent, @Nullable Object rawRequestContent) Sets theRequestOnlyLog.requestContent()
and theRequestOnlyLog.rawRequestContent()
.void
requestContentPreview
(@Nullable String requestContentPreview) Sets theRequestOnlyLog.requestContentPreview()
.void
void
requestFirstBytesTransferred
(long requestFirstBytesTransferredNanos) SetsRequestOnlyLog.requestFirstBytesTransferredTimeNanos()
with the specified timestamp.void
requestHeaders
(RequestHeaders requestHeaders) Sets theRequestOnlyLog.requestHeaders()
.void
requestLength
(long requestLength) Sets theRequestOnlyLog.requestLength()
.void
requestTrailers
(HttpHeaders requestTrailers) Sets theRequestOnlyLog.requestTrailers()
.void
responseCause
(Throwable cause) Sets theRequestLog.responseCause()
without completing the response log.void
responseContent
(@Nullable Object responseContent, @Nullable Object rawResponseContent) Sets theRequestLog.responseContent()
and theRequestLog.rawResponseContent()
.void
responseContentPreview
(@Nullable String responseContentPreview) Sets theRequestLog.responseContentPreview()
.void
void
responseFirstBytesTransferred
(long responseFirstBytesTransferredNanos) SetsRequestLog.responseFirstBytesTransferredTimeNanos()
with the specified timestamp.void
responseHeaders
(ResponseHeaders responseHeaders) Sets theRequestLog.responseHeaders()
.void
responseLength
(long responseLength) Sets theRequestLog.responseLength()
.void
responseTrailers
(HttpHeaders responseTrailers) Sets theRequestLog.responseTrailers()
.void
serializationFormat
(SerializationFormat serializationFormat) Sets theSerializationFormat
.void
session
(@Nullable Channel channel, SessionProtocol sessionProtocol, @Nullable ClientConnectionTimings connectionTimings) Sets the properties related with socket connection.void
session
(@Nullable Channel channel, SessionProtocol sessionProtocol, @Nullable SSLSession sslSession, @Nullable ClientConnectionTimings connectionTimings) Sets the properties related with socket connection.default void
Starts the collection of theRequest
information.void
startRequest
(long requestStartTimeNanos, long requestStartTimeMicros) Starts the collection of theRequest
information.void
Starts the collection ofResponse
information.void
startResponse
(long responseStartTimeNanos, long responseStartTimeMicros) Starts the collection ofResponse
information.Methods inherited from interface com.linecorp.armeria.common.logging.RequestLogAccess
availabilityStamp, children, context, ensureAvailable, ensureAvailable, ensureAvailable, ensureComplete, ensureRequestComplete, getIfAvailable, getIfAvailable, isAvailable, isAvailable, isAvailable, isComplete, isRequestComplete, parent, partial, whenAvailable, whenAvailable, whenAvailable, whenComplete, whenRequestComplete
-
Method Details
-
startRequest
default void startRequest()Starts the collection of theRequest
information. This method sets the following properties: -
startRequest
void startRequest(long requestStartTimeNanos, long requestStartTimeMicros) Starts the collection of theRequest
information. This method sets the following properties:- Parameters:
requestStartTimeNanos
-System.nanoTime()
value when the request started.requestStartTimeMicros
- the number of microseconds since the epoch, e.g.System.currentTimeMillis() * 1000
.
-
session
void session(@Nullable @Nullable Channel channel, SessionProtocol sessionProtocol, @Nullable @Nullable ClientConnectionTimings connectionTimings) Sets the properties related with socket connection. This method sets the following properties:- Parameters:
channel
- theChannel
which handled theRequest
.sessionProtocol
- theSessionProtocol
of the connection.
-
session
void session(@Nullable @Nullable Channel channel, SessionProtocol sessionProtocol, @Nullable @Nullable SSLSession sslSession, @Nullable @Nullable ClientConnectionTimings connectionTimings) Sets the properties related with socket connection. This method sets the following properties:- Parameters:
channel
- theChannel
which handled theRequest
.sessionProtocol
- theSessionProtocol
of the connection.sslSession
- theSSLSession
of the connection, ornull
.
-
serializationFormat
Sets theSerializationFormat
. -
name
Sets the human-readable service name and method name of theRequest
such as:- A service and method name for gRPC and Thrift
- An innermost class and method name for annotated service
- A path pattern and HTTP method name for
HttpService
-
name
Sets the human-readable name of theRequest
, such as RPC method name, annotated service method name or HTTP method name. This property is often used as a meter tag or distributed trace's span name. -
authenticatedUser
Sets the remote user of the request if it's authenticated. The value will be printed out if the access log has%u
format.- See Also:
-
increaseRequestLength
void increaseRequestLength(long deltaBytes) Increases theRequestOnlyLog.requestLength()
bydeltaBytes
. -
increaseRequestLength
-
requestLength
void requestLength(long requestLength) Sets theRequestOnlyLog.requestLength()
. -
requestFirstBytesTransferred
void requestFirstBytesTransferred() -
requestFirstBytesTransferred
void requestFirstBytesTransferred(long requestFirstBytesTransferredNanos) SetsRequestOnlyLog.requestFirstBytesTransferredTimeNanos()
with the specified timestamp. -
requestHeaders
Sets theRequestOnlyLog.requestHeaders()
. -
requestContent
void requestContent(@Nullable @Nullable Object requestContent, @Nullable @Nullable Object rawRequestContent) Sets theRequestOnlyLog.requestContent()
and theRequestOnlyLog.rawRequestContent()
. If the specifiedrequestContent
is anRpcRequest
and theRequestContext.rpcRequest()
isnull
, this method will callRequestContext.updateRpcRequest(RpcRequest)
. -
requestContentPreview
Sets theRequestOnlyLog.requestContentPreview()
. -
requestTrailers
Sets theRequestOnlyLog.requestTrailers()
. -
endRequest
void endRequest()Finishes the collection of theRequest
information. This method sets the following properties: -
endRequest
Finishes the collection of theRequest
information. This method sets the following properties:- Parameters:
requestCause
- the cause of the failure.
-
endRequest
void endRequest(long requestEndTimeNanos) Finishes the collection of theRequest
information. This method sets the following properties:- Parameters:
requestEndTimeNanos
-System.nanoTime()
value when the request ended.
-
endRequest
Finishes the collection of theRequest
information. This method sets the following properties:- Parameters:
requestCause
- the cause of the failure.requestEndTimeNanos
-System.nanoTime()
value when the request ended.
-
startResponse
void startResponse()Starts the collection ofResponse
information. This method sets the following properties: -
startResponse
void startResponse(long responseStartTimeNanos, long responseStartTimeMicros) Starts the collection ofResponse
information. This method sets the following properties:- Parameters:
responseStartTimeNanos
-System.nanoTime()
value when the response started.responseStartTimeMicros
- the number of microseconds since the epoch, e.g.System.currentTimeMillis() * 1000
.
-
increaseResponseLength
void increaseResponseLength(long deltaBytes) Increases theRequestLog.responseLength()
bydeltaBytes
. -
increaseResponseLength
-
responseLength
void responseLength(long responseLength) Sets theRequestLog.responseLength()
. -
responseFirstBytesTransferred
void responseFirstBytesTransferred() -
responseFirstBytesTransferred
void responseFirstBytesTransferred(long responseFirstBytesTransferredNanos) SetsRequestLog.responseFirstBytesTransferredTimeNanos()
with the specified timestamp. -
responseHeaders
Sets theRequestLog.responseHeaders()
. -
responseContent
void responseContent(@Nullable @Nullable Object responseContent, @Nullable @Nullable Object rawResponseContent) Sets theRequestLog.responseContent()
and theRequestLog.rawResponseContent()
. -
responseContentPreview
Sets theRequestLog.responseContentPreview()
. -
responseTrailers
Sets theRequestLog.responseTrailers()
. -
responseCause
Sets theRequestLog.responseCause()
without completing the response log. This method may be useful if you want to send additional data even after an exception is raised. If you want to end the response log right away when an exception is raised, please useendResponse(Throwable)
. -
endResponse
void endResponse()Finishes the collection of theResponse
information. If aThrowable
cause has been set withresponseContent(Object, Object)
, it will be treated as theresponseCause
for this log. This method sets the following properties: -
endResponse
Finishes the collection of theResponse
information. This method sets the following properties:- Parameters:
responseCause
- the cause of the failure.
-
endResponse
void endResponse(long responseEndTimeNanos) Finishes the collection of theResponse
information. If aThrowable
cause has been set withresponseContent(Object, Object)
, it will be treated as theresponseCause
for this log. This method sets the following properties:- Parameters:
responseEndTimeNanos
-System.nanoTime()
value when the response ended.
-
endResponse
Finishes the collection of theResponse
information. This method sets the following properties:- Parameters:
responseCause
- the cause of the failure.responseEndTimeNanos
-System.nanoTime()
value when the response ended.
-
isDeferred
-
isDeferred
Returnstrue
if all of the specifiedRequestLogProperty
s have been deferred withdefer(RequestLogProperty)
. -
isDeferred
Returnstrue
if all of the specifiedRequestLogProperty
s have been deferred withdefer(RequestLogProperty)
. -
defer
Allows setting the specifiedRequestLogProperty
even afterendResponse()
orendResponse(Throwable)
called. Once this method is called, the caller must ensure to call the setter of the specifiedRequestLogProperty
, because otherwise theRequestLog
will never be completed.Note, however, the following
RequestLogProperty
s will be set automatically when theRequestLog
has ended with an exception: -
defer
Allows setting the specifiedRequestLogProperty
s even afterendResponse()
orendResponse(Throwable)
called. Once this method is called, the caller must ensure to call the setters of the specifiedRequestLogProperty
s, because otherwise theRequestLog
will never be completed.Note, however, the following
RequestLogProperty
s will be set automatically when theRequestLog
has ended with an exception: -
defer
Allows setting the specifiedRequestLogProperty
s even afterendResponse()
orendResponse(Throwable)
called. Once this method is called, the caller must ensure to call the setters of the specifiedRequestLogProperty
s, because otherwise theRequestLog
will never be completed.Note, however, the following
RequestLogProperty
s will be set automatically when theRequestLog
has ended with an exception: -
addChild
Adds the specifiedRequestLogAccess
so that the logs are propagated from thechild
. Note that only the request-side logs of the first added child will be propagated. To fill the response-side logs you need to callendResponseWithLastChild()
. -
endResponseWithLastChild
void endResponseWithLastChild()Fills the response-side logs from the last added child. Note that already collected properties in the child log will be propagated immediately.
-