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


Java Summary类代码示例

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


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

示例1: ServletHook

import io.prometheus.client.Summary; //导入依赖的package包/类
public ServletHook(MetricsStore metricsStore) {

        httpRequestsTotal = metricsStore.createOrGet(new MetricDef<>(
                "http_requests_total",
                (name, registry) -> Counter.build()
                        .name(name)
                        .labelNames("method", "path", "status")
                        .help("Total number of http requests.")
                        .register(registry)
        ));

        httpRequestsDuration = metricsStore.createOrGet(new MetricDef<>(
                "http_request_duration",
                (name, registry) -> Summary.build()
                        .quantile(0.5, 0.05)   // Add 50th percentile (= median) with 5% tolerated error
                        .quantile(0.9, 0.01)   // Add 90th percentile with 1% tolerated error
                        .quantile(0.99, 0.001) // Add 99th percentile with 0.1% tolerated error
                        .name(name)
                        .labelNames("method", "path", "status")
                        .help("Duration for serving the http requests in seconds.")
                        .register(registry)
        ));
    }
 
开发者ID:fstab,项目名称:promagent,代码行数:24,代码来源:ServletHook.java

示例2: createAssertionCollector

import io.prometheus.client.Summary; //导入依赖的package包/类
protected void createAssertionCollector(){
	if (!collectAssertions){
		return;
	}
	
	String[] labelNames = new String[]{};
	
	if (SampleEvent.getVarCount() > 0) {
		labelNames = this.combineAssertionLabelsWithSampleVars();
	}else {
		labelNames = this.assertionConfig.getLabels();
	}
	
	if(this.getSaveConfig().getAssertionClass().equals(Summary.class))
		this.assertionsCollector = Summary.build().name("jmeter_assertions_total").help("Counter for assertions")
			.labelNames(labelNames).quantile(0.5, 0.1).quantile(0.99, 0.1)
			.create().register(CollectorRegistry.defaultRegistry);
	
	else if(this.getSaveConfig().getAssertionClass().equals(Counter.class))
		this.assertionsCollector = Counter.build().name("jmeter_assertions_total").help("Counter for assertions")
		.labelNames(labelNames).create().register(CollectorRegistry.defaultRegistry);
		
}
 
开发者ID:johrstrom,项目名称:jmeter-prometheus-plugin,代码行数:24,代码来源:PrometheusListener.java

示例3: createSamplerCollector

import io.prometheus.client.Summary; //导入依赖的package包/类
protected void createSamplerCollector(){
	if (collectSamples) {
		String[] labelNames = new String[]{};
		
		if (SampleEvent.getVarCount() > 0) {
			labelNames = this.combineConfigLabelsWithSampleVars();
		}else {
			labelNames = this.samplerConfig.getLabels();
		}
		
		this.samplerCollector = Summary.build()
				.name("jmeter_samples_latency")
				.help("Summary for Sample Latency")
				.labelNames(labelNames)
				.quantile(0.5, 0.1)
				.quantile(0.99, 0.1)
				.create()
				.register(CollectorRegistry.defaultRegistry);
	}
}
 
开发者ID:johrstrom,项目名称:jmeter-prometheus-plugin,代码行数:21,代码来源:PrometheusListener.java

示例4: DimensionStats

import io.prometheus.client.Summary; //导入依赖的package包/类
public DimensionStats(String name, long updateDurationInSec) {
    this.name = name;
    this.dimensionSumLabel = name + "_sum";
    this.dimensionCountLabel = name + "_count";
    Builder summaryBuilder = Summary.build().name(name).help("-");
    for (int i = 0; i < QUANTILES.length; i++) {
        summaryBuilder.quantile(QUANTILES[i], 0.01);
    }
    this.summary = summaryBuilder.maxAgeSeconds(updateDurationInSec).create();
    try {
        defaultRegistry.register(summary);
    } catch (IllegalArgumentException ie) {
        // it only happens in test-cases when try to register summary multiple times in registry
        log.warn("{} is already registred {}", name, ie.getMessage());
    }
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:17,代码来源:DimensionStats.java

示例5: observeStage

import io.prometheus.client.Summary; //导入依赖的package包/类
private void observeStage(Map<String, Summary> histogramMap, Job job, Run build, FlowNode stage) {
    String jobName = job.getName();
    String stageName = stage.getDisplayName();
    String[] labelNameArray = {"job", "stage"};
    String[] labelValueArray = {jobName, stageName};

    String key = jobName + "_" + stageName;
    Summary collector = histogramMap.get(key);
    if (collector == null) {
        collector = Summary.build().name(fullname + "_stage_duration_milliseconds_summary").
                subsystem(subsystem).namespace(namespace).
                        labelNames(labelNameArray).
                help("Summary of Jenkins build times by Job and Stage").
                create();
        histogramMap.put(key, collector);
    }
    long duration = FlowNodes.getStageDuration(stage);
    collector.labels(labelValueArray).observe(duration);
}
 
开发者ID:fabric8io,项目名称:fabric8-jenkins-workflow-steps,代码行数:20,代码来源:JobCollector.java

示例6: timeMethod

import io.prometheus.client.Summary; //导入依赖的package包/类
@Around("timeable()")
public Object timeMethod(ProceedingJoinPoint pjp) throws Throwable {
    String key = pjp.getSignature().toLongString();

    Summary summary;
    final Lock r = summaryLock.readLock();
    r.lock();
    try {
        summary = summaries.get(key);
    } finally {
        r.unlock();
    }

    if (summary == null) {
        summary = ensureSummary(pjp, key);
    }

    final Summary.Timer t = summary.startTimer();

    try {
        return pjp.proceed();
    } finally {
        t.observeDuration();
    }
}
 
开发者ID:prometheus,项目名称:client_java,代码行数:26,代码来源:MethodTimer.java

示例7: testSummaryOutputWithQuantiles

import io.prometheus.client.Summary; //导入依赖的package包/类
@Test
public void testSummaryOutputWithQuantiles() throws IOException {
  Summary labelsAndQuantiles = Summary.build()
          .quantile(0.5, 0.05).quantile(0.9, 0.01).quantile(0.99, 0.001)
          .labelNames("l").name("labelsAndQuantiles").help("help").register(registry);
  labelsAndQuantiles.labels("a").observe(2);
  writer = new StringWriter();
  TextFormat.write004(writer, registry.metricFamilySamples());
  assertEquals("# HELP labelsAndQuantiles help\n"
          + "# TYPE labelsAndQuantiles summary\n"
          + "labelsAndQuantiles{l=\"a\",quantile=\"0.5\",} 2.0\n"
          + "labelsAndQuantiles{l=\"a\",quantile=\"0.9\",} 2.0\n"
          + "labelsAndQuantiles{l=\"a\",quantile=\"0.99\",} 2.0\n"
          + "labelsAndQuantiles_count{l=\"a\",} 1.0\n"
          + "labelsAndQuantiles_sum{l=\"a\",} 2.0\n", writer.toString());
}
 
开发者ID:prometheus,项目名称:client_java,代码行数:17,代码来源:TextFormatTest.java

示例8: JdbcHook

import io.prometheus.client.Summary; //导入依赖的package包/类
public JdbcHook(MetricsStore metricsStore) {

        sqlQueriesTotal = metricsStore.createOrGet(new MetricDef<>(
                "sql_queries_total",
                (name, registry) -> Counter.build()
                        .name(name)
                        .labelNames("method", "path", "query")
                        .help("Total number of sql queries.")
                        .register(registry)
        ));

        sqlQueriesDuration = metricsStore.createOrGet(new MetricDef<>(
                "sql_query_duration",
                (name, registry) -> Summary.build()
                        .quantile(0.5, 0.05)   // Add 50th percentile (= median) with 5% tolerated error
                        .quantile(0.9, 0.01)   // Add 90th percentile with 1% tolerated error
                        .quantile(0.99, 0.001) // Add 99th percentile with 0.1% tolerated error
                        .name(name)
                        .labelNames("method", "path", "query")
                        .help("Duration for serving the sql queries in seconds.")
                        .register(registry)
        ));
    }
 
开发者ID:fstab,项目名称:promagent,代码行数:24,代码来源:JdbcHook.java

示例9: sampleOccurred

import io.prometheus.client.Summary; //导入依赖的package包/类
public void sampleOccurred(SampleEvent event) {

		try {

			// build the label values from the event and observe the sampler
			// metrics
			String[] samplerLabelValues = this.labelValues(event);
			if (collectSamples)
				samplerCollector.labels(samplerLabelValues).observe(event.getResult().getTime());

			if (collectThreads)
				threadCollector.set(JMeterContextService.getContext().getThreadGroup().getNumberOfThreads());

			// if there are any assertions to
			if (collectAssertions) {
				if (event.getResult().getAssertionResults().length > 0) {
					for (AssertionResult assertionResult : event.getResult().getAssertionResults()) {
						String[] assertionsLabelValues = this.labelValues(event, assertionResult);
						
						if(assertionsCollector instanceof Summary)
							((Summary) assertionsCollector).labels(assertionsLabelValues).observe(event.getResult().getTime());
						else if (assertionsCollector instanceof Counter)
							((Counter) assertionsCollector).labels(assertionsLabelValues).inc();
					}
				}
			}

		} catch (Exception e) {
			log.error("Didn't update metric because of exception. Message was: {}", e.getMessage());
		}
	}
 
开发者ID:johrstrom,项目名称:jmeter-prometheus-plugin,代码行数:32,代码来源:PrometheusListener.java

示例10: modifyTestElementForAssertionClass

import io.prometheus.client.Summary; //导入依赖的package包/类
private void modifyTestElementForAssertionClass(PrometheusSaveConfig config){
	int selectedIndex = this.assertionComboBox.getSelectedIndex();
	if(selectedIndex == 0)
		config.setAssertionClass(Counter.class);
	else if(selectedIndex == 1)
		config.setAssertionClass(Summary.class);
}
 
开发者ID:johrstrom,项目名称:jmeter-prometheus-plugin,代码行数:8,代码来源:PrometheusListenerGui.java

示例11: configureAssertionClass

import io.prometheus.client.Summary; //导入依赖的package包/类
private void configureAssertionClass(PrometheusSaveConfig config){
	Class<? extends Collector> assertionClass = config.getAssertionClass();
	String name = "";
	if(assertionClass.equals(Summary.class))
		name = Summary.class.getSimpleName();
	else if(assertionClass.equals(Counter.class))
		name = Counter.class.getSimpleName();
		
	this.assertionComboBox.setSelectedItem(name);
}
 
开发者ID:johrstrom,项目名称:jmeter-prometheus-plugin,代码行数:11,代码来源:PrometheusListenerGui.java

示例12: get

import io.prometheus.client.Summary; //导入依赖的package包/类
@SuppressWarnings("MagicNumber")
public @NotNull Summary.Builder get(@NotNull String name, @NotNull String help) {
  return Summary.build(name, help)
      .quantile(0.5, 0.01)
      .quantile(0.7, 0.01)
      .quantile(0.9, 0.01)
      .quantile(0.99, 0.01);
}
 
开发者ID:nolequen,项目名称:vertx-prometheus-metrics,代码行数:9,代码来源:TimeCounter.java

示例13: run

import io.prometheus.client.Summary; //导入依赖的package包/类
@Override
public void run() {
    synchronized (lock) {
        try {
            File fsImageFile = findLatestFSImageFile(fsImageDir);
            if (config.isSkipPreviouslyParsed() && fsImageFile.equals(lastFsImageFileLoaded)) {
                METRIC_SCRAPE_SKIPS.inc();
                LOGGER.debug("Skipping previously parsed {}", fsImageFile.getAbsoluteFile());
                return;
            }

            // Load new fsimage ...
            METRIC_LOAD_SIZE.set(fsImageFile.length());
            FSImageLoader loader;
            try (RandomAccessFile raFile = new RandomAccessFile(fsImageFile, "r")) {
                long time = System.currentTimeMillis();
                try (Summary.Timer timer = METRIC_LOAD_DURATION.startTimer()) {
                    loader = FSImageLoader.load(raFile);
                }
                if(LOGGER.isInfoEnabled()) {
                    LOGGER.info("Loaded {} with {}MiB in {}ms", fsImageFile.getAbsoluteFile(),
                            String.format("%.1f", fsImageFile.length() / 1024.0 / 1024.0),
                            System.currentTimeMillis() - time);
                }
            }
            lastFsImageFileLoaded = fsImageFile;

            // ... compute stats
            try (Summary.Timer timer = METRIC_VISIT_DURATION.startTimer()) {
                report = FsImageReporter.computeStatsReport(loader, config);
            }
        } catch (Exception e) {
            LOGGER.error("Can not preload FSImage", e);
            report.error = true;
        }
    }
}
 
开发者ID:marcelmay,项目名称:hadoop-hdfs-fsimage-exporter,代码行数:38,代码来源:FsImageWatcher.java

示例14: testSummaryOutput

import io.prometheus.client.Summary; //导入依赖的package包/类
@Test
public void testSummaryOutput() throws IOException {
  Summary noLabels = Summary.build().name("nolabels").help("help").register(registry);
  noLabels.observe(2);
  TextFormat.write004(writer, registry.metricFamilySamples());
  assertEquals("# HELP nolabels help\n"
               + "# TYPE nolabels summary\n"
               + "nolabels_count 1.0\n"
               + "nolabels_sum 2.0\n", writer.toString());
}
 
开发者ID:prometheus,项目名称:client_java,代码行数:11,代码来源:TextFormatTest.java

示例15: SummaryMetricAdapter

import io.prometheus.client.Summary; //导入依赖的package包/类
SummaryMetricAdapter(Summary.Child child) {
    this.child = child;
}
 
开发者ID:marcelmay,项目名称:hadoop-hdfs-fsimage-exporter,代码行数:4,代码来源:FsImageReporter.java


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