@JsonIgnore public Instant getLookBackAsInstant() { return Instant.ofEpochMilli(getLookBackAsDuration().toMillis()); } }
/** * Calculates the start and end timestamps that will be used when quering the metrics sources when doing the * canary judgements for each judgement interval. * * @param judgementNumber The judgement number / index for the canary analysis execution * @param judgementDuration The duration of the judgement window * @param config The execution request config * @return A wrapper object containing the start and end times to be used as Instants */ protected ScopeTimeConfig calculateStartAndEndForJudgement(CanaryAnalysisExecutionRequest config, long judgementNumber, Duration judgementDuration) { Duration warmupDuration = config.getBeginCanaryAnalysisAfterAsDuration(); Duration offset = judgementDuration.multipliedBy(judgementNumber); ScopeTimeConfig scopeTimeConfig = new ScopeTimeConfig(); Instant startTime = Optional.ofNullable(config.getStartTime()).orElse(now(clock)); scopeTimeConfig.start = startTime; scopeTimeConfig.end = startTime.plus(offset); if (config.getEndTime() == null) { scopeTimeConfig.start = scopeTimeConfig.start.plus(warmupDuration); scopeTimeConfig.end = scopeTimeConfig.end.plus(warmupDuration); } // If the look back is defined, use it to recalculate the start time, this is used to do sliding window judgements if (config.getLookBackAsInstant().isAfter(ZERO_AS_INSTANT)) { scopeTimeConfig.start = scopeTimeConfig.end.minus(config.getLookBackAsDuration()); } return scopeTimeConfig; }
@JsonIgnore public Instant getLookBackAsInstant() { return Instant.ofEpochMilli(getLookBackAsDuration().toMillis()); } }
/** * Calculates the start and end timestamps that will be used when quering the metrics sources when doing the * canary judgements for each judgement interval. * * @param judgementNumber The judgement number / index for the canary analysis execution * @param judgementDuration The duration of the judgement window * @param config The execution request config * @return A wrapper object containing the start and end times to be used as Instants */ protected ScopeTimeConfig calculateStartAndEndForJudgement(CanaryAnalysisExecutionRequest config, long judgementNumber, Duration judgementDuration) { Duration warmupDuration = config.getBeginCanaryAnalysisAfterAsDuration(); Duration offset = judgementDuration.multipliedBy(judgementNumber); ScopeTimeConfig scopeTimeConfig = new ScopeTimeConfig(); Instant startTime = Optional.ofNullable(config.getStartTime()).orElse(now(clock)); scopeTimeConfig.start = startTime; scopeTimeConfig.end = startTime.plus(offset); if (config.getEndTime() == null) { scopeTimeConfig.start = scopeTimeConfig.start.plus(warmupDuration); scopeTimeConfig.end = scopeTimeConfig.end.plus(warmupDuration); } // If the look back is defined, use it to recalculate the start time, this is used to do sliding window judgements if (config.getLookBackAsInstant().isAfter(ZERO_AS_INSTANT)) { scopeTimeConfig.start = scopeTimeConfig.end.minus(config.getLookBackAsDuration()); } return scopeTimeConfig; }