public POMObjectMapper(JsonFactory fact) { super(fact); this.registerModule(new TolerantHealthTimeModule()); this.registerModule(new MetricsModule(TimeUnit.SECONDS, TimeUnit.MILLISECONDS, false)); this.registerModule(new HealthCheckModule()); // this.registerModule(new ViewDefDefModule()); // the following config could be in its own Jackson Module ("VPRModule") if this list gets unwieldy or we want to // externalize the VPR's JSON serialization configuration more or not have dependencies on 3rd party libs. No need right now, though. this.setSerializationInclusion(JsonInclude.Include.NON_NULL); this.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); this.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); this.addMixInAnnotations(VistaUserDetails.class, VistaUserDetailsJacksonAnnotations.class); this.addMixInAnnotations(UserDetails.class, UserDetailsJacksonAnnotations.class); this.addMixInAnnotations(GrantedAuthority.class, GrantedAuthorityJacksonAnnotations.class); }
@Override public void onActivate( Application application ) throws ActivationException { application.plugin( JSON.class ).mapper() .registerModule( new MetricsModule( SECONDS, MILLISECONDS, true ) ) .registerModule( new HealthCheckModule() ); MetricRegistry metrics = new MetricRegistry(); HealthCheckRegistry healthChecks = new HealthCheckRegistry(); registerMetrics( application, metrics ); registerMetricsReporters( application, metrics ); registerHealthChecks( application, healthChecks ); api = new Metrics( metrics, healthChecks ); }
@Override public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); boolean disableAuthorization = Boolean.TRUE.toString().equalsIgnoreCase(servletConfig.getInitParameter(DISABLE_AUTHORIZATION_INIT_PARAM)); if (!disableAuthorization) { String credentials = null; String username = servletConfig.getInitParameter(USERNAME_INIT_PARAM); String password = servletConfig.getInitParameter(PASSWORD_INIT_PARAM); if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password)) { credentials = username.trim() + ":" + password.trim(); } else { credentials = DEFAULT_CREDENTIALS; } this.encodedCredentials = BaseEncoding.base64().encode(credentials.getBytes()); } this.objectMapper = new ObjectMapper() .registerModule(new MetricsModule(TimeUnit.SECONDS, TimeUnit.MICROSECONDS, false)) .registerModule(new HealthCheckModule()) .setSerializationInclusion(JsonInclude.Include.NON_NULL) .setTimeZone(TimeZone.getDefault()) .setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z")); this.graphiteMetricFormatter = new GraphiteMetricFormatter(TimeUnit.SECONDS, TimeUnit.MICROSECONDS); try { this.threadDumpGenerator = new ThreadDump(ManagementFactory.getThreadMXBean()); } catch (NoClassDefFoundError ignore) { } ServletContext servletContext = servletConfig.getServletContext(); String servletSpecVersion = servletContext.getMajorVersion() + "." + servletContext.getMinorVersion(); this.serverInfo = ServerInfo.create(servletContext.getServerInfo(), servletSpecVersion); }
private AmqpReporter(Builder builder) { super(builder.registry, "amqp-reporter", builder.filter, builder.rateUnit, builder.durationUnit); this.routingKey = builder.routingKey; this.exchangeName = builder.exchangeName; Assert.hasText(this.exchangeName, "exchangeName is null or empty"); this.exchangeFactory = builder.exchangeFactory; this.messagePropertiesCallback = builder.messagePropertiesCallback; this.connectionFactoryProvider = builder.connectionFactoryProvider; Assert.notNull(this.connectionFactoryProvider, "connectionFactoryProvider can't be null"); objectMapper.registerModules(new HealthCheckModule(), new MetricsModule(builder.rateUnit, builder.durationUnit, false /* if enable histogram data will be serialized */)); }
public MetricsContent(String name, MetricRegistry metricsRegistry) { super(name); this.registry = metricsRegistry; objectMapper = new ObjectMapper(); objectMapper.registerModule(new MetricsModule(TimeUnit.MINUTES, TimeUnit.SECONDS, true)); objectMapper.registerModule(new HealthCheckModule()); objectMapper.enable(SerializationFeature.INDENT_OUTPUT); }