Java 类com.codahale.metrics.json.HealthCheckModule 实例源码

项目:eHMP    文件:POMObjectMapper.java   
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);
    }
项目:werval    文件:MetricsPlugin.java   
@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 );
}
项目:monitoring-center    文件:MonitoringCenterServlet.java   
@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);
}
项目:haven-platform    文件:AmqpReporter.java   
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 */));
}
项目:support-core-plugin    文件:MetricsContent.java   
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);
}