line/armeria

Add `KafkaLogWriter`

オープン

#4,958 opened on 2023/06/15

 (8 件のコメント) (0 件のリアクション) (0 人の担当者)Java (863 件のフォーク)batch import
good first issuenew feature

Repository metrics

Stars
 (4,552 個のスター)
PR merge metrics
 (平均マージ 5d 12h) (30d で 42 merged PRs)

説明

The default LogWriter uses SLFJ4 to write serialized RequestLogs. In the cloud environment, it would be better to send logs to the remote message queue directly rather than write logs to the local filesystem.

Like KafkaAccessLogWriter, KafkaLogWriter can be added to the armeria-kafka module. https://github.com/line/armeria/blob/d8a744b467271efb4a617584f5d70d8ac140f7f5/kafka/src/main/java/com/linecorp/armeria/server/logging/kafka/KafkaAccessLogWriter.java#L41-L41

public final class KafkaLogWriter implements LogWriter {
    @Override
    public void logRequest(RequestOnlyLog log) {
        // use LogFormatter.ofJson() to convert the log to a JSON object
    }

    @Override
    public void logResponse(RequestLog log) {
        ...
    }
}

コントリビューターガイド