Skip to content

expose pending tasks of eventloops as metrics #1398

@warmuuh

Description

@warmuuh

expose pending tasks of eventloops as metrics both for server and client.
Currently, some metrics are provided (reactor.netty.http.[client|server]). it would be nice to also see pending tasks as this is an important metric about the health of the system.

see https://gitter.im/reactor/reactor-netty?at=5fc0ec2466dcfa77e2a78389 for related question

Motivation

a current solution seems to be possible like this

 httpServer.doOnBind(config -> {
        config.loopResources()
            .onServer(httpServer.configuration().isPreferNative())
            .forEach(eventExecutor -> {
              if (eventExecutor instanceof SingleThreadEventExecutor) {
                var singleThreadEventExecutor = (SingleThreadEventExecutor) eventExecutor;
                Gauge.builder(SERVER_PENDING_TASK_METRIC, singleThreadEventExecutor::pendingTasks)
                    .description("Pending Tasks")
                    .tag(SERVER_THREAD_NAME, singleThreadEventExecutor.threadProperties().name())
                    .tag(SERVER_THREAD_STATE, singleThreadEventExecutor.threadProperties().state().name())
                    .register(registry);
              }
            });

Desired solution

httpServer::metric and TcpClient::metric should result in this metric to also be exposed

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions