io.honeybadger.reporter.dto.Details Maven / Gradle / Ivy
package io.honeybadger.reporter.dto;
import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.honeybadger.reporter.config.ConfigContext;
import org.slf4j.MDC;
import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TreeMap;
/**
* Class representing metadata and run-time state.
* @author Elijah Zupancic
* @since 1.0.9
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Details extends LinkedHashMap>
implements Serializable {
private static final long serialVersionUID = -6238693264237448645L;
private final ConfigContext config;
@JsonCreator
public Details(@JacksonInject("config") final ConfigContext config) {
this.config = config;
}
void addDefaultDetails() {
put("System Properties", systemProperties());
put("MDC Properties", mdcProperties());
}
protected static LinkedHashMap mdcProperties() {
LinkedHashMap map = new LinkedHashMap<>();
@SuppressWarnings("unchecked")
Map mdc = MDC.getCopyOfContextMap();
if (mdc != null) {
for (Map.Entry entry : mdc.entrySet()) {
map.put(entry.getKey(), entry.getValue());
}
}
return map;
}
protected Map systemProperties() {
TreeMap map = new TreeMap<>();
Set excludedSysProps = config.getExcludedSysProps();
for (Map.Entry