A default implementation of ClientMetrics that exposes the driver events as
Node.js events.
An instance of DefaultMetrics is configured by default in the client,
you can access this instance using Client#metrics property.
Members
Emits all the error events.
Use each of the properties to measure events of specific errors.
Properties:
Name
Type
Description
authentication
EventEmitter
Emits the authentication timeout error events.
clientTimeout
EventEmitter
Emits the client timeout error events.
connection
EventEmitter
Emits the connection error events.
readTimeout
EventEmitter
Emits the read timeout error events obtained from the server.
other
EventEmitter
Emits the error events, that are not part of the other categories.
unavailable
EventEmitter
Emits the unavailable error events obtained from the server.
writeTimeout
EventEmitter
Emits the write timeout error events obtained from the server
Emits events when an error is ignored by the retry policy.
Emits events when a response message is obtained.
Properties:
Name
Type
Description
success
EventEmitter
Emits when a response was obtained as the result of a successful execution.
Emits all the retry events.
Use each of the properties to measure events of specific retries.
Properties:
Name
Type
Description
clientTimeout
EventEmitter
Emits when an execution is retried as a result of an client timeout.
other
EventEmitter
Emits the error events, that are not part of the other categories.
readTimeout
EventEmitter
Emits an execution is retried as a result of an read timeout error from the
server (coordinator to replica).
unavailable
EventEmitter
Emits an execution is retried as a result of an unavailable error from the
server.
writeTimeout
EventEmitter
Emits an execution is retried as a result of a write timeout error from the
server (coordinator to replica).
Emits events when a speculative execution is started.
Constructor
Creates a new instance of DefaultMetrics .
Examples:
Listening to events emitted
defaultMetrics . errors . on ( 'increment' , err => totalErrors ++ );
defaultMetrics . errors . clientTimeout . on ( 'increment' , () => clientTimeoutErrors ++ );
defaultMetrics . speculativeRetries . on ( 'increment' , () => specExecsCount ++ );
defaultMetrics . responses . on ( 'increment' , latency => myHistogram . record ( latency ));
Methods
onAuthenticationError
( AuthenticationError or
Error e )
Method invoked when an authentication error is obtained from the server.
Parameters:
Name
Type
Description
e
AuthenticationError or Error
The error encountered.
onClientTimeoutError
( OperationTimedOutError e )
Method invoked when an error (different than a server or client timeout, authentication or connection error) is
encountered when executing a request.
Parameters:
Name
Type
Description
e
OperationTimedOutError
The timeout error.
onClientTimeoutRetry
( Error e )
Method invoked when an execution is retried as a result of a client-level timeout.
Parameters:
Name
Type
Description
e
Error
The error that caused the retry.
onConnectionError
( Error e )
Method invoked when there is a connection error.
Parameters:
Name
Type
Description
e
Error
The error encountered.
Method invoked when an error is marked as ignored by the retry policy.
Parameters:
Name
Type
Description
e
Error
The error that was ignored by the retry policy.
Method invoked when an error (different than a server or client timeout, authentication or connection error) is
encountered when executing a request.
Parameters:
Name
Type
Description
e
Error
The error encountered.
onOtherErrorRetry
( Error e )
Method invoked when an error (other than a server or client timeout) is retried.
Parameters:
Name
Type
Description
e
Error
The error that caused the retry.
onReadTimeoutError
( ResponseError e )
Method invoked when a read timeout error is obtained from the server.
Parameters:
Name
Type
Description
e
ResponseError
The error encountered.
onReadTimeoutRetry
( Error e )
Method invoked when an execution is retried as a result of a read timeout from the server (coordinator to replica).
Parameters:
Name
Type
Description
e
Error
The error that caused the retry.
Method invoked when any response is obtained, the response can be the result of a successful execution or a
server-side error.
Parameters:
Name
Type
Description
latency
Array < Number >
The latency represented in a [seconds, nanoseconds] tuple
Array, where nanoseconds is the remaining part of the real time that can’t be represented in second precision.
onSpeculativeExecution
( )
Method invoked when a speculative execution is started.
Method invoked when a response is obtained successfully.
Parameters:
Name
Type
Description
latency
Array < Number >
The latency represented in a [seconds, nanoseconds] tuple
Array, where nanoseconds is the remaining part of the real time that can’t be represented in second precision.
onUnavailableError
( ResponseError e )
Method invoked when an unavailable error is obtained from the server.
Parameters:
Name
Type
Description
e
ResponseError
The error encountered.
onUnavailableRetry
( Error e )
Method invoked when an execution is retried as a result of an unavailable error from the server.
Parameters:
Name
Type
Description
e
Error
The error that caused the retry.
onWriteTimeoutError
( ResponseError e )
Method invoked when a write timeout error is obtained from the server.
Parameters:
Name
Type
Description
e
ResponseError
The error encountered.
onWriteTimeoutRetry
( Error e )
Method invoked when an execution is retried as a result of a write timeout from the server (coordinator to
replica).
Parameters:
Name
Type
Description
e
Error
The error that caused the retry.