@ExecuteOn(TaskExecutors.IO)
    @Get(uri = "/{executionId}")
    @Operation(tags = {"Metrics"}, summary = "Get metrics for a specific execution")
    public PagedResults<MetricEntry> findByExecution(
        @Parameter(description = "The current page") @QueryValue(defaultValue = "1") int page,
        @Parameter(description = "The current page size") @QueryValue(defaultValue = "10") int size,
        @Parameter(description = "The sort of current page") @Nullable @QueryValue List<String> sort,
        @Parameter(description = "The execution id") @PathVariable String executionId,
        @Parameter(description = "The taskrun id") @Nullable @QueryValue String taskRunId,
        @Parameter(description = "The task id") @Nullable @QueryValue String taskId
    ) {
        var pageable = PageableUtils.from(page, size, sort, metricsRepository.sortMapping());
        if (taskId != null) {
            return PagedResults.of(metricsRepository.findByExecutionIdAndTaskId(tenantService.resolveTenant(), executionId, taskId, pageable));
        } else if (taskRunId != null) {
            return PagedResults.of(metricsRepository.findByExecutionIdAndTaskRunId(tenantService.resolveTenant(), executionId, taskRunId, pageable));
        } else {
            return PagedResults.of(metricsRepository.findByExecutionId(tenantService.resolveTenant(), executionId, pageable));
        }
    }
@SuppressWarnings("unchecked")
    @Test
    void findByExecution() {
        Execution result = triggerExecution(TESTS_FLOW_NS, "minimal", null, true);
        assertThat(result, notNullValue());

        PagedResults<MetricEntry> metrics = client.toBlocking().retrieve(
            HttpRequest.GET("/api/v1/metrics/" + result.getId()),
            Argument.of(PagedResults.class, MetricEntry.class)
        );
        assertThat(metrics.getTotal(), is(2L));
    }