Spear.subscribe_to_stats
You're seeing just the function
subscribe_to_stats
, go back to Spear module for more information.
Specs
subscribe_to_stats( connection :: Spear.Connection.t(), subscriber :: pid() | GenServer.name(), opts :: Keyword.t() ) :: {:ok, reference()} | {:error, any()}
Subscribes a process to stats updates from the EventStoreDB
This function subscribes a process in the same way as subscribe/4
: the
function will return a reference representing the subscription and the
stats messages will be sent to the subscriber process with send/2
.
This subscription can be cancelled with cancel_subscription/3
.
This functionality was added to EventStoreDB in release v21.6.0. Prior EventStoreDB versions will throw a GRPC error when attempting to use this function.
Options
:interval
- (default:5_000
- 5 seconds) the interval after which a new stats message should be sent. By default, stats messages arrive every five seconds.:use_metadata?
- (default:true
) undocumented option. See the EventStoreDB implementation for more information.:timeout
- (default:5_000
- 5 seconds) the GenServer timeout to use when requesting a subscription to stats:raw?
- (default:false
) whether to emit the stats messages as 'raw'Spear.Records.Monitoring.stats_resp/0
records in a tuple of{subscription :: reference(), Spear.Records.Monitoring.stats_resp()}
. By default, stats messages are returned as maps.:credentials
- (default:nil
) credentials to use to perform this subscription request.
Examples
iex> Spear.subscribe_to_stats(conn, self())
{:ok, #Reference<0.359109646.3547594759.216222>}
iex> flush()
%{
"es-queue-Projection Core #2-length" => "0",
"es-queue-Worker #1-lengthLifetimePeak" => "0",
"es-queue-Worker #3-lengthCurrentTryPeak" => "0",
"es-queue-StorageReaderQueue #9-avgProcessingTime" => "0",
"es-queue-StorageReaderQueue #6-idleTimePercent" => "100",
..
}