Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Am using Honeycomb and Spring Boot.

    <dependency>
        <groupId>io.honeycomb.beeline</groupId>
        <artifactId>beeline-spring-boot-starter</artifactId>
        <version>1.0.2</version>
    </dependency>

Am able to send data to Honeycombe successfully but by default beeline/spring is sending STANDARD fields like "request.path", "request.header....", "request......" etc...

How can I exclude some or all of these standard fields from being recorded/sent to Honeycomb?

Any code/config example would be useful.

question from:https://stackoverflow.com/questions/66055290/honeycomb-spring-boot-2-exclude-standard-fields

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
203 views
Welcome To Ask or Share your Answers For Others

1 Answer

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;
}

}


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...