/** * identifies the stepDuration based on the timeseries. With 'TIMESERIES MAX' New Relic returns the maximum possible * resolution we need to determine the step size. * @param timeSeries to identify stepsize for * @return step size */ private Duration calculateStepDuration(NewRelicTimeSeries timeSeries) { Long firstTimestamp = null; for (NewRelicTimeSeries.NewRelicSeriesEntry entry : timeSeries.getTimeSeries()) { if (firstTimestamp == null) { // get first firstTimestamp = entry.getBeginTimeSeconds(); } else { // get next which differs from first if (!firstTimestamp.equals(entry.getBeginTimeSeconds())) { return Duration.ofSeconds(entry.getBeginTimeSeconds() - firstTimestamp); } } } return Duration.ZERO; } }
@JsonIgnore public Double getValue() { return adjustSingleResult(results.get(0)); } }
public Stream<Double> getDataPoints() { return timeSeries.stream().map(o -> o.getValue()); }
NewRelicRemoteService remoteService = accountCredentials.getNewRelicRemoteService(); NewRelicTimeSeries timeSeries = remoteService.getTimeSeries( credentials.getApiKey(), credentials.getApplicationKey(), Instant.ofEpochMilli(timeSeries.getMetadata().getBeginTimeMillis()); Instant end = Instant.ofEpochMilli(timeSeries.getMetadata().getEndTimeMillis()); .endTimeMillis(end.toEpochMilli()) .endTimeIso(end.toString()) .values(timeSeries.getDataPoints().collect(Collectors.toList())) .build() );
NewRelicRemoteService remoteService = accountCredentials.getNewRelicRemoteService(); NewRelicTimeSeries timeSeries = remoteService.getTimeSeries( credentials.getApiKey(), credentials.getApplicationKey(), Instant.ofEpochMilli(timeSeries.getMetadata().getBeginTimeMillis()); Instant end = Instant.ofEpochMilli(timeSeries.getMetadata().getEndTimeMillis()); .endTimeMillis(end.toEpochMilli()) .endTimeIso(end.toString()) .values(timeSeries.getDataPoints().collect(Collectors.toList())) .build() );
/** * identifies the stepDuration based on the timeseries. With 'TIMESERIES MAX' New Relic returns the maximum possible * resolution we need to determine the step size. * @param timeSeries to identify stepsize for * @return step size */ private Duration calculateStepDuration(NewRelicTimeSeries timeSeries) { Long firstTimestamp = null; for (NewRelicTimeSeries.NewRelicSeriesEntry entry : timeSeries.getTimeSeries()) { if (firstTimestamp == null) { // get first firstTimestamp = entry.getBeginTimeSeconds(); } else { // get next which differs from first if (!firstTimestamp.equals(entry.getBeginTimeSeconds())) { return Duration.ofSeconds(entry.getBeginTimeSeconds() - firstTimestamp); } } } return Duration.ZERO; } }
@JsonIgnore public Double getValue() { return adjustSingleResult(results.get(0)); } }
public Stream<Double> getDataPoints() { return timeSeries.stream().map(o -> o.getValue()); }