class MetricsHandler

Traits

Properties

protected PendingMetric> $metrics

The metrics being gathered.

Methods

array
infoForChannels(Application $application, array $channels, string $info)

Get meta / status information for the given channels.

array
info(Application $application, string $channel, string $info)

Get meta / status information for the given channel.

bool
isPresenceChannel(Channel $channel)

Determine if the given channel is a presence channel.

bool
isCacheChannel(Channel $channel)

Determine if the given channel is a cache channel.

int
userCount(Channel $channel)

Get the number of unique users subscribed to the presence channel.

__construct(ServerProviderManager $serverProviderManager, ChannelManager $channels, PubSubProvider $pubSubProvider)

Create an instance of the metrics handler.

array
gather(Application $application, string $type, array $options = [])

Gather the metrics for the given type.

array
get(PendingMetric $metric)

Get the metrics for the given type.

array
channel(PendingMetric $metric)

Get the channel for the given application.

array
channels(PendingMetric $metric)

Get the channels for the given application.

array
channelUsers(PendingMetric $metric)

Get the channel users for the given application.

array
connections(PendingMetric $metric)

Get the connections for the given application.

array
gatherMetricsFromSubscribers(PendingMetric $metric)

Gather metrics from all subscribers for the given type.

array
mergeSubscriberMetrics(array $metrics, MetricType $type)

Merge the given metrics into a single result set.

array
mergeChannel(array $metrics)

Merge multiple channel instances into a single set.

array
mergeChannels(array $metrics)

Merge multiple sets of channel instances into a single result set.

void
publish(PendingMetric $metric)

Publish the metrics for the given type.

void
stopListening(PendingMetric $metric)

Stop listening for the given metric.

Details

protected array infoForChannels(Application $application, array $channels, string $info)

Get meta / status information for the given channels.

Parameters

Application $application
array $channels
string $info

Return Value

array

protected array info(Application $application, string $channel, string $info)

Get meta / status information for the given channel.

Parameters

Application $application
string $channel
string $info

Return Value

array

protected bool isPresenceChannel(Channel $channel)

Determine if the given channel is a presence channel.

Parameters

Channel $channel

Return Value

bool

protected bool isCacheChannel(Channel $channel)

Determine if the given channel is a cache channel.

Parameters

Channel $channel

Return Value

bool

protected int userCount(Channel $channel)

Get the number of unique users subscribed to the presence channel.

Parameters

Channel $channel

Return Value

int

at line 30
__construct(ServerProviderManager $serverProviderManager, ChannelManager $channels, PubSubProvider $pubSubProvider)

Create an instance of the metrics handler.

Parameters

ServerProviderManager $serverProviderManager
ChannelManager $channels
PubSubProvider $pubSubProvider

at line 40
array gather(Application $application, string $type, array $options = [])

Gather the metrics for the given type.

Parameters

Application $application
string $type
array $options

Return Value

array

at line 57
array get(PendingMetric $metric)

Get the metrics for the given type.

Parameters

PendingMetric $metric

Return Value

array

at line 70
protected array channel(PendingMetric $metric)

Get the channel for the given application.

Parameters

PendingMetric $metric

Return Value

array

at line 78
protected array channels(PendingMetric $metric)

Get the channels for the given application.

Parameters

PendingMetric $metric

Return Value

array

at line 102
protected array channelUsers(PendingMetric $metric)

Get the channel users for the given application.

Parameters

PendingMetric $metric

Return Value

array

at line 121
protected array connections(PendingMetric $metric)

Get the connections for the given application.

Parameters

PendingMetric $metric

Return Value

array

at line 131
protected array gatherMetricsFromSubscribers(PendingMetric $metric)

Gather metrics from all subscribers for the given type.

Uses a Swoole coroutine channel with timeout instead of ReactPHP promises.

Parameters

PendingMetric $metric

Return Value

array

at line 186
protected array mergeSubscriberMetrics(array $metrics, MetricType $type)

Merge the given metrics into a single result set.

Parameters

array $metrics
MetricType $type

Return Value

array

at line 199
protected array mergeChannel(array $metrics)

Merge multiple channel instances into a single set.

Parameters

array $metrics

Return Value

array

at line 218
protected array mergeChannels(array $metrics)

Merge multiple sets of channel instances into a single result set.

Parameters

array $metrics

Return Value

array

at line 239
void publish(PendingMetric $metric)

Publish the metrics for the given type.

Called by the pub/sub message handler when this node receives a metrics request.

Parameters

PendingMetric $metric

Return Value

void

at line 250
protected void stopListening(PendingMetric $metric)

Stop listening for the given metric.

Parameters

PendingMetric $metric

Return Value

void