Java Code Examples for io.prometheus.client.Gauge#Timer

The following examples show how to use io.prometheus.client.Gauge#Timer . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TxleMetrics.java    From txle with Apache License 2.0 6 votes vote down vote up
public void endMarkTxDuration(TxEvent event) {
    if (!isEnableMonitor(event)) {
        return;
    }
    String globalOrLocalTxId = "";
    if (SagaEndedEvent.name().equals(event.type())) {
        globalOrLocalTxId = event.globalTxId();
    } else if (TxEndedEvent.name().equals(event.type())) {
        globalOrLocalTxId = event.localTxId();
    }
    Gauge.Timer gaugeTimerOfTxId = txIdAndGaugeTimer.get(globalOrLocalTxId);
    if (gaugeTimerOfTxId != null) {
        gaugeTimerOfTxId.setDuration();
        txIdAndGaugeTimer.remove(globalOrLocalTxId);
        if (txIdAndGaugeTimer.isEmpty()) {
            txIdAndGaugeTimer.clear();
        }
    }
}
 
Example 2
Source File: FsImageCollector.java    From hadoop-hdfs-fsimage-exporter with Apache License 2.0 6 votes vote down vote up
public List<MetricFamilySamples> collect() {
    List<MetricFamilySamples> mfs = new ArrayList<>();

    try (Gauge.Timer timer = scrapeDuration.startTimer()) {
        scapeRequests.inc();

        if (fsImageReportUpdater.collectFsImageSamples(mfs)) {
            scrapeErrors.inc();
        }
    } catch (Exception e) {
        scrapeErrors.inc();
        LOGGER.error("FSImage scrape failed", e);
    }

    mfs.addAll(scrapeDuration.collect());
    mfs.addAll(scapeRequests.collect());
    mfs.addAll(scrapeErrors.collect());

    return mfs;
}
 
Example 3
Source File: CommonPrometheusMetrics.java    From txle with Apache License 2.0 5 votes vote down vote up
public void endMarkSQLDuration() {
    Gauge.Timer timer = GAUGE_TIMER.get();
    if (timer != null) {
        timer.setDuration();
    }
    GAUGE_TIMER.remove();
}
 
Example 4
Source File: TxleMetrics.java    From txle with Apache License 2.0 5 votes vote down vote up
public void endMarkSQLDuration(String globalTxId) {
    if (!isEnableMonitorServer) {
        return;
    }
    Gauge.Timer timer = gaugeTimer.get();
    if (timer != null) {
        timer.setDuration();
    }
    gaugeTimer.remove();
    CurrentThreadContext.clearCache(globalTxId);
}