Class KafkaAccessLogWriter<K,V>
java.lang.Object
com.linecorp.armeria.server.logging.kafka.KafkaAccessLogWriter<K,V>
- All Implemented Interfaces:
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
ConstructorDescriptionKafkaAccessLogWriter(Producer<K,V> producer, String topic, Function<? super RequestLog,? extends @Nullable K> keyExtractor, Function<? super RequestLog,? extends @Nullable V> valueExtractor)
Creates a new instance.KafkaAccessLogWriter(Producer<K,V> producer, String topic, Function<? super RequestLog,? extends @Nullable V> valueExtractor)
Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
log(RequestLog log)
Logs the specifiedRequestLog
.shutdown()
Shuts down thisAccessLogWriter
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.linecorp.armeria.server.logging.AccessLogWriter
andThen
-
Constructor Details
-
KafkaAccessLogWriter
public KafkaAccessLogWriter(Producer<K,V> producer, String topic, Function<? super RequestLog,? extends @Nullable V> valueExtractor)Creates a new instance.- Parameters:
producer
- a KafkaProducer
which is used to send logs to Kafkatopic
- the name of topic which is used to send logsvalueExtractor
- aFunction
that extracts aV
-typed record value from aRequestLog
. TheFunction
is allowed to returnnull
to skip logging for the givenRequestLog
.
-
KafkaAccessLogWriter
public KafkaAccessLogWriter(Producer<K,V> producer, String topic, Function<? super RequestLog,? extends @Nullable K> keyExtractor, Function<? super RequestLog,? extends @Nullable V> valueExtractor)Creates a new instance.- Parameters:
producer
- a KafkaProducer
which is used to send logs to Kafkatopic
- the name of topic which is used to send logskeyExtractor
- aFunction
that extracts aK
-typed record key from aRequestLog
. TheFunction
is allowed to returnnull
to leave the record key unspecified.valueExtractor
- aFunction
that extracts aV
-typed record value from aRequestLog
. TheFunction
is allowed to returnnull
to skip logging for the givenRequestLog
.
-
-
Method Details
-
log
Description copied from interface:AccessLogWriter
Logs the specifiedRequestLog
.- Specified by:
log
in interfaceAccessLogWriter
-
shutdown
Description copied from interface:AccessLogWriter
Shuts down thisAccessLogWriter
.- Specified by:
shutdown
in interfaceAccessLogWriter
- Returns:
- the
CompletableFuture
which is completed when thisAccessLogWriter
has been shut down.
-