Skip to content

Allow customizing ThriftFieldMaskerSelectorProvider #6343

Description

@ikhoon

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();

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions