public class KafkaStructuredLoggingService<I extends com.linecorp.armeria.common.Request,O extends com.linecorp.armeria.common.Response,L>
extends com.linecorp.armeria.server.logging.structured.StructuredLoggingService<I,O,L>
This method returns immediately after the Producer.send(ProducerRecord, Callback) returns rather
than waiting for returned Future completes so logs which are written and are not yet flushed can
be lost if an application crashes in unclean way.
Refer variety of newDecorator(org.apache.kafka.clients.producer.Producer<byte[], L>, java.lang.String, com.linecorp.armeria.server.logging.structured.StructuredLogBuilder<L>, com.linecorp.armeria.server.logging.structured.kafka.KafkaStructuredLoggingService.KeySelector<L>) methods to see how to enable Kafka based structured logging.
| Modifier and Type | Class and Description |
|---|---|
static interface |
KafkaStructuredLoggingService.KeySelector<E>
Implements "key" selector of Kafka based service log writer.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
close() |
static <I extends com.linecorp.armeria.common.Request,O extends com.linecorp.armeria.common.Response,L> |
newDecorator(Producer<byte[],L> producer,
String topic,
com.linecorp.armeria.server.logging.structured.StructuredLogBuilder<L> logBuilder)
Creates a decorator which provides
StructuredLoggingService with defaulting key to null. |
static <I extends com.linecorp.armeria.common.Request,O extends com.linecorp.armeria.common.Response,L> |
newDecorator(Producer<byte[],L> producer,
String topic,
com.linecorp.armeria.server.logging.structured.StructuredLogBuilder<L> logBuilder,
KafkaStructuredLoggingService.KeySelector<L> keySelector)
Creates a decorator which provides
StructuredLoggingService with full set of arguments. |
static <I extends com.linecorp.armeria.common.Request,O extends com.linecorp.armeria.common.Response,L> |
newDecorator(String bootstrapServers,
String topic,
com.linecorp.armeria.server.logging.structured.StructuredLogBuilder<L> logBuilder)
Creates a decorator which provides
StructuredLoggingService with default Producer
and defaulting key to null. |
static <I extends com.linecorp.armeria.common.Request,O extends com.linecorp.armeria.common.Response,L> |
newDecorator(String bootstrapServers,
String topic,
com.linecorp.armeria.server.logging.structured.StructuredLogBuilder<L> logBuilder,
KafkaStructuredLoggingService.KeySelector<L> keySelector)
Creates a decorator which provides
StructuredLoggingService with default Producer. |
protected void |
writeLog(com.linecorp.armeria.common.logging.RequestLog log,
L structuredLog) |
serve, serviceAddedas, delegate, shouldCachePath, toStringpublic static <I extends com.linecorp.armeria.common.Request,O extends com.linecorp.armeria.common.Response,L> Function<com.linecorp.armeria.server.Service<I,O>,com.linecorp.armeria.server.logging.structured.StructuredLoggingService<I,O,L>> newDecorator(Producer<byte[],L> producer, String topic, com.linecorp.armeria.server.logging.structured.StructuredLogBuilder<L> logBuilder, @Nullable KafkaStructuredLoggingService.KeySelector<L> keySelector)
StructuredLoggingService with full set of arguments.I - the Request typeO - the Response typeL - the type of the structured log representationproducer - a kafka Producer producer which is used to send logs to Kafkatopic - a name of topic which is used to send logslogBuilder - an instance of StructuredLogBuilder which is used to construct a log entrykeySelector - a KafkaStructuredLoggingService.KeySelector which is used to decide what key to use for the logpublic static <I extends com.linecorp.armeria.common.Request,O extends com.linecorp.armeria.common.Response,L> Function<com.linecorp.armeria.server.Service<I,O>,com.linecorp.armeria.server.logging.structured.StructuredLoggingService<I,O,L>> newDecorator(Producer<byte[],L> producer, String topic, com.linecorp.armeria.server.logging.structured.StructuredLogBuilder<L> logBuilder)
StructuredLoggingService with defaulting key to null.I - the Request typeO - the Response typeL - the type of the structured log representationproducer - a kafka Producer producer which is used to send logs to Kafkatopic - a name of topic which is used to send logslogBuilder - an instance of StructuredLogBuilder which is used to construct a log entrypublic static <I extends com.linecorp.armeria.common.Request,O extends com.linecorp.armeria.common.Response,L> Function<com.linecorp.armeria.server.Service<I,O>,com.linecorp.armeria.server.logging.structured.StructuredLoggingService<I,O,L>> newDecorator(String bootstrapServers, String topic, com.linecorp.armeria.server.logging.structured.StructuredLogBuilder<L> logBuilder, @Nullable KafkaStructuredLoggingService.KeySelector<L> keySelector)
StructuredLoggingService with default Producer.I - the Request typeO - the Response typeL - the type of the structured log representationbootstrapServers - a bootstrap.servers config to specify destination Kafka clustertopic - a name of topic which is used to send logslogBuilder - an instance of StructuredLogBuilder which is used to construct a log entrykeySelector - a KafkaStructuredLoggingService.KeySelector which is used to decide what key to use for the logpublic static <I extends com.linecorp.armeria.common.Request,O extends com.linecorp.armeria.common.Response,L> Function<com.linecorp.armeria.server.Service<I,O>,com.linecorp.armeria.server.logging.structured.StructuredLoggingService<I,O,L>> newDecorator(String bootstrapServers, String topic, com.linecorp.armeria.server.logging.structured.StructuredLogBuilder<L> logBuilder)
StructuredLoggingService with default Producer
and defaulting key to null.I - the Request typeO - the Response typeL - the type of the structured log representationbootstrapServers - a bootstrap.servers config to specify destination Kafka clustertopic - a name of topic which is used to send logslogBuilder - an instance of StructuredLogBuilder which is used to construct a log entryprotected void writeLog(com.linecorp.armeria.common.logging.RequestLog log,
L structuredLog)
© Copyright 2015–2018 LINE Corporation. All rights reserved.