@Override
    public FailureResult howToHandleFailure(
            Throwable failure, CompletableFuture<Map<String, String>> failureLabels) {
        FailureResult failureResult = howToHandleFailure(failure);
        if (reportEventsAsSpans) {
            // TODO: replace with reporting as event once events are supported.
            // Add reporting as callback for when the failure labeling is completed.
            failureLabels.thenAcceptAsync(
                    (labels) -> jobFailureMetricReporter.reportJobFailure(failureResult, labels),
                    componentMainThreadExecutor);
        }
        return failureResult;
    }
@Test
    void testHowToHandleFailureRejectedByStrategy() throws Exception {
        final Configuration configuration = new Configuration();
        configuration.set(TraceOptions.REPORT_EVENTS_AS_SPANS, Boolean.TRUE);
        final List<Span> spanCollector = new ArrayList<>(1);
        final UnregisteredMetricGroups.UnregisteredJobManagerJobMetricGroup testMetricGroup =
                createTestMetricGroup(spanCollector);

        final AdaptiveScheduler scheduler =
                new AdaptiveSchedulerBuilder(
                                createJobGraph(),
                                mainThreadExecutor,
                                EXECUTOR_RESOURCE.getExecutor())
                        .setRestartBackoffTimeStrategy(NoRestartBackoffTimeStrategy.INSTANCE)
                        .setJobMasterConfiguration(configuration)
                        .setJobManagerJobMetricGroup(testMetricGroup)
                        .build();

        assertThat(
                        scheduler
                                .howToHandleFailure(
                                        new Exception("test"), createFailureLabelsFuture())
                                .canRestart())
                .isFalse();

        assertThat(spanCollector).isEmpty();
        mainThreadExecutor.trigger();
        checkMetrics(spanCollector, false);
    }