On this page

M

ClientStats

History
Source Code: lib/util/stats.js
Stability: 2Stable

A ClientStats is a point-in-time snapshot of the connection and request state of a single Client. Instances are not created directly; a fresh snapshot is produced each time the client.stats getter is read.

import { Client } from 'undici'

const client = new Client('http://localhost:3000')
const stats = client.stats
console.log(stats.connected, stats.running)
C

ClientStats

History

Captures the connection and request counters of a Client at the moment the snapshot is taken. The values are read from the client at construction time and do not update afterwards; read client.stats again for current values.

C

ClientStats Constructor

History
new ClientStats(client): void
Attributes
client:<Client>
The client to read the statistics from.

Creates a snapshot from the supplied client. This constructor is used internally by the client.stats getter and is not normally invoked by application code.

P

clientStats.connected

History

true when the client currently has an open socket connection.

P

clientStats.pending

History

Number of open socket connections of this client that do not have an active request.

P

clientStats.running

History

Number of currently active requests of this client.

P

clientStats.size

History

Number of active, pending, or queued requests of this client.