In ContentSanitizer, Thrift messages are currently masked and serialized in the Thrift TJSON protocol format.
|
tMaskingSerializer = new TMaskingSerializer(ThriftProtocolFactories.json(), selectorCache); |
However, since TJSON includes only field IDs, it significantly reduces human readability.
content={"service":"...","method":"hello","params":[{"2":{"str":""},"13":{"i32":0}}]}}
There may be a need to log messages in a more human-readable format, such as the Thrift TText protocol or TText with named enums. To support this, I propose providing a builder for ThriftFieldMaskerSelectorProvider and allowing it to be set in the ContentSanitizerBuilder.
var maskerSelectorProvider =
ThriftFieldMaskerSelectorProvider
.builder()
.tProtocolFactory(ThriftProtocolFactories.text())
// This method is mutually exclusive with tProtocolFactory()
.serializer(...)
.deserializers(...)
.build();
ContentSanitizer
.builder()
.fieldMaskerSelectorProvider(maskerSelectorProvider)
Additionally, I suggest removing useDefaultPrettyPrinter() option for TText protocol. This change would help reduce network and log payload size and improve consistency with the other log message formats, which use a single-line format.
|
generator = OBJECT_MAPPER.getFactory().createGenerator(baos, JsonEncoding.UTF8) |
|
.useDefaultPrettyPrinter(); |
In
ContentSanitizer, Thrift messages are currently masked and serialized in the Thrift TJSON protocol format.armeria/thrift/thrift0.13/src/main/java/com/linecorp/armeria/internal/common/thrift/logging/TBaseSerializer.java
Line 36 in 883e8bf
However, since TJSON includes only field IDs, it significantly reduces human readability.
There may be a need to log messages in a more human-readable format, such as the Thrift TText protocol or TText with named enums. To support this, I propose providing a builder for
ThriftFieldMaskerSelectorProviderand allowing it to be set in theContentSanitizerBuilder.Additionally, I suggest removing
useDefaultPrettyPrinter()option for TText protocol. This change would help reduce network and log payload size and improve consistency with the other log message formats, which use a single-line format.armeria/thrift/thrift0.13/src/main/java/com/linecorp/armeria/common/thrift/text/TTextProtocol.java
Lines 834 to 835 in 0960d09