private void setKey(ResourceMetricKey resourceKey) { this.key = resourceKey; this.resource = resourceKey.getResourceKey(); this.metric = resourceKey.getMetricKey(); }
public ResourceMetricKey getKey() { if (key != null) { return key; } key = ResourceMetricKey.valueOf(resource, metric); return key; }
public static ResourceMetricKey valueOf (ResourceKey resource, MetricKey metric) { return new ResourceMetricKey(resource, metric); }
public boolean isCounter() { return Metrics.COUNTER_TYPE.equals(getKey().getMetricKey().getType()); }
List<IntervalMetricDataSummary> getMetricDataSummary(ResourceMetricKey rmKey, long now, int[] intervals) { List<IntervalMetricDataSummary> res = new ArrayList<IntervalMetricDataSummary>(); MetricData data = repo.createOrGetMetricData(rmKey); for (int interval : intervals) { TimeRange range = getIntervalRange(interval, now); res.add(getMetric(rmKey.getMetricKey(), range, data)); } return res; }
void setKey(ResourceMetricKey resourceKey) { this.key = resourceKey; this.resource = resourceKey.getResourceKey(); this.metric = resourceKey.getMetricKey(); }
public ResourceMetricKey getKey() { if (key != null) { return key; } key = ResourceMetricKey.valueOf(resource, metric); return key; }
Set<MetricKey> getDefaultExposedMetrics() { Set<MetricKey> res = asSet(INVOCATION_COUNT, ERROR_COUNT, TOLERATED_TAG.getMetricKey(), SATISFIED_TAG.getMetricKey(), FRUSTRATED_TAG.getMetricKey(), healthKey.getMetricKey()); if (resource.getType().isResponseTimeAware()) { res.add(ENDPOINT_RESPONSE_TIME); } return res; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ResourceMetricKey other = (ResourceMetricKey) obj; return ObjectUtil.typedEquals(getResourceKey(), other.getResourceKey()) && ObjectUtil.typedEquals(getMetricKey(), other.getMetricKey()) ; }
public ResourceMetricKey getHealthKey(ResourceKey resourceKey) { return ResourceMetricKey.valueOf(resourceKey, healthKey); }
@Override public int hashCode() { return ObjectUtil.hashCode(getResourceKey()) + ObjectUtil.hashCode(getMetricKey()) ; }
void initializeExposedMetrics(Collection<MetricKey> metrics) { ResourceKey rKey = resource.getKey(); exposedMetrics = new ArrayList<ResourceMetricKey>(metrics.size()); for (MetricKey metric : metrics) { exposedMetrics.add(ResourceMetricKey.valueOf(rKey, metric)); } }
MetricData createMetricData(ResourceMetricKey key) { Metric metric = metricRepo.getMetric(key.getMetricKey()); MetricDataFactory<?> factory = dataFactoryLocator.getFactory(metric.getType()); if (factory == null) { throw new InsightRuntimeException("Factory not found for metric type [" + metric.getType() + "]"); } Resource resource = resourceRepo.findOrCreateResource(key.getResourceKey()); MetricData res = factory.createMetricData(resource, metric); return res; }
public NapdexHealthMetricData(MetricDataRepo metricDataRepo, MetricRepo metricRepo, ResourceKey resource) { this.dataRepo = metricDataRepo; this.metricRepo = metricRepo; this.satisfied = ResourceMetricKey.valueOf(resource, SATISFIED_TAG.getMetricKey()); this.tolerated = ResourceMetricKey.valueOf(resource, TOLERATED_TAG.getMetricKey()); this.frustrated = ResourceMetricKey.valueOf(resource, FRUSTRATED_TAG.getMetricKey()); this.satisfiedData = dataRepo.createOrGetMetricData(satisfied); this.toleratedData = dataRepo.createOrGetMetricData(tolerated); this.frustratedData = dataRepo.createOrGetMetricData(frustrated); }
public List<SyncMetricDataTagCommand> generateCommands(TraceAnalysis analysis) { Set<Resource> resources = analysis.getResources(); List<SyncMetricDataTagCommand> commands = new ArrayList<SyncMetricDataTagCommand>(resources.size()); String tagName = REQUEST_URI_EXAMPLE; String tagValue = analysis.getEndPointAnalysis().getExample(); for (Resource r : resources) { ResourceMetricKey rmKey = ResourceMetricKey.valueOf(r.getKey(), ENDPOINT_RESPONSE_TIME); commands.add(new SyncMetricDataTagCommand(rmKey, tagName, tagValue)); } return commands; }
public List<UpdateMetricCommand> generateCommands(TraceAnalysis analysis) { Resource endPoint=analysis.getEndPoint(); ResourceMetricKey rmKey=ResourceMetricKey.valueOf(endPoint.getKey(), Metrics.ENDPOINT_RESPONSE_TIME); return asList(new UpdateMetricCommand(rmKey, analysis.getResponseTimePoint())); }
public List<UpdateMetricCommand> generateCommands(TraceAnalysis analysis) { if (!analysis.isError()) { return Collections.emptyList(); } ResourceMetricKey rmKey = ResourceMetricKey.valueOf(analysis.getEndPoint().getKey(), ERROR_COUNT); CounterMetricValue val = new CounterMetricValue(analysis.getResponseTime(), 1); return Collections.singletonList(new UpdateMetricCommand(rmKey, val)); }
public List<UpdateMetricCommand> generateCommands(TraceAnalysis analysis) { List<MetricKey> tagMetricKeys = getMetricsForTags(analysis.getTraceTags()); List<UpdateMetricCommand> commands = new ArrayList<UpdateMetricCommand>(tagMetricKeys.size()); TimeRange responseTime = analysis.getResponseTime(); ResourceKey resourceKey = analysis.getEndPoint().getKey(); for (MetricKey tagMetricKey : tagMetricKeys) { ResourceMetricKey rmKey = ResourceMetricKey.valueOf(resourceKey, tagMetricKey); CounterMetricValue value = new CounterMetricValue(responseTime, 1); commands.add(new UpdateMetricCommand(rmKey, value)); } return commands; }
public List<UpdateMetricCommand> generateCommands(TraceAnalysis analysis) { Resource endPoint=analysis.getEndPoint(); ResourceMetricKey rmKey=ResourceMetricKey.valueOf(endPoint.getKey(), INVOCATION_COUNT); CounterMetricValue value=new CounterMetricValue(analysis.getResponseTime(), 1.0d); return singletonList(new UpdateMetricCommand(rmKey, value)); } }
public static SyncMetricDataTagCommand getMetricDataTagCommand() { ResourceMetricKey key = ResourceMetricKey.valueOf(getServerResourceCommand("butter", "butter-label").getResource().getKey(), Metrics.INVOCATION_COUNT); return new SyncMetricDataTagCommand(key,"mytagName", "tag"); }