/** * Add to the dimension-less/zero-point value of this counter. * * @param n the amount by which to increase this counter */ public void add(long n) { add(n, defaultPosition); }
@Override public PointBuilder builder() { return super.builder(); } }
/** * Declare a counter metric, with default dimension values as given. Create * the point argument by using a builder from {@link #pointBuilder()}. * * @param name * the name of the metric * @param boundDimensions * dimensions which have a fixed value in the life cycle of the * metric object or null * @return a thread-safe counter with given default values */ public Counter declareCounter(String name, Point boundDimensions) { return new Counter(name, boundDimensions, this); }
/** * Increase the dimension-less/zero-point value of this counter by 1. */ public void add() { add(1L, defaultPosition); }
private Point createContext(String dimensionName, String dimensionValue) { return overQuotaCounter.builder().set(dimensionName, dimensionValue).build(); }
/** * Increase this metric at the given point by 1. * * @param p the point in the metric space at which to increase this metric by 1 */ public void add(Point p) { add(1L, p); }
public void add(long n) { synchronized (lock) { counter.add(n); value += n; } }
public void reportFailure(DocumentOperationType documentOperationType, DocumentOperationStatus documentOperationStatus) { Point point = points.get(documentOperationStatus).get(documentOperationType); feeds.add(point); }
public void reportHttpRequest(String clientVersion) { if (clientVersion != null) { try { Point point = versionPointCache.get(clientVersion, () -> new Point(Map.of("client-version", clientVersion))); feedRequests.add(point); } catch (ExecutionException e) { // When Point constructor throws an exception throw new RuntimeException(e); } } else { feedRequests.add(); } }
public void reportSuccessful(DocumentOperationType documentOperationType, double latencyInSeconds) { Point point = points.get(DocumentOperationStatus.OK).get(documentOperationType); feedLatency.sample(latencyInSeconds, point); feeds.add(point); }
return; utfRejections.add(); throw new IllegalArgumentException("The user input has been determined to be double encoded UTF-8." + " Please investigate whether this is a false positive.");
private void repeatedTermsInPhraseCheck(PhraseItem phrase) { if (phrase.getItemCount() > MAX_REPEATED_TERMS_IN_PHRASE) { Map<String, Count> repeatedCount = new HashMap<>(); for (int i = 0; i < phrase.getItemCount(); ++i) { Item item = phrase.getItem(i); if (item instanceof TermItem) { TermItem term = (TermItem) item; String current = term.getIndexedString(); Count count = repeatedCount.get(current); if (count != null) { if (count.get() >= MAX_REPEATED_TERMS_IN_PHRASE) { repeatedTermsInPhraseRejections.add(); throw new IllegalArgumentException("Phrase contains more than " + MAX_REPEATED_TERMS_IN_PHRASE + " occurrences of term '" + current + "' in phrase : " + phrase.toString()); } count.inc(); } else { repeatedCount.put(current, new Count(1)); } } } } }
private void repeatedConsecutiveTermsInPhraseCheck(PhraseItem phrase) { if (phrase.getItemCount() > MAX_REPEATED_CONSECUTIVE_TERMS_IN_PHRASE) { String prev = null; int repeatedCount = 0; for (int i = 0; i < phrase.getItemCount(); ++i) { Item item = phrase.getItem(i); if (item instanceof TermItem) { TermItem term = (TermItem) item; String current = term.getIndexedString(); if (prev != null) { if (prev.equals(current)) { repeatedCount++; if (repeatedCount >= MAX_REPEATED_CONSECUTIVE_TERMS_IN_PHRASE) { repeatedConsecutiveTermsInPhraseRejections.add(); throw new IllegalArgumentException("More than " + MAX_REPEATED_CONSECUTIVE_TERMS_IN_PHRASE + " ocurrences of term '" + current + "' in a row detected in phrase : " + phrase.toString()); } } else { repeatedCount = 0; } } prev = current; } else { prev = null; repeatedCount = 0; } } } } private static final class Count {