Interface StructuredParameterProvider


public interface StructuredParameterProvider
A user-supplied provider for 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;
  }
}
Result:
{
  "jsonPayload": {
    "message": "Request rejected: unauthorized.",
    "traceId": "39f9a49a9567a8bd7087b708f8932550",
    "spanId": "c7431b14630b633d"
  }
}
See Also: