@Override public Context createContext(Map<String, ?> properties) { if (properties == null) properties = new HashMap<>(); return new Point(properties); }
public GaugeWrapper declareGauge(String application, Dimensions dimensions, String name, DimensionType type) { synchronized (monitor) { Map<Dimensions, Map<String, MetricValue>> metricsByDimensions = getOrCreateApplicationMetrics(application, type); if (!metricsByDimensions.containsKey(dimensions)) metricsByDimensions.put(dimensions, new HashMap<>()); if (!metricsByDimensions.get(dimensions).containsKey(name)) { GaugeWrapper gauge = new GaugeWrapper(metricReceiver.declareGauge(name, new Point(dimensions.dimensionsMap))); metricsByDimensions.get(dimensions).put(name, gauge); } return (GaugeWrapper) metricsByDimensions.get(dimensions).get(name); } }
public CounterWrapper declareCounter(String application, Dimensions dimensions, String name, DimensionType type) { synchronized (monitor) { Map<Dimensions, Map<String, MetricValue>> metricsByDimensions = getOrCreateApplicationMetrics(application, type); if (!metricsByDimensions.containsKey(dimensions)) metricsByDimensions.put(dimensions, new HashMap<>()); if (!metricsByDimensions.get(dimensions).containsKey(name)) { CounterWrapper counter = new CounterWrapper(metricReceiver.declareCounter(name, new Point(dimensions.dimensionsMap))); metricsByDimensions.get(dimensions).put(name, counter); } return (CounterWrapper) metricsByDimensions.get(dimensions).get(name); } }
/** * Create a new Point instance using the settings stored in this * PointBuilder. PointBuilder instances cannot be re-used after build() has * been invoked. * * @return a Point instance reflecting this builder */ public Point build() { Point p = Point.emptyPoint(); int size = dimensions.size(); if (size != 0) { p = new Point(dimensions.toArray(new String[size]), location.toArray(new Value[size])); } // deny builder re-use dimensions = null; location = null; return p; }
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 DocumentApiMetrics(MetricReceiver metricReceiver, String apiName) { Map<String, String> dimensions = new HashMap<>(); dimensions.put("api", apiName); for (DocumentOperationStatus status : DocumentOperationStatus.values()) { points.put(status, new HashMap<>()); dimensions.put("status", status.name()); for (DocumentOperationType operation : DocumentOperationType.values()) { dimensions.put("operation", operation.name()); points.get(status).put(operation, new Point(dimensions)); } } feeds = metricReceiver.declareCounter("feed.operations"); feedLatency = metricReceiver.declareGauge("feed.latency"); feedRequests = metricReceiver.declareCounter("feed.http-requests"); }