Skip to content

Commit fe72326

Browse files
committed
feat: add USERS_ONLINE_STATS metric for tracking distinct online user statistics
1 parent e331f17 commit fe72326

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

libs/contract/constants/metrics/metric-names.constant.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export const METRIC_NAMES = {
22
NODE_ONLINE_USERS: 'node_online_users',
33
NODE_STATUS: 'node_status',
44
USERS_STATUS: 'users_status',
5+
USERS_ONLINE_STATS: 'users_online_stats',
56
USERS_TOTAL: 'users_total',
67
NODE_INBOUND_UPLOAD_BYTES: 'node_inbound_upload_bytes',
78
NODE_INBOUND_DOWNLOAD_BYTES: 'node_inbound_download_bytes',

src/scheduler/metrics-providers.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ export const METRIC_PROVIDERS = [
1818
help: 'Counter for users statuses, updated every 1 minute',
1919
labelNames: ['status'],
2020
}),
21+
makeGaugeProvider({
22+
name: METRIC_NAMES.USERS_ONLINE_STATS,
23+
help: 'Counter for online stats of distinct users, updated every 1 minute',
24+
labelNames: ['metricType'],
25+
}),
2126
makeGaugeProvider({
2227
name: METRIC_NAMES.USERS_TOTAL,
2328
help: 'Total number of users, updated every 1 minute',

src/scheduler/tasks/export-metrics/export-metrics.task.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export class ExportMetricsTask {
6060

6161
constructor(
6262
@InjectMetric(METRIC_NAMES.USERS_STATUS) public usersStatus: Gauge<string>,
63+
@InjectMetric(METRIC_NAMES.USERS_ONLINE_STATS) public usersOnlineStats: Gauge<string>,
6364
@InjectMetric(METRIC_NAMES.USERS_TOTAL) public usersTotal: Gauge<string>,
6465
@InjectMetric(METRIC_NAMES.NODE_ONLINE_USERS) public nodeOnlineUsers: Gauge<string>,
6566
@InjectMetric(METRIC_NAMES.NODE_STATUS) public nodeStatus: Gauge<string>,
@@ -141,6 +142,10 @@ export class ExportMetricsTask {
141142
this.usersStatus.set({ status }, count);
142143
});
143144

145+
Object.entries(stats.onlineStats).forEach(([metricType, value]) => {
146+
this.usersOnlineStats.set({ metricType }, value);
147+
});
148+
144149
this.usersTotal.set({ type: 'all' }, stats.statusCounts.totalUsers);
145150

146151
// this.logger.debug(

0 commit comments

Comments
 (0)