com.yammer.metrics.Metrics.newHistogram()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(16.2k)|赞(0)|评价(0)|浏览(101)

本文整理了Java中com.yammer.metrics.Metrics.newHistogram()方法的一些代码示例,展示了Metrics.newHistogram()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Metrics.newHistogram()方法的具体详情如下:
包路径:com.yammer.metrics.Metrics
类名称:Metrics
方法名:newHistogram

Metrics.newHistogram介绍

[英]Creates a new non-biased com.yammer.metrics.core.Histogram and registers it under the given metric name.
[中]创建一个新的无偏见com。亚默。韵律学。果心直方图,并将其注册到给定的度量名称下。

代码示例

代码示例来源:origin: apache/incubator-pinot

/**
 *
 * Return an existing histogram if
 *  (a) A histogram already exist with the same metric name.
 * Otherwise, creates a new meter and registers
 *
 * @param registry MetricsRegistry
 * @param name metric name
 * @param biased (true if uniform distribution, otherwise exponential weighted)
 * @return histogram
 */
public static Histogram newHistogram(MetricsRegistry registry, MetricName name, boolean biased) {
 if (registry != null) {
  return registry.newHistogram(name, biased);
 } else {
  return Metrics.newHistogram(name, biased);
 }
}

代码示例来源:origin: com.yammer.metrics/metrics-core

/**
 * Creates a new non-biased {@link com.yammer.metrics.core.Histogram} and registers it under the
 * given metric name.
 *
 * @param metricName the name of the metric
 * @return a new {@link com.yammer.metrics.core.Histogram}
 */
public static Histogram newHistogram(MetricName metricName) {
  return newHistogram(metricName, false);
}

代码示例来源:origin: co.paralleluniverse/quasar

public MetricsForkJoinPoolMonitor(String name, ForkJoinPool fjPool, Map<?, Integer> highContentionObjects) {
  super(name, fjPool, highContentionObjects);
  
  this.runsPerTask = Metrics.newHistogram(MetricsForkJoinPoolMonitor.class, "runsPerTask", name, true);
}

代码示例来源:origin: com.wavefront/proxy

public PointHandlerImpl(final String handle,
            final String validationLevel,
            final int blockedPointsPerBatch,
            @Nullable final String prefix,
            final PostPushDataTimedTask[] sendDataTasks) {
 this.validationLevel = validationLevel;
 this.handle = handle;
 this.blockedPointsPerBatch = blockedPointsPerBatch;
 this.prefix = prefix;
 String logPointsProperty = System.getProperty("wavefront.proxy.logpoints");
 this.logPointsFlag = logPointsProperty != null && logPointsProperty.equalsIgnoreCase("true");
 String logPointsSampleRateProperty = System.getProperty("wavefront.proxy.logpoints.sample-rate");
 this.logPointsSampleRate = logPointsSampleRateProperty != null &&
   NumberUtils.isNumber(logPointsSampleRateProperty) ? Double.parseDouble(logPointsSampleRateProperty) : 1.0d;
 this.receivedPointLag = Metrics.newHistogram(new MetricName("points." + handle + ".received", "", "lag"));
 this.sendDataTasks = sendDataTasks;
}

代码示例来源:origin: wavefrontHQ/java

public PointHandlerImpl(final String handle,
            final String validationLevel,
            final int blockedPointsPerBatch,
            @Nullable final String prefix,
            final PostPushDataTimedTask[] sendDataTasks) {
 this.validationLevel = validationLevel;
 this.handle = handle;
 this.blockedPointsPerBatch = blockedPointsPerBatch;
 this.prefix = prefix;
 String logPointsProperty = System.getProperty("wavefront.proxy.logpoints");
 this.logPointsFlag = logPointsProperty != null && logPointsProperty.equalsIgnoreCase("true");
 String logPointsSampleRateProperty = System.getProperty("wavefront.proxy.logpoints.sample-rate");
 this.logPointsSampleRate = logPointsSampleRateProperty != null &&
   NumberUtils.isNumber(logPointsSampleRateProperty) ? Double.parseDouble(logPointsSampleRateProperty) : 1.0d;
 this.receivedPointLag = Metrics.newHistogram(new MetricName("points." + handle + ".received", "", "lag"));
 this.sendDataTasks = sendDataTasks;
}

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-server

/**
 * Create a histogram-like interface that will register both a CF, keyspace and global level
 * histogram and forward any updates to both
 */
protected ColumnFamilyHistogram createColumnFamilyHistogram(String name, Histogram keyspaceHistogram) 
{
  Histogram cfHistogram = Metrics.newHistogram(factory.createMetricName(name), true);  
  register(name, cfHistogram);
  return new ColumnFamilyHistogram(cfHistogram, keyspaceHistogram, Metrics.newHistogram(globalNameFactory.createMetricName(name), true));
}

