private Metric.Context getChainMetricContext(String chainName) { Metric.Context context = chainContexts.get(chainName); if (context == null) { Map<String, String> dimensions = new HashMap<>(); dimensions.put("chain", chainName); context = this.metric.createContext(dimensions); chainContexts.put(chainName, context); } return context; }
private void addResponseMetrics(HttpResponseStatisticsCollector statisticsCollector) { Map<String, Map<String, Long>> statistics = statisticsCollector.takeStatisticsByMethod(); statistics.forEach((httpMethod, statsByResponseType) -> { Map<String, Object> dimensions = new HashMap<>(); dimensions.put(Metrics.METHOD_DIMENSION, httpMethod); Context ctx = metric.createContext(dimensions); statsByResponseType.forEach((group, value) -> metric.add(group, value, ctx)); }); }
@Override public void emitMetrics(Metric metric) { int numStaleContainers; synchronized (monitor) { numStaleContainers = this.numStaleContainers; } metric.set(TOTAL_DEACTIVATED_CONTAINERS, numStaleContainers, null); }
private void increment(String metricName, long countIncrement) { if (countIncrement > 0) { metric.add(metricName, countIncrement, null); } } }
public void emitMetrics(Metric metric) { Instant now = clock.instant(); collectGcStatistics(now); cleanStatistics(now); for (Map.Entry<String, LinkedList<GcStats>> item : gcStatistics.entrySet()) { GcStats reference = item.getValue().getFirst(); GcStats latest = item.getValue().getLast(); Map<String, String> contextData = new HashMap<>(); contextData.put(DIMENSION_KEY, item.getKey()); Metric.Context gcContext = metric.createContext(contextData); metric.set(GC_COUNT, latest.count - reference.count, gcContext); metric.set(GC_TIME, latest.totalRuntime.minus(reference.totalRuntime).toMillis(), gcContext); } }
public void contentSize(int size) { metric.set(Metrics.CONTENT_SIZE, size, context); } }
public void failedWrite() { metric.add(Metrics.NUM_FAILED_WRITES, 1, context); }
private ExecutorServiceWrapper(WorkerCompletionTimingThreadPoolExecutor wrapped, Metric metric, ProcessTerminator processTerminator, long maxThreadExecutionTimeMillis) { this.wrapped = wrapped; this.metric = metric; this.processTerminator = processTerminator; this.maxThreadExecutionTimeMillis = maxThreadExecutionTimeMillis; metric.set(MetricNames.THREAD_POOL_SIZE, wrapped.getPoolSize(), null); metric.set(MetricNames.ACTIVE_THREADS, wrapped.getActiveCount(), null); metric.add(MetricNames.REJECTED_REQUEST, 0, null); metricReporter = new Thread(this::reportMetrics); metricReporter.setDaemon(true); metricReporter.start(); }
public void successfulRead(int bytes_received) { metric.set(JettyHttpServer.Metrics.NUM_BYTES_RECEIVED, bytes_received, context); }
public void prematurelyClosed() { metric.add(Metrics.NUM_PREMATURELY_CLOSED_CONNECTIONS, 1, context); }
private Metric.Context getDimensions(String source) { Metric.Context context = statePageOnlyContexts.get(source == null ? "" : source); if (context == null) { Map<String, String> dims = new HashMap<>(); if (source != null) { dims.put("source", source); } context = this.metric.createContext(dims); statePageOnlyContexts.put(source == null ? "" : source, context); } // TODO add other relevant metric dimensions // Would be nice to have chain as a dimension as // we can separate errors from different chains return context; }
public void uriLength(int length) { metric.set(Metrics.URI_LENGTH, length, context); }
private Metric.Context getContextAt(String... point) { if (point.length % 2 != 0) { throw new IllegalArgumentException("Dimension specification comes in pairs"); } Map<String, String> dimensions = new HashMap<>(); for (int i = 0; i < point.length; i += 2) { dimensions.put(point[i], point[i + 1]); } Metric.Context context = contextMap.get(dimensions); if (context != null) { return context; } context = metric.createContext(dimensions); contextMap.put(dimensions, context); return context; }
private void updateMaintenanceMetrics() { metric.set("hostedVespa.pendingRedeployments", pendingRedeploymentsSupplier.get(), null); }
private void incrQueryCount(Metric.Context metricContext) { //myStats.incrQueryCnt(); queries.increment(); metric.add(QUERIES_METRIC, 1, metricContext); }
public Metric.Context getRequestMetricContext(HttpServletRequest request) { String method = request.getMethod(); return requestMetricContextCache.computeIfAbsent(method, ignored -> { Map<String, Object> dimensions = createConnectorDimensions(listenPort, connectorName); dimensions.put(JettyHttpServer.Metrics.METHOD_DIMENSION, method); return metric.createContext(dimensions); }); }