|
4 | 4 | Gauge, |
5 | 5 | Histogram, |
6 | 6 | Registry, |
| 7 | + Summary, |
7 | 8 | } from 'prom-client'; |
8 | 9 |
|
9 | 10 | const register = new Registry(); |
@@ -70,6 +71,182 @@ const redisCacheOperations = new Counter({ |
70 | 71 | registers: [register], |
71 | 72 | }); |
72 | 73 |
|
| 74 | +const createChannelCounter = new Counter({ |
| 75 | + name: 'create_channel_total', |
| 76 | + help: 'Total number of create_channel events', |
| 77 | + labelNames: [], |
| 78 | + registers: [register], |
| 79 | +}); |
| 80 | + |
| 81 | +const createChannelErrorCounter = new Counter({ |
| 82 | + name: 'create_channel_error_total', |
| 83 | + help: 'Total number of create_channel errors', |
| 84 | + labelNames: [], |
| 85 | + registers: [register], |
| 86 | +}); |
| 87 | + |
| 88 | +const ackCounter = new Counter({ |
| 89 | + name: 'ack_total', |
| 90 | + help: 'Total number of ack events', |
| 91 | + labelNames: [], |
| 92 | + registers: [register], |
| 93 | +}); |
| 94 | + |
| 95 | +const ackErrorCounter = new Counter({ |
| 96 | + name: 'ack_error_total', |
| 97 | + help: 'Total number of ack errors', |
| 98 | + labelNames: [], |
| 99 | + registers: [register], |
| 100 | +}); |
| 101 | + |
| 102 | +const messageCounter = new Counter({ |
| 103 | + name: 'message_total', |
| 104 | + help: 'Total number of message events', |
| 105 | + labelNames: [], |
| 106 | + registers: [register], |
| 107 | +}); |
| 108 | + |
| 109 | +const messageErrorCounter = new Counter({ |
| 110 | + name: 'message_error_total', |
| 111 | + help: 'Total number of message errors', |
| 112 | + labelNames: [], |
| 113 | + registers: [register], |
| 114 | +}); |
| 115 | + |
| 116 | +const pingCounter = new Counter({ |
| 117 | + name: 'ping_total', |
| 118 | + help: 'Total number of ping events', |
| 119 | + labelNames: [], |
| 120 | + registers: [register], |
| 121 | +}); |
| 122 | + |
| 123 | +const pingErrorCounter = new Counter({ |
| 124 | + name: 'ping_error_total', |
| 125 | + help: 'Total number of ping errors', |
| 126 | + labelNames: [], |
| 127 | + registers: [register], |
| 128 | +}); |
| 129 | + |
| 130 | +const joinChannelCounter = new Counter({ |
| 131 | + name: 'join_channel_total', |
| 132 | + help: 'Total number of join_channel events', |
| 133 | + labelNames: [], |
| 134 | + registers: [register], |
| 135 | +}); |
| 136 | + |
| 137 | +const joinChannelErrorCounter = new Counter({ |
| 138 | + name: 'join_channel_error_total', |
| 139 | + help: 'Total number of join_channel errors', |
| 140 | + labelNames: [], |
| 141 | + registers: [register], |
| 142 | +}); |
| 143 | + |
| 144 | +const rejectedCounter = new Counter({ |
| 145 | + name: 'rejected_total', |
| 146 | + help: 'Total number of rejected events', |
| 147 | + labelNames: [], |
| 148 | + registers: [register], |
| 149 | +}); |
| 150 | + |
| 151 | +const rejectedErrorCounter = new Counter({ |
| 152 | + name: 'rejected_error_total', |
| 153 | + help: 'Total number of rejected errors', |
| 154 | + labelNames: [], |
| 155 | + registers: [register], |
| 156 | +}); |
| 157 | + |
| 158 | +const leaveChannelCounter = new Counter({ |
| 159 | + name: 'leave_channel_total', |
| 160 | + help: 'Total number of leave_channel events', |
| 161 | + labelNames: [], |
| 162 | + registers: [register], |
| 163 | +}); |
| 164 | + |
| 165 | +const leaveChannelErrorCounter = new Counter({ |
| 166 | + name: 'leave_channel_error_total', |
| 167 | + help: 'Total number of leave_channel errors', |
| 168 | + labelNames: [], |
| 169 | + registers: [register], |
| 170 | +}); |
| 171 | + |
| 172 | +const checkRoomCounter = new Counter({ |
| 173 | + name: 'check_room_total', |
| 174 | + help: 'Total number of check_room events', |
| 175 | + labelNames: [], |
| 176 | + registers: [register], |
| 177 | +}); |
| 178 | + |
| 179 | +const checkRoomErrorCounter = new Counter({ |
| 180 | + name: 'check_room_error_total', |
| 181 | + help: 'Total number of check_room errors', |
| 182 | + labelNames: [], |
| 183 | + registers: [register], |
| 184 | +}); |
| 185 | + |
| 186 | +const createChannelDuration = new Summary({ |
| 187 | + name: 'create_channel_duration_milliseconds', |
| 188 | + help: 'Duration of create_channel events in milliseconds', |
| 189 | + labelNames: [], |
| 190 | + percentiles: [0.5, 0.9, 0.99], // Reports median, 90th and 99th percentiles |
| 191 | + registers: [register], |
| 192 | +}); |
| 193 | + |
| 194 | +const ackDuration = new Summary({ |
| 195 | + name: 'ack_duration_milliseconds', |
| 196 | + help: 'Duration of ack events in milliseconds', |
| 197 | + labelNames: [], |
| 198 | + percentiles: [0.5, 0.9, 0.99], |
| 199 | + registers: [register], |
| 200 | +}); |
| 201 | + |
| 202 | +const messageDuration = new Summary({ |
| 203 | + name: 'message_duration_milliseconds', |
| 204 | + help: 'Duration of message events in milliseconds', |
| 205 | + labelNames: [], |
| 206 | + percentiles: [0.5, 0.9, 0.99], |
| 207 | + registers: [register], |
| 208 | +}); |
| 209 | + |
| 210 | +const pingDuration = new Summary({ |
| 211 | + name: 'ping_duration_milliseconds', |
| 212 | + help: 'Duration of ping events in milliseconds', |
| 213 | + labelNames: [], |
| 214 | + percentiles: [0.5, 0.9, 0.99], |
| 215 | + registers: [register], |
| 216 | +}); |
| 217 | + |
| 218 | +const joinChannelDuration = new Summary({ |
| 219 | + name: 'join_channel_duration_milliseconds', |
| 220 | + help: 'Duration of join_channel events in milliseconds', |
| 221 | + labelNames: [], |
| 222 | + percentiles: [0.5, 0.9, 0.99], |
| 223 | + registers: [register], |
| 224 | +}); |
| 225 | + |
| 226 | +const rejectedDuration = new Summary({ |
| 227 | + name: 'rejected_duration_milliseconds', |
| 228 | + help: 'Duration of rejected events in milliseconds', |
| 229 | + labelNames: [], |
| 230 | + percentiles: [0.5, 0.9, 0.99], |
| 231 | + registers: [register], |
| 232 | +}); |
| 233 | + |
| 234 | +const leaveChannelDuration = new Summary({ |
| 235 | + name: 'leave_channel_duration_milliseconds', |
| 236 | + help: 'Duration of leave_channel events in milliseconds', |
| 237 | + labelNames: [], |
| 238 | + percentiles: [0.5, 0.9, 0.99], |
| 239 | + registers: [register], |
| 240 | +}); |
| 241 | + |
| 242 | +const checkRoomDuration = new Summary({ |
| 243 | + name: 'check_room_duration_milliseconds', |
| 244 | + help: 'Duration of check_room events in milliseconds', |
| 245 | + labelNames: [], |
| 246 | + percentiles: [0.5, 0.9, 0.99], |
| 247 | + registers: [register], |
| 248 | +}); |
| 249 | + |
73 | 250 | export function setSocketIoServerTotalClients(count: number) { |
74 | 251 | socketIoServerTotalClients.set(count); |
75 | 252 | } |
@@ -112,3 +289,99 @@ export function incrementRedisCacheOperation( |
112 | 289 | ) { |
113 | 290 | redisCacheOperations.inc({ operation, result: isHit ? 'hit' : 'miss' }); |
114 | 291 | } |
| 292 | + |
| 293 | +export function incrementCreateChannel() { |
| 294 | + createChannelCounter.inc(); |
| 295 | +} |
| 296 | + |
| 297 | +export function incrementCreateChannelError() { |
| 298 | + createChannelErrorCounter.inc(); |
| 299 | +} |
| 300 | + |
| 301 | +export function incrementAck() { |
| 302 | + ackCounter.inc(); |
| 303 | +} |
| 304 | + |
| 305 | +export function incrementAckError() { |
| 306 | + ackErrorCounter.inc(); |
| 307 | +} |
| 308 | + |
| 309 | +export function incrementMessage() { |
| 310 | + messageCounter.inc(); |
| 311 | +} |
| 312 | + |
| 313 | +export function incrementMessageError() { |
| 314 | + messageErrorCounter.inc(); |
| 315 | +} |
| 316 | + |
| 317 | +export function incrementPing() { |
| 318 | + pingCounter.inc(); |
| 319 | +} |
| 320 | + |
| 321 | +export function incrementPingError() { |
| 322 | + pingErrorCounter.inc(); |
| 323 | +} |
| 324 | + |
| 325 | +export function incrementJoinChannel() { |
| 326 | + joinChannelCounter.inc(); |
| 327 | +} |
| 328 | + |
| 329 | +export function incrementJoinChannelError() { |
| 330 | + joinChannelErrorCounter.inc(); |
| 331 | +} |
| 332 | + |
| 333 | +export function incrementRejected() { |
| 334 | + rejectedCounter.inc(); |
| 335 | +} |
| 336 | + |
| 337 | +export function incrementRejectedError() { |
| 338 | + rejectedErrorCounter.inc(); |
| 339 | +} |
| 340 | + |
| 341 | +export function incrementLeaveChannel() { |
| 342 | + leaveChannelCounter.inc(); |
| 343 | +} |
| 344 | + |
| 345 | +export function incrementLeaveChannelError() { |
| 346 | + leaveChannelErrorCounter.inc(); |
| 347 | +} |
| 348 | + |
| 349 | +export function incrementCheckRoom() { |
| 350 | + checkRoomCounter.inc(); |
| 351 | +} |
| 352 | + |
| 353 | +export function incrementCheckRoomError() { |
| 354 | + checkRoomErrorCounter.inc(); |
| 355 | +} |
| 356 | + |
| 357 | +export function observeCreateChannelDuration(duration: number) { |
| 358 | + createChannelDuration.observe(duration); |
| 359 | +} |
| 360 | + |
| 361 | +export function observeAckDuration(duration: number) { |
| 362 | + ackDuration.observe(duration); |
| 363 | +} |
| 364 | + |
| 365 | +export function observeMessageDuration(duration: number) { |
| 366 | + messageDuration.observe(duration); |
| 367 | +} |
| 368 | + |
| 369 | +export function observePingDuration(duration: number) { |
| 370 | + pingDuration.observe(duration); |
| 371 | +} |
| 372 | + |
| 373 | +export function observeJoinChannelDuration(duration: number) { |
| 374 | + joinChannelDuration.observe(duration); |
| 375 | +} |
| 376 | + |
| 377 | +export function observeRejectedDuration(duration: number) { |
| 378 | + rejectedDuration.observe(duration); |
| 379 | +} |
| 380 | + |
| 381 | +export function observeLeaveChannelDuration(duration: number) { |
| 382 | + leaveChannelDuration.observe(duration); |
| 383 | +} |
| 384 | + |
| 385 | +export function observeCheckRoomDuration(duration: number) { |
| 386 | + checkRoomDuration.observe(duration); |
| 387 | +} |
0 commit comments