代码示例来源:origin: com.wavefront/proxy

@Override
public void execute(Object callback) {
 parsePostingResponse(service.postPushData(currentAgentId, workUnitId, currentMillis, format, pushData));
 if (timeSpentInQueue == null) {
  timeSpentInQueue = Metrics.newHistogram(new MetricName("buffer", "", "queue-time"));
 }
 // timestamps on PostPushDataResultTask are local system clock, not drift-corrected clock
 timeSpentInQueue.update(System.currentTimeMillis() - currentMillis);
}

代码示例来源:origin: com.wavefront/proxy

@VisibleForTesting
PointHandlerDispatcher(AccumulationCache digests, PointHandler output, TimeProvider clock,
            @Nullable Integer dispatchLimit, @Nullable Utils.Granularity granularity) {
 this.digests = digests;
 this.output = output;
 this.clock = clock;
 this.dispatchLimit = dispatchLimit;
 String metricNamespace = "histogram.accumulator." + Utils.Granularity.granularityToString(granularity);
 this.dispatchCounter = Metrics.newCounter(new MetricName(metricNamespace, "", "dispatched"));
 this.dispatchErrorCounter = Metrics.newCounter(new MetricName(metricNamespace, "", "dispatch_errors"));
 this.accumulatorSize = Metrics.newHistogram(new MetricName(metricNamespace, "", "size"));
 this.dispatchProcessTime = Metrics.newHistogram(new MetricName(metricNamespace, "", "dispatch_process_nanos"));
 this.dispatchLagMillis = Metrics.newHistogram(new MetricName(metricNamespace, "", "dispatch_lag_millis"));
}

代码示例来源:origin: wavefrontHQ/java

@Override
public void execute(Object callback) {
 parsePostingResponse(service.postPushData(currentAgentId, workUnitId, currentMillis, format, pushData));
 if (timeSpentInQueue == null) {
  timeSpentInQueue = Metrics.newHistogram(new MetricName("buffer", "", "queue-time"));
 }
 // timestamps on PostPushDataResultTask are local system clock, not drift-corrected clock
 timeSpentInQueue.update(System.currentTimeMillis() - currentMillis);
}

代码示例来源:origin: wavefrontHQ/java

@VisibleForTesting
PointHandlerDispatcher(AccumulationCache digests, PointHandler output, TimeProvider clock,
            @Nullable Integer dispatchLimit, @Nullable Utils.Granularity granularity) {
 this.digests = digests;
 this.output = output;
 this.clock = clock;
 this.dispatchLimit = dispatchLimit;
 String metricNamespace = "histogram.accumulator." + Utils.Granularity.granularityToString(granularity);
 this.dispatchCounter = Metrics.newCounter(new MetricName(metricNamespace, "", "dispatched"));
 this.dispatchErrorCounter = Metrics.newCounter(new MetricName(metricNamespace, "", "dispatch_errors"));
 this.accumulatorSize = Metrics.newHistogram(new MetricName(metricNamespace, "", "size"));
 this.dispatchProcessTime = Metrics.newHistogram(new MetricName(metricNamespace, "", "dispatch_process_nanos"));
 this.dispatchLagMillis = Metrics.newHistogram(new MetricName(metricNamespace, "", "dispatch_lag_millis"));
}

代码示例来源:origin: com.wavefront/proxy

/**
 * Create new instance.
 *
 * @param handle               handle/port number
 * @param blockedItemsPerBatch controls sample rate of how many blocked points are written into the main log file.
 * @param senderTasks          sender tasks
 */
ReportPointHandlerImpl(final String handle,
            final int blockedItemsPerBatch,
            final Collection<SenderTask> senderTasks) {
 super(ReportableEntityType.POINT, handle, blockedItemsPerBatch, new ReportPointSerializer(), senderTasks);
 String logPointsProperty = System.getProperty("wavefront.proxy.logpoints");
 this.logPointsFlag = logPointsProperty != null && logPointsProperty.equalsIgnoreCase("true");
 String logPointsSampleRateProperty = System.getProperty("wavefront.proxy.logpoints.sample-rate");
 this.logSampleRate = NumberUtils.isNumber(logPointsSampleRateProperty) ?
   Double.parseDouble(logPointsSampleRateProperty) : 1.0d;
 this.receivedPointLag = Metrics.newHistogram(new MetricName("points." + handle + ".received", "", "lag"));
 this.attemptedCounter = Metrics.newCounter(new MetricName("points." + handle, "", "sent"));
 this.queuedCounter = Metrics.newCounter(new MetricName("points." + handle, "", "queued"));
 this.statisticOutputExecutor.scheduleAtFixedRate(this::printStats, 10, 10, TimeUnit.SECONDS);
 this.statisticOutputExecutor.scheduleAtFixedRate(this::printTotal, 1, 1, TimeUnit.MINUTES);
}

代码示例来源:origin: wavefrontHQ/java

@VisibleForTesting
protected DataDogPortUnificationHandler(final String handle,
                    final ReportableEntityHandler<ReportPoint> pointHandler,
                    final boolean processSystemMetrics,
                    final boolean processServiceChecks,
                    @Nullable final HttpClient requestRelayClient,
                    @Nullable final String requestRelayTarget,
                    @Nullable final ReportableEntityPreprocessor preprocessor) {
 super(TokenAuthenticatorBuilder.create().setTokenValidationMethod(TokenValidationMethod.NONE).build(), handle,
   false, true);
 this.pointHandler = pointHandler;
 this.processSystemMetrics = processSystemMetrics;
 this.processServiceChecks = processServiceChecks;
 this.requestRelayClient = requestRelayClient;
 this.requestRelayTarget = requestRelayTarget;
 this.preprocessor = preprocessor;
 this.jsonParser = new ObjectMapper();
 this.httpRequestSize = Metrics.newHistogram(new TaggedMetricName("listeners", "http-requests.payload-points",
   "port", handle));
 Metrics.newGauge(new TaggedMetricName("listeners", "tags-cache-size",
   "port", handle), new Gauge<Long>() {
  @Override
  public Long value() {
   return tagsCache.estimatedSize();
  }
 });
}

代码示例来源:origin: wavefrontHQ/java

/**
 * Create new instance.
 *
 * @param handle               handle/port number
 * @param blockedItemsPerBatch controls sample rate of how many blocked points are written into the main log file.
 * @param senderTasks          sender tasks
 */
ReportPointHandlerImpl(final String handle,
            final int blockedItemsPerBatch,
            final Collection<SenderTask> senderTasks) {
 super(ReportableEntityType.POINT, handle, blockedItemsPerBatch, new ReportPointSerializer(), senderTasks);
 String logPointsProperty = System.getProperty("wavefront.proxy.logpoints");
 this.logPointsFlag = logPointsProperty != null && logPointsProperty.equalsIgnoreCase("true");
 String logPointsSampleRateProperty = System.getProperty("wavefront.proxy.logpoints.sample-rate");
 this.logSampleRate = NumberUtils.isNumber(logPointsSampleRateProperty) ?
   Double.parseDouble(logPointsSampleRateProperty) : 1.0d;
 this.receivedPointLag = Metrics.newHistogram(new MetricName("points." + handle + ".received", "", "lag"));
 this.attemptedCounter = Metrics.newCounter(new MetricName("points." + handle, "", "sent"));
 this.queuedCounter = Metrics.newCounter(new MetricName("points." + handle, "", "queued"));
 this.statisticOutputExecutor.scheduleAtFixedRate(this::printStats, 10, 10, TimeUnit.SECONDS);
 this.statisticOutputExecutor.scheduleAtFixedRate(this::printTotal, 1, 1, TimeUnit.MINUTES);
}

代码示例来源:origin: com.wavefront/proxy

public AccumulationTask(ObjectQueue<List<String>> input,
            AccumulationCache digests,
            Decoder<String> decoder,
            PointHandler blockedPointsHandler,
            Validation.Level validationLevel,
            long ttlMillis,
            @Nullable Utils.Granularity granularity,
            short compression) {
 this.input = input;
 this.digests = digests;
 this.decoder = decoder;
 this.blockedPointsHandler = blockedPointsHandler;
 this.validationLevel = validationLevel;
 this.ttlMillis = ttlMillis;
 this.granularity = granularity == null ? Utils.Granularity.DAY : granularity;
 this.compression = compression;
 String metricNamespace = "histogram.accumulator." + Utils.Granularity.granularityToString(granularity);
 eventCounter = Metrics.newCounter(new MetricName(metricNamespace, "", "sample_added"));
 histogramCounter = Metrics.newCounter(new MetricName(metricNamespace, "", "histogram_added"));
 ignoredCounter = Metrics.newCounter(new MetricName(metricNamespace, "", "ignored"));
 batchProcessTime = Metrics.newHistogram(new MetricName(metricNamespace, "", "batch_process_nanos"));
 histogramBinCount = Metrics.newHistogram(new MetricName(metricNamespace, "", "histogram_bins"));
 histogramSampleCount = Metrics.newHistogram(new MetricName(metricNamespace, "", "histogram_samples"));
}

代码示例来源:origin: wavefrontHQ/java

public FilebeatIngester(LogsIngester logsIngester, Supplier<Long> currentMillis) {
 this.logsIngester = logsIngester;
 this.received = Metrics.newCounter(new MetricName("logsharvesting", "", "filebeat-received"));
 this.malformed = Metrics.newCounter(new MetricName("logsharvesting", "", "filebeat-malformed"));
 this.drift = Metrics.newHistogram(new MetricName("logsharvesting", "", "filebeat-drift"));
 this.currentMillis = currentMillis;
}

代码示例来源:origin: com.wavefront/proxy

public FilebeatIngester(LogsIngester logsIngester, Supplier<Long> currentMillis) {
 this.logsIngester = logsIngester;
 this.received = Metrics.newCounter(new MetricName("logsharvesting", "", "filebeat-received"));
 this.malformed = Metrics.newCounter(new MetricName("logsharvesting", "", "filebeat-malformed"));
 this.drift = Metrics.newHistogram(new MetricName("logsharvesting", "", "filebeat-drift"));
 this.currentMillis = currentMillis;
}

代码示例来源:origin: com.senseidb/sensei-core

IndexingMetrics(int partition) {
  MetricName docsIndexedName = new MetricName(MetricsConstants.Domain, "meter", "docs-indexed",
    "indexer");
  docsIndexedMetric = Metrics.newMeter(docsIndexedName, "indexing", TimeUnit.SECONDS);
  MetricName docsLeftoverName = new MetricName(MetricsConstants.Domain, "meter",
    "docs-leftover", "indexer");
  docsLeftoverMetric = Metrics.newMeter(docsLeftoverName, "indexing", TimeUnit.SECONDS);
  MetricName flushTimeName = new MetricName(MetricsConstants.Domain, "histogram", "flush-time",
    "indexer");
  flushTimeHistogram = Metrics.newHistogram(flushTimeName, false);
 }
}

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-server

public CASClientRequestMetrics(String scope) {
  super(scope);
  contention = Metrics.newHistogram(factory.createMetricName("ContentionHistogram"), true);
  conditionNotMet =  Metrics.newCounter(factory.createMetricName("ConditionNotMet"));
  unfinishedCommit =  Metrics.newCounter(factory.createMetricName("UnfinishedCommit"));
}

代码示例来源:origin: wavefrontHQ/java

/**
 * Create new instance.
 *
 * @param tokenAuthenticator  tokenAuthenticator for incoming requests.
 * @param handle              handle/port number.
 */
public PortUnificationHandler(@Nonnull TokenAuthenticator tokenAuthenticator, @Nullable final String handle,
               boolean plaintextEnabled, boolean httpEnabled) {
 this.tokenAuthenticator = tokenAuthenticator;
 this.handle = firstNonNull(handle, "unknown");
 this.plaintextEnabled = plaintextEnabled;
 this.httpEnabled = httpEnabled;
 this.httpRequestHandleDuration = lazySupplier(() -> Metrics.newHistogram(new TaggedMetricName("listeners",
   "http-requests.duration-nanos", "port", this.handle)));
 this.requestsDiscarded = lazySupplier(() -> Metrics.newCounter(new TaggedMetricName("listeners",
   "http-requests.discarded", "port", this.handle)));
 this.pointsDiscarded = lazySupplier(() -> Metrics.newCounter(new TaggedMetricName("listeners",
   "items-discarded", "port", this.handle)));
}

代码示例来源:origin: com.wavefront/proxy

/**
 * Create new instance.
 *
 * @param tokenAuthenticator  tokenAuthenticator for incoming requests.
 * @param handle              handle/port number.
 */
public PortUnificationHandler(@Nonnull TokenAuthenticator tokenAuthenticator, @Nullable final String handle,
               boolean plaintextEnabled, boolean httpEnabled) {
 this.tokenAuthenticator = tokenAuthenticator;
 this.handle = firstNonNull(handle, "unknown");
 this.plaintextEnabled = plaintextEnabled;
 this.httpEnabled = httpEnabled;
 this.httpRequestHandleDuration = lazySupplier(() -> Metrics.newHistogram(new TaggedMetricName("listeners",
   "http-requests.duration-nanos", "port", this.handle)));
 this.requestsDiscarded = lazySupplier(() -> Metrics.newCounter(new TaggedMetricName("listeners",
   "http-requests.discarded", "port", this.handle)));
 this.pointsDiscarded = lazySupplier(() -> Metrics.newCounter(new TaggedMetricName("listeners",
   "items-discarded", "port", this.handle)));
}

相关文章