Skip to content

Commit

Permalink
Code format
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagohora committed Dec 13, 2024
1 parent 19bdb8b commit db2961b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public Mono<List<Entry>> getDuration(@NonNull UUID projectId, @NonNull ProjectMe
.map(Stream::toList));
}

private Stream<Entry> mapDuration(Row row) {
private Stream<Entry> mapDuration(Row row) {
return Optional.ofNullable(row.get("duration", List.class))
.map(durations -> Stream.of(
Entry.builder().name(NAME_DURATION_P50)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ class ProjectMetricsServiceImpl implements ProjectMetricsService {
@Inject
public ProjectMetricsServiceImpl(@NonNull ProjectMetricsDAO projectMetricsDAO) {
metricHandler = Map.of(
MetricType.TRACE_COUNT, projectMetricsDAO::getTraceCount,
MetricType.FEEDBACK_SCORES, projectMetricsDAO::getFeedbackScores,
MetricType.TOKEN_USAGE, projectMetricsDAO::getTokenUsage,
MetricType.COST, projectMetricsDAO::getCost,
MetricType.DURATION, projectMetricsDAO::getDuration);
MetricType.TRACE_COUNT, projectMetricsDAO::getTraceCount,
MetricType.FEEDBACK_SCORES, projectMetricsDAO::getFeedbackScores,
MetricType.TOKEN_USAGE, projectMetricsDAO::getTokenUsage,
MetricType.COST, projectMetricsDAO::getCost,
MetricType.DURATION, projectMetricsDAO::getDuration);
}

@Override
Expand Down Expand Up @@ -78,7 +78,8 @@ private List<ProjectMetricResponse.Results<Number>> entriesToResults(List<Projec
.toList();
}

private BiFunction<UUID, ProjectMetricRequest, Mono<List<ProjectMetricsDAO.Entry>>> getMetricHandler(MetricType metricType) {
private BiFunction<UUID, ProjectMetricRequest, Mono<List<ProjectMetricsDAO.Entry>>> getMetricHandler(
MetricType metricType) {
return Optional.ofNullable(metricHandler.get(metricType))
.orElseThrow(() -> new BadRequestException(ERR_PROJECT_METRIC_NOT_SUPPORTED.formatted(metricType)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,7 @@ public static Stream<Arguments> invalidParameters() {
arguments(named("start equal to end", validReq.toBuilder()
.intervalStart(now)
.intervalEnd(now)
.build()), ProjectMetricsService.ERR_START_BEFORE_END)
);
.build()), ProjectMetricsService.ERR_START_BEFORE_END));
}

@ParameterizedTest
Expand Down Expand Up @@ -721,13 +720,14 @@ void happyPath(TimeInterval interval) {
getMetricsAndAssert(
projectId,
ProjectMetricRequest.builder()
.metricType(MetricType.DURATION)
.interval(interval)
.intervalStart(subtract(marker, TIME_BUCKET_4, interval))
.intervalEnd(Instant.now())
.build(),
.metricType(MetricType.DURATION)
.interval(interval)
.intervalStart(subtract(marker, TIME_BUCKET_4, interval))
.intervalEnd(Instant.now())
.build(),
marker,
List.of(ProjectMetricsDAO.NAME_DURATION_P50, ProjectMetricsDAO.NAME_DURATION_P90, ProjectMetricsDAO.NAME_DURATION_P99),
List.of(ProjectMetricsDAO.NAME_DURATION_P50, ProjectMetricsDAO.NAME_DURATION_P90,
ProjectMetricsDAO.NAME_DURATION_P99),
BigDecimal.class,
durationMinus3,
durationMinus1,
Expand Down Expand Up @@ -755,18 +755,18 @@ void emptyData(TimeInterval interval) {
getMetricsAndAssert(
projectId,
ProjectMetricRequest.builder()
.metricType(MetricType.DURATION)
.interval(interval)
.intervalStart(subtract(marker, TIME_BUCKET_4, interval))
.intervalEnd(Instant.now())
.build(),
.metricType(MetricType.DURATION)
.interval(interval)
.intervalStart(subtract(marker, TIME_BUCKET_4, interval))
.intervalEnd(Instant.now())
.build(),
marker,
List.of(ProjectMetricsDAO.NAME_DURATION_P50, ProjectMetricsDAO.NAME_DURATION_P90, ProjectMetricsDAO.NAME_DURATION_P99),
List.of(ProjectMetricsDAO.NAME_DURATION_P50, ProjectMetricsDAO.NAME_DURATION_P90,
ProjectMetricsDAO.NAME_DURATION_P99),
BigDecimal.class,
empty,
empty,
empty
);
empty);
}

private List<BigDecimal> createTraces(String projectName, Instant marker) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2788,7 +2788,8 @@ Stream<Arguments> getSpansByProject__whenFilterByDuration__thenReturnSpansFilter

@ParameterizedTest
@MethodSource
void getSpansByProject__whenFilterByDuration__thenReturnSpansFiltered(Operator operator, long end, double duration) {
void getSpansByProject__whenFilterByDuration__thenReturnSpansFiltered(Operator operator, long end,
double duration) {
String workspaceName = UUID.randomUUID().toString();
String workspaceId = UUID.randomUUID().toString();
String apiKey = UUID.randomUUID().toString();
Expand Down Expand Up @@ -7587,8 +7588,7 @@ static Stream<Filter> getSpanStats__whenFilterInvalidOperatorForFieldType__thenR
.field(SpanField.DURATION)
.operator(Operator.STARTS_WITH)
.value("1")
.build()
);
.build());
}

@ParameterizedTest
Expand Down Expand Up @@ -7702,8 +7702,7 @@ static Stream<Filter> getSpanStats__whenFilterInvalidValueOrKeyForFieldType__the
.field(SpanField.DURATION)
.operator(Operator.EQUAL)
.value(RandomStringUtils.randomAlphanumeric(5))
.build()
);
.build());
}

@ParameterizedTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2798,7 +2798,8 @@ Stream<Arguments> getTracesByProject__whenFilterByDuration__thenReturnTracesFilt

@ParameterizedTest
@MethodSource
void getTracesByProject__whenFilterByDuration__thenReturnTracesFiltered(Operator operator, long end, double duration) {
void getTracesByProject__whenFilterByDuration__thenReturnTracesFiltered(Operator operator, long end,
double duration) {
String workspaceName = UUID.randomUUID().toString();
String workspaceId = UUID.randomUUID().toString();
String apiKey = UUID.randomUUID().toString();
Expand Down Expand Up @@ -3077,8 +3078,7 @@ static Stream<Filter> getTracesByProject__whenFilterInvalidOperatorForFieldType_
.field(TraceField.DURATION)
.operator(Operator.NOT_CONTAINS)
.value("1")
.build()
);
.build());
}

@ParameterizedTest
Expand Down Expand Up @@ -6737,7 +6737,8 @@ Stream<Arguments> getTraceStats__whenFilterByDuration__thenReturnTracesFiltered(

@ParameterizedTest
@MethodSource
void getTraceStats__whenFilterByDuration__thenReturnTracesFiltered(Operator operator, long end, double duration) {
void getTraceStats__whenFilterByDuration__thenReturnTracesFiltered(Operator operator, long end,
double duration) {
String workspaceName = UUID.randomUUID().toString();
String workspaceId = UUID.randomUUID().toString();
String apiKey = UUID.randomUUID().toString();
Expand Down Expand Up @@ -7608,8 +7609,7 @@ static Stream<Filter> getTraceStats__whenFilterInvalidOperatorForFieldType__then
.field(TraceField.DURATION)
.operator(Operator.NOT_CONTAINS)
.value("1")
.build()
);
.build());
}

@ParameterizedTest
Expand Down Expand Up @@ -7710,8 +7710,7 @@ static Stream<Filter> getTraceStats__whenFilterInvalidValueOrKeyForFieldType__th
.field(TraceField.DURATION)
.operator(Operator.EQUAL)
.value(RandomStringUtils.randomAlphanumeric(5))
.build()
);
.build());
}

@ParameterizedTest
Expand Down

0 comments on commit db2961b

Please sign in to comment.