public static RpcService startRemoteMetricsRpcService(
            Configuration configuration,
            String externalAddress,
            @Nullable String bindAddress,
            RpcSystem rpcSystem)
            throws Exception {
        final String portRange = configuration.get(MetricOptions.QUERY_SERVICE_PORT);

        final RpcSystem.RpcServiceBuilder rpcServiceBuilder =
                rpcSystem.remoteServiceBuilder(configuration, externalAddress, portRange);
        if (bindAddress != null) {
            rpcServiceBuilder.withBindAddress(bindAddress);
        }

        return startMetricRpcService(configuration, rpcServiceBuilder);
    }
@Test
    void testStartMetricActorSystemRespectsThreadPriority() throws Exception {
        final Configuration configuration = new Configuration();
        final int expectedThreadPriority = 3;
        configuration.set(MetricOptions.QUERY_SERVICE_THREAD_PRIORITY, expectedThreadPriority);

        final RpcService rpcService =
                MetricUtils.startRemoteMetricsRpcService(
                        configuration, "localhost", null, RpcSystem.load());

        try {
            final int threadPriority =
                    rpcService
                            .getScheduledExecutor()
                            .schedule(
                                    () -> Thread.currentThread().getPriority(), 0, TimeUnit.SECONDS)
                            .get();
            assertThat(threadPriority).isEqualTo(expectedThreadPriority);
        } finally {
            rpcService.closeAsync().get();
        }
    }