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
An
AccessLogWriter that sends access logs to a Kafka backend.
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.
-
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
Modifier and Type Method Description voidlog(com.linecorp.armeria.common.logging.RequestLog log)CompletableFuture<Void>shutdown()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.linecorp.armeria.server.logging.AccessLogWriter
andThen
-
Constructor Details
-
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 Details
-
log
public void log(com.linecorp.armeria.common.logging.RequestLog log)- Specified by:
login interfacecom.linecorp.armeria.server.logging.AccessLogWriter
-
shutdown
- Specified by:
shutdownin interfacecom.linecorp.armeria.server.logging.AccessLogWriter
-