Interface LabelProvider


public interface LabelProvider
A user-supplied provider for Labels.

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 RequestIdLabelProvider implements LabelProvider {

  @Override
  public Collection<Label> getLabels() {
    return List.of(Label.of("requestId", RequestContext.current().getRequestId()));
  }
}

Result:

{
  "textPayload": "Request rejected: unauthorized.",
  "labels": {
    "requestId": "123"
  }
}
See Also: