private void increment(String metricName, long countIncrement) { if (countIncrement > 0) { metric.add(metricName, countIncrement, null); } } }
public void prematurelyClosed() { metric.add(Metrics.NUM_PREMATURELY_CLOSED_CONNECTIONS, 1, context); }
public void failedWrite() { metric.add(Metrics.NUM_FAILED_WRITES, 1, context); }
private void incrQueryCount(Metric.Context metricContext) { //myStats.incrQueryCnt(); queries.increment(); metric.add(QUERIES_METRIC, 1, metricContext); }
private void incrementDocs(long increment) { docCounter.increment(increment); metric.add(docCounterName, increment, null); }
private void incrementProcTime(long increment) { procTimeCounter.increment(increment); metric.add(procTimeCounterName, increment, null); }
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 to set connector attribute before the request becomes an upgrade request in the web socket case. * (After the upgrade, the HttpConnection is no longer available.) */ @Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setAttribute(JDiscServerConnector.REQUEST_ATTRIBUTE, getConnector(request)); Metric.Context metricContext = getMetricContext(request); context.metric.add(JettyHttpServer.Metrics.NUM_REQUESTS, 1, metricContext); context.metric.add(JettyHttpServer.Metrics.JDISC_HTTP_REQUESTS, 1, metricContext); if (JETTY_UNSUPPORTED_METHODS.contains(request.getMethod().toUpperCase())) { dispatchHttpRequest(request, response); } else { super.service(request, response); } }
static DocumentOperationMessageV3 create(VespaXMLFeedReader.Operation operation, String operationId, Metric metric) { switch (operation.getType()) { case DOCUMENT: metric.add(MetricNames.NUM_PUTS, 1, null /*metricContext*/); return newPutMessage(operation, operationId); case REMOVE: metric.add(MetricNames.NUM_REMOVES, 1, null /*metricContext*/); return newRemoveMessage(operation, operationId); case UPDATE: metric.add(MetricNames.NUM_UPDATES, 1, null /*metricContext*/); return newUpdateMessage(operation, operationId); default: // typical end of feed return null; } }
public void successfulWrite(int numBytes) { setTimeToFirstByteFirstTime(); metric.add(Metrics.NUM_SUCCESSFUL_WRITES, 1, context); metric.set(Metrics.NUM_BYTES_SENT, numBytes, context); }
@Override public HttpResponse handle(HttpRequest request) { if (metric != null) metric.add(NUM_REQUESTS_METRIC, 1, null); if (vipStatus != null) updateAndLogRotationState(); return new StatusResponse(); }
/** * Tracks all instances of RejectedExecutionException. * ThreadPoolProvider returns an executor, so external uses will not * have access to the methods declared by ExecutorService. * (execute(Runnable) is declared by Executor.) */ @Override public void execute(Runnable command) { try { super.execute(command); } catch (RejectedExecutionException e) { metric.add(MetricNames.REJECTED_REQUEST, 1, null); long timeSinceLastReturnedThreadMillis = System.currentTimeMillis() - wrapped.lastThreadAssignmentTimeMillis; if (timeSinceLastReturnedThreadMillis > maxThreadExecutionTimeMillis) processTerminator.logAndDie("No worker threads have been available for " + timeSinceLastReturnedThreadMillis + " ms. Shutting down.", true); throw e; } }
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(); }
private ContentChannel handleResponse() { try { if (httpResponse == null) throw new NullPointerException("Writing to a lazy content channel without calling setHttpResponse first"); httpResponse.complete(); return responseHandler.handleResponse(httpResponse.getJdiscResponse()); } catch (Exception e) { metric.add(RENDERING_ERRORS, 1, null); if (log.isLoggable(LogLevel.DEBUG)) { log.log(LogLevel.DEBUG, "Error writing response to client - connection probably terminated " + "from client side.", e); } return new DevNullChannel(); // Ignore further operations on this } }
public void successfulResponse() { setTimeToFirstByteFirstTime(); long requestLatency = getRequestLatency(); metric.set(Metrics.TOTAL_SUCCESSFUL_LATENCY, requestLatency, context); metric.add(Metrics.NUM_SUCCESSFUL_RESPONSES, 1, context); }
public void failedResponse() { setTimeToFirstByteFirstTime(); metric.set(Metrics.TOTAL_FAILED_LATENCY, getRequestLatency(), context); metric.add(Metrics.NUM_FAILED_RESPONSES, 1, context); }
private void incrErrorCount(Result result, Metric.Context metricContext) { failedQueries.increment(); metric.add(FAILED_QUERIES_METRIC, 1, metricContext); if (result == null) // the chain threw an exception metric.add("error.unhandled_exception", 1, metricContext); else if (result.hits().getErrorHit().hasOnlyErrorCode(Error.NULL_QUERY.code)) nullQueries.increment(); else if (result.hits().getErrorHit().hasOnlyErrorCode(Error.ILLEGAL_QUERY.code)) illegalQueries.increment(); }
/** Returns the next message in the stream, or null if none */ protected DocumentOperationMessageV3 getNextMessage( String operationId, InputStream requestInputStream, FeederSettings settings) throws Exception { VespaXMLFeedReader.Operation operation = streamReaderV3.getNextOperation(requestInputStream, settings); // This is a bit hard to set up while testing, so we accept that things are not perfect. if (sourceSession.getResource().session() != null) { metric.set( MetricNames.PENDING, Double.valueOf(sourceSession.getResource().session().getPendingCount()), null); } DocumentOperationMessageV3 message = DocumentOperationMessageV3.create(operation, operationId, metric); if (message == null) { // typical end of feed return null; } metric.add(MetricNames.NUM_OPERATIONS, 1, null /*metricContext*/); log(LogLevel.DEBUG, "Successfully deserialized document id: ", message.getOperationId()); return message; }
@Override public void handleReply(Reply reply) { Object o = reply.getContext(); if (!(o instanceof ReplyContext)) { return; } ReplyContext context = (ReplyContext) o; final double latencyInSeconds = (System.currentTimeMillis() - context.creationTime) / 1000.0d; metric.set(MetricNames.LATENCY, latencyInSeconds, null); if (reply.hasErrors()) { Set<Integer> errorCodes = reply.getErrorCodes(); metricsHelper.reportFailure(DocumentOperationType.fromMessage(reply.getMessage()), DocumentOperationStatus.fromMessageBusErrorCodes(errorCodes)); metric.add(MetricNames.FAILED, 1, null); enqueue(context, reply.getError(0).getMessage(), ErrorCode.ERROR, reply.getError(0).getCode() == DocumentProtocol.ERROR_TEST_AND_SET_CONDITION_FAILED, reply.getTrace()); } else { metricsHelper.reportSuccessful(DocumentOperationType.fromMessage(reply.getMessage()), latencyInSeconds); metric.add(MetricNames.SUCCEEDED, 1, null); enqueue(context, "Document processed.", ErrorCode.OK, false, reply.getTrace()); } }