Class KafkaAccessLogWriter<K,V>
- java.lang.Object
-
- com.linecorp.armeria.server.logging.kafka.KafkaAccessLogWriter<K,V>
-
- All Implemented Interfaces:
com.linecorp.armeria.server.logging.AccessLogWriter
public final class KafkaAccessLogWriter<K,V> extends Object implements com.linecorp.armeria.server.logging.AccessLogWriter
AnAccessLogWriterthat sends access logs to a Kafka backend.This method returns immediately after the
Producer.send(ProducerRecord, Callback)returns rather than waiting for returnedFuturecompletes so logs which are written and are not yet flushed can be lost if an application crashes in unclean way.
-
-
Constructor Summary
Constructors Constructor Description KafkaAccessLogWriter(Producer<K,V> producer, String topic, Function<? super com.linecorp.armeria.common.logging.RequestLog,? extends K> keyExtractor, Function<? super com.linecorp.armeria.common.logging.RequestLog,? extends V> valueExtractor)Creates a new instance.KafkaAccessLogWriter(Producer<K,V> producer, String topic, Function<? super com.linecorp.armeria.common.logging.RequestLog,? extends V> valueExtractor)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidlog(com.linecorp.armeria.common.logging.RequestLog log)CompletableFuture<Void>shutdown()
-
-
-
Constructor Detail
-
KafkaAccessLogWriter
public KafkaAccessLogWriter(Producer<K,V> producer, String topic, Function<? super com.linecorp.armeria.common.logging.RequestLog,? extends V> valueExtractor)
Creates a new instance.
-
KafkaAccessLogWriter
public KafkaAccessLogWriter(Producer<K,V> producer, String topic, Function<? super com.linecorp.armeria.common.logging.RequestLog,? extends K> keyExtractor, Function<? super com.linecorp.armeria.common.logging.RequestLog,? extends V> valueExtractor)
Creates a new instance.- Parameters:
producer- a KafkaProducerwhich is used to send logs to Kafkatopic- the name of topic which is used to send logskeyExtractor- aFunctionthat extracts aK-typed record key from aRequestLog. TheFunctionis allowed to returnnullto leave the record key unspecified.valueExtractor- aFunctionthat extracts aV-typed record value from aRequestLog. TheFunctionis allowed to returnnullto skip logging for the givenRequestLog.
-
-
Method Detail
-
log
public void log(com.linecorp.armeria.common.logging.RequestLog log)
- Specified by:
login interfacecom.linecorp.armeria.server.logging.AccessLogWriter
-
shutdown
public CompletableFuture<Void> shutdown()
- Specified by:
shutdownin interfacecom.linecorp.armeria.server.logging.AccessLogWriter
-
-