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:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceContextual data available togetLabels(Context). -
Method Summary
Modifier and TypeMethodDescriptiondefault @Nullable Collection<Label> Provides a collection ofLabels to add to each log entry that is logged.default @Nullable Collection<Label> getLabels(LabelProvider.Context context) Provides a collection ofLabels to add to each log entry that is logged.
-
Method Details
-
getLabels
Provides a collection ofLabels to add to each log entry that is logged.If
getLabels(Context)is implemented, this method is ignored.- Returns:
- a collection of
Labels to add to each log entry that is logged. - See Also:
-
getLabels
Provides a collection ofLabels to add to each log entry that is logged.Delegates to
getLabels()by default.- Returns:
- a collection of
Labels to add to each log entry that is logged.
-