OK, so I had to create EventPostProcessor and remove the standard field I was interested in... I hope this was the correct way of doing it!
@Configuration
public class HoneycombConfig {
@Bean
public EventPostProcessor honeycombEventPostProcessor(HoneycombDependencyConfig honeycombDependencyConfig) {
return new ApplicationHoneycombEventPostProcessor(honeycombDependencyConfig.getExcludeFields());
}
static class ApplicationHoneycombEventPostProcessor implements EventPostProcessor {
private final List<String> excludeFields;
public ApplicationHoneycombEventPostProcessor(List<String> excludeFields) {
this.excludeFields = excludeFields;
}
@Override
public void process(EventData<?> eventData) {
//over write field
this.excludeFields
.stream()
.filter(field -> eventData.getFields().containsKey(field))
.forEach(field -> eventData.getFields().remove(field));
}
}
}
@Configuration
@ConfigurationProperties(prefix = "dependencies.honeycomb")
public class HoneycombDependencyConfig {
private List<String> excludeFields;
public List<String> getExcludeFields() {
if(this.excludeFields == null) {
this.excludeFields = new ArrayList<>();
}
return excludeFields;
}
public void setExcludeFields(List<String> excludeFields) {
this.excludeFields = excludeFields;
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…