当前位置: 首页>>代码示例>>Java>>正文


Java MetricsModule类代码示例

本文整理汇总了Java中com.codahale.metrics.json.MetricsModule的典型用法代码示例。如果您正苦于以下问题:Java MetricsModule类的具体用法?Java MetricsModule怎么用?Java MetricsModule使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MetricsModule类属于com.codahale.metrics.json包,在下文中一共展示了MetricsModule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: KafkaReporter

import com.codahale.metrics.json.MetricsModule; //导入依赖的package包/类
private KafkaReporter(MetricRegistry registry, String name,
		TimeUnit rateUnit, TimeUnit durationUnit, boolean showSamples, MetricFilter filter,
		String topic, ProducerConfig config, String prefix,
		String hostName, String ip) {
	super(registry, name, filter, rateUnit, durationUnit);
	this.topic = topic;
	this.config = config;
	this.prefix = prefix;
	this.hostName = hostName;
	this.ip = ip;
	
	this.mapper = new ObjectMapper().registerModule(new MetricsModule(rateUnit,
               durationUnit,
               showSamples));

	producer = new Producer<String, String>(config);

	kafkaExecutor = Executors
			.newSingleThreadExecutor(new ThreadFactoryBuilder()
					.setNameFormat("kafka-producer-%d").build());
}
 
开发者ID:hengyunabc,项目名称:metrics-kafka,代码行数:22,代码来源:KafkaReporter.java

示例2: POMObjectMapper

import com.codahale.metrics.json.MetricsModule; //导入依赖的package包/类
public POMObjectMapper(JsonFactory fact) {
        super(fact);

        this.registerModule(new TolerantHealthTimeModule());


        this.registerModule(new MetricsModule(TimeUnit.SECONDS, TimeUnit.MILLISECONDS, false));
        //ASU CHANGE 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);
        */
    }
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:23,代码来源:POMObjectMapper.java

示例3: POMObjectMapper

import com.codahale.metrics.json.MetricsModule; //导入依赖的package包/类
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);
    }
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:18,代码来源:POMObjectMapper.java

示例4: POMXmlMapper

import com.codahale.metrics.json.MetricsModule; //导入依赖的package包/类
public POMXmlMapper() {
        JacksonXmlModule xmlModule = new JacksonXmlModule();
        xmlModule.setDefaultUseWrapper(false);

        registerModule(xmlModule);
//        registerModule(new JaxbAnnotationModule());
        registerModule(new HealthTimeModule());
        registerModule(new MetricsModule(TimeUnit.SECONDS, TimeUnit.MILLISECONDS, false));

        configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
        configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, false);
        setSerializationInclusion(JsonInclude.Include.NON_NULL);

//        setAnnotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()));

        addMixInAnnotations(IPOMObject.class, POMObjectJacksonXmlAnnotations.class);
    }
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:18,代码来源:POMXmlMapper.java

示例5: KafkaReporter

import com.codahale.metrics.json.MetricsModule; //导入依赖的package包/类
private KafkaReporter(MetricRegistry registry,
                      String name,
                      MetricFilter filter,
                      TimeUnit rateUnit,
                      TimeUnit durationUnit,
                      String kafkaTopic,
                      Properties kafkaProperties) {
    super(registry, name, filter, rateUnit, durationUnit);
    this.registry = registry;
    this.converter = new JsonToAvroConverter();
    mapper = new ObjectMapper().registerModule(new MetricsModule(rateUnit,
                                                                 durationUnit,
                                                                 false));
    this.kafkaTopic = kafkaTopic;
    kafkaProducer = new KafkaProducer<String, IndexedRecord>(kafkaProperties);
}
 
开发者ID:elodina,项目名称:java-kafka,代码行数:17,代码来源:KafkaReporter.java

示例6: onActivate

import com.codahale.metrics.json.MetricsModule; //导入依赖的package包/类
@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 );
}
 
开发者ID:werval,项目名称:werval,代码行数:17,代码来源:MetricsPlugin.java

示例7: serveAdmin

import com.codahale.metrics.json.MetricsModule; //导入依赖的package包/类
public void serveAdmin() {
  MetricsModule metricsModule = new MetricsModule(TimeUnit.SECONDS, TimeUnit.MILLISECONDS, true);
  ObjectMapper metricsMapper = new ObjectMapper().registerModule(metricsModule);
  ObjectMapper healthMapper = new ObjectMapper();

  /*
  '/info' -> should expose version number, git commit number, etc
  '/metrics' -> should return the metrics reporters in JSON format
  '/health' -> should expose a summary of downstream health checks
  '/ping' -> should respond with a 200-OK status code and the text 'PONG'
  '/ready' -> should expose a Kubernetes or ELB specific healthcheck for liveliness
  '/restart' -> restart service (should be restricted to approved devs / tooling)
   '/killkillkill' -> shutdown service (should be restricted to approved devs / tooling)```
   */

  addRoute("/info", AdminHandlers.infoHandler(), HttpMethod.GET);
  addRoute(
      "/metrics", AdminHandlers.metricsHandler(metricRegistry, metricsMapper), HttpMethod.GET);
  addRoute(
      "/health",
      AdminHandlers.healthCheckHandler(healthCheckRegistry, healthMapper),
      HttpMethod.GET);
  addRoute("/ping", AdminHandlers.pingHandler(), HttpMethod.GET);
  addRoute("/ready", AdminHandlers.readyHandler(), HttpMethod.GET);
  addRoute("/restart", AdminHandlers.restartHandler(this), HttpMethod.GET);
  addRoute("/killkillkill", AdminHandlers.killHandler(this), HttpMethod.GET);

  addRoute("/gc", AdminHandlers.pingHandler(), HttpMethod.GET);
}
 
开发者ID:Nordstrom,项目名称:xrpc,代码行数:30,代码来源:Router.java

示例8: execute

import com.codahale.metrics.json.MetricsModule; //导入依赖的package包/类
@Override
protected void execute() {
    IntentMetricsService service = get(IntentMetricsService.class);

    if (outputJson()) {
        ObjectMapper mapper = new ObjectMapper()
            .registerModule(new MetricsModule(TimeUnit.SECONDS,
                                              TimeUnit.MILLISECONDS,
                                              false));
        ObjectNode result = mapper.createObjectNode();
        result = json(mapper, result, "intentSubmitted",
                      service.intentSubmittedEventMetric());
        result = json(mapper, result, "intentInstalled",
                      service.intentInstalledEventMetric());
        result = json(mapper, result, "intentFailed",
                      service.intentFailedEventMetric());
        result = json(mapper, result, "intentWithdrawRequested",
                      service.intentWithdrawRequestedEventMetric());
        result = json(mapper, result, "intentWithdrawn",
                      service.intentWithdrawnEventMetric());
        result = json(mapper, result, "intentPurged",
                      service.intentPurgedEventMetric());
        print("%s", result);
    } else {
        printEventMetric("Submitted",
                         service.intentSubmittedEventMetric());
        printEventMetric("Installed",
                         service.intentInstalledEventMetric());
        printEventMetric("Failed",
                         service.intentFailedEventMetric());
        printEventMetric("Withdraw Requested",
                         service.intentWithdrawRequestedEventMetric());
        printEventMetric("Withdrawn",
                         service.intentWithdrawnEventMetric());
        printEventMetric("Purged",
                         service.intentPurgedEventMetric());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:39,代码来源:IntentEventsMetricsCommand.java

示例9: execute

import com.codahale.metrics.json.MetricsModule; //导入依赖的package包/类
@Override
protected void execute() {
    TopologyMetricsService service = get(TopologyMetricsService.class);

    if (outputJson()) {
        ObjectMapper mapper = new ObjectMapper()
            .registerModule(new MetricsModule(TimeUnit.SECONDS,
                                              TimeUnit.MILLISECONDS,
                                              false));
        ObjectNode result = mapper.createObjectNode();
        result = json(mapper, result, "topologyDeviceEvent",
                      service.topologyDeviceEventMetric());
        result = json(mapper, result, "topologyHostEvent",
                      service.topologyHostEventMetric());
        result = json(mapper, result, "topologyLinkEvent",
                      service.topologyLinkEventMetric());
        result = json(mapper, result, "topologyGraphEvent",
                      service.topologyGraphEventMetric());
        result = json(mapper, result, "topologyGraphReasonsEvent",
                      service.topologyGraphReasonsEventMetric());
        print("%s", result);
    } else {
        printEventMetric("Device", service.topologyDeviceEventMetric());
        printEventMetric("Host", service.topologyHostEventMetric());
        printEventMetric("Link", service.topologyLinkEventMetric());
        printEventMetric("Graph", service.topologyGraphEventMetric());
        printEventMetric("Graph Reasons",
                         service.topologyGraphReasonsEventMetric());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:31,代码来源:TopologyEventsMetricsCommand.java

示例10: getApplictionMetrics

import com.codahale.metrics.json.MetricsModule; //导入依赖的package包/类
private String getApplictionMetrics() throws JsonProcessingException {
	ObjectMapper mapper = new ObjectMapper();
	mapper.registerModule(
			new MetricsModule(
					TimeUnit.SECONDS,
					TimeUnit.MILLISECONDS,
					false));
	return mapper.writeValueAsString(metricRegistry);
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:10,代码来源:AdminServiceImpl.java

示例11: SystemController

import com.codahale.metrics.json.MetricsModule; //导入依赖的package包/类
public SystemController(Service spark, GraknConfig config, SystemKeyspace systemKeyspace,
                        GraknEngineStatus graknEngineStatus, MetricRegistry metricRegistry) {
    this.systemKeyspace = systemKeyspace;
    this.config = config;

    this.graknEngineStatus = graknEngineStatus;
    this.metricRegistry = metricRegistry;
    DropwizardExports prometheusMetricWrapper = new DropwizardExports(metricRegistry);
    this.prometheusRegistry = new CollectorRegistry();
    prometheusRegistry.register(prometheusMetricWrapper);

    spark.get(REST.WebPath.ROOT, this::getRoot);

    spark.get(REST.WebPath.KB, (req, res) -> getKeyspaces(res));
    spark.get(REST.WebPath.KB_KEYSPACE, this::getKeyspace);
    spark.put(REST.WebPath.KB_KEYSPACE, this::putKeyspace);
    spark.delete(REST.WebPath.KB_KEYSPACE, this::deleteKeyspace);
    spark.get(REST.WebPath.METRICS, this::getMetrics);
    spark.get(REST.WebPath.STATUS, (req, res) -> getStatus());
    spark.get(REST.WebPath.VERSION, (req, res) -> getVersion());

    final TimeUnit rateUnit = TimeUnit.SECONDS;
    final TimeUnit durationUnit = TimeUnit.SECONDS;
    final boolean showSamples = false;
    MetricFilter filter = MetricFilter.ALL;

    this.mapper = new ObjectMapper().registerModule(
            new MetricsModule(rateUnit,
                    durationUnit,
                    showSamples,
                    filter));
}
 
开发者ID:graknlabs,项目名称:grakn,代码行数:33,代码来源:SystemController.java

示例12: init

import com.codahale.metrics.json.MetricsModule; //导入依赖的package包/类
@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);
}
 
开发者ID:centro,项目名称:monitoring-center,代码行数:38,代码来源:MonitoringCenterServlet.java

示例13: AmqpReporter

import com.codahale.metrics.json.MetricsModule; //导入依赖的package包/类
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 */));
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:16,代码来源:AmqpReporter.java

示例14: doStart

import com.codahale.metrics.json.MetricsModule; //导入依赖的package包/类
@Override
protected void doStart() throws Exception {
    if (metricsRegistry == null) {
        Registry camelRegistry = getCamelContext().getRegistry();
        metricsRegistry = camelRegistry.lookupByNameAndType(MetricsComponent.METRIC_REGISTRY_NAME, MetricRegistry.class);
        // create a new metricsRegistry by default
        if (metricsRegistry == null) {
            metricsRegistry = new MetricRegistry();
        }
    }

    if (useJmx) {
        ManagementAgent agent = getCamelContext().getManagementStrategy().getManagementAgent();
        if (agent != null) {
            MBeanServer server = agent.getMBeanServer();
            if (server != null) {
                reporter = JmxReporter.forRegistry(metricsRegistry).registerWith(server).inDomain(jmxDomain).build();
                reporter.start();
            }
        } else {
            throw new IllegalStateException("CamelContext has not enabled JMX");
        }
    }

    // json mapper
    this.mapper = new ObjectMapper().registerModule(new MetricsModule(getRateUnit(), getDurationUnit(), false));
    if (getRateUnit() == TimeUnit.SECONDS && getDurationUnit() == TimeUnit.SECONDS) {
        // they both use same units so reuse
        this.secondsMapper = this.mapper;
    } else {
        this.secondsMapper = new ObjectMapper().registerModule(new MetricsModule(TimeUnit.SECONDS, TimeUnit.SECONDS, false));
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:34,代码来源:MetricsMessageHistoryService.java

示例15: MetricsServlet

import com.codahale.metrics.json.MetricsModule; //导入依赖的package包/类
/**
 * New instance, which will report on the supplied metrics.
 *
 * @param registry
 *            the metrics registry to provide metrics from
 */
public MetricsServlet(MetricRegistry registry) {
	super(LOGGER, MetricsServlet.class);
	this.registry = registry;

	getMapper().registerModule(new MetricsModule(TimeUnit.SECONDS, TimeUnit.SECONDS, false));
}
 
开发者ID:dstl,项目名称:baleen,代码行数:13,代码来源:MetricsServlet.java


注:本文中的com.codahale.metrics.json.MetricsModule类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。