Interface StructuredParameterProvider
public interface StructuredParameterProvider
A user-supplied provider for
Result:
StructuredParameters.
Instances of this interface that are registered with the Formatter are applied to each
log entry that is logged.
If you are using the Quarkus extension, any CDI beans registered under this interface are registered automatically.
Example:
@Singleton
@Unremovable
public final class TraceLogParameterProvider implements StructuredParameterProvider {
@Override
public StructuredParameter getParameter() {
var b = Json.createObjectBuilder();
b.add("traceId", Span.current().getSpanContext().getTraceId());
b.add("spanId", Span.current().getSpanContext().getSpanId());
return () -> b;
}
}
{
"jsonPayload": {
"message": "Request rejected: unauthorized.",
"traceId": "39f9a49a9567a8bd7087b708f8932550",
"spanId": "c7431b14630b633d"
}
}
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceContextual data available togetParameter(Context). -
Method Summary
Modifier and TypeMethodDescriptiondefault @Nullable StructuredParameterProvides aStructuredParameterto add to each log entry that is logged.default @Nullable StructuredParameterProvides aStructuredParameterto add to each log entry that is logged.
-
Method Details
-
getParameter
Provides aStructuredParameterto add to each log entry that is logged.It is often useful to return a custom
StructuredParameterrather than aKeyValueParameterfrom this method. This way multiple key–value pairs can be generated by a single invocation.If
getParameter(Context)is implemented, this method is ignored.- Returns:
- a
StructuredParameterto add to each log entry that is logged. - See Also:
-
getParameter
Provides aStructuredParameterto add to each log entry that is logged.It is often useful to return a custom
StructuredParameterrather than aKeyValueParameterfrom this method. This way multiple key–value pairs can be generated by a single invocation.Delegates to
getParameter()by default.- Returns:
- a
StructuredParameterto add to each log entry that is logged.
-