line/armeria

Add `KafkaLogWriter`

开放

#4,958 创建于 2023年6月15日

 (8 条评论) (0 个反应) (0 位负责人)Java (863 个派生)batch import
good first issuenew feature

仓库指标

星标
 (4,552 个星标)
PR 合并指标
 (平均合并 5天 12小时) (30 天内合并 42 个 PR)

描述

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) {
        ...
    }
}

贡献者指南