@adalo/metrics 0.1.113 → 0.1.115

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- const { MetricsClient } = require('.')
1
+ const { BaseMetricsClient } = require('./baseMetricsClient')
2
2
  const {
3
3
  getRedisClientType,
4
4
  REDIS_V4,
@@ -10,26 +10,25 @@ const redisConnectionStableFields = ['name', 'flags', 'cmd']
10
10
  const redisConnectionFields = ['name', 'flags', 'tot-mem', 'cmd']
11
11
 
12
12
  /**
13
- * RedisMetricsClient extends MetricsClient to collect
13
+ * RedisMetricsClient extends BaseMetricsClient to collect
14
14
  * Redis metrics periodically and push them to Prometheus Pushgateway.
15
15
  *
16
- * @extends MetricsClient
16
+ * @extends BaseMetricsClient
17
17
  */
18
- class RedisMetricsClient extends MetricsClient {
18
+ class RedisMetricsClient extends BaseMetricsClient {
19
19
  /**
20
20
  * @param {Object} options
21
21
  * @param {any} options.redisClient - Redis client instance (required)
22
- * @param {string} [options.appName] - Application name (from MetricsClient)
23
- * @param {string} [options.dynoId] - Dyno/instance ID (from MetricsClient)
24
- * @param {string} [options.processType] - Process type (from MetricsClient)
25
- * @param {boolean} [options.enabled] - Enable metrics collection (from MetricsClient)
26
- * @param {boolean} [options.logValues] - Log metrics values (from MetricsClient)
27
- * @param {string} [options.pushgatewayUrl] - PushGateway URL (from MetricsClient)
28
- * @param {string} [options.pushgatewaySecret] - PushGateway secret token (from MetricsClient)
29
- * @param {number} [options.intervalSec] - Interval in seconds for pushing metrics (from MetricsClient)
30
- * @param {boolean} [options.removeOldMetrics] - Remove old metrics by service (from MetricsClient)
31
- * @param {boolean} [options.scripDefaultMetrics] - Skip default metrics creation (from MetricsClient)
32
- * @param {function} [options.startupValidation] - Function to validate startup (from MetricsClient)
22
+ * @param {string} [options.appName] - Application name (from BaseMetricsClient)
23
+ * @param {string} [options.dynoId] - Dyno/instance ID (from BaseMetricsClient)
24
+ * @param {string} [options.processType] - Process type (from BaseMetricsClient)
25
+ * @param {boolean} [options.enabled] - Enable metrics collection (from BaseMetricsClient)
26
+ * @param {boolean} [options.logValues] - Log metrics values (from BaseMetricsClient)
27
+ * @param {string} [options.pushgatewayUrl] - PushGateway URL (from BaseMetricsClient)
28
+ * @param {string} [options.pushgatewaySecret] - PushGateway secret token (from BaseMetricsClient)
29
+ * @param {number} [options.intervalSec] - Interval in seconds for pushing metrics (from BaseMetricsClient)
30
+ * @param {boolean} [options.removeOldMetrics] - Remove old metrics by service (from BaseMetricsClient)
31
+ * @param {function} [options.startupValidation] - Function to validate startup (from BaseMetricsClient)
33
32
  */
34
33
  constructor({ redisClient, ...metricsConfig } = {}) {
35
34
  const intervalSec =
@@ -39,7 +38,6 @@ class RedisMetricsClient extends MetricsClient {
39
38
 
40
39
  super({
41
40
  ...metricsConfig,
42
- scripDefaultMetrics: true,
43
41
  processType: metricsConfig.processType || 'queue-metrics',
44
42
  intervalSec,
45
43
  })
@@ -142,14 +140,10 @@ class RedisMetricsClient extends MetricsClient {
142
140
  .split('\n')
143
141
  .filter(line => line.trim() !== '')
144
142
  .map(line => {
145
- console.log("parseRedisConnections line: ", line)
146
143
  const parts = line.split(' ')
147
144
  const client = {}
148
- console.log("parseRedisConnections parts: ", parts)
149
-
150
145
  parts.forEach(p => {
151
146
  const [k, v] = p.split('=')
152
- console.log("parseRedisConnections part includes: ", redisConnectionFields.includes(k))
153
147
  if (redisConnectionFields.includes(k)) {
154
148
  client[k] = v
155
149
  }
@@ -182,14 +176,14 @@ class RedisMetricsClient extends MetricsClient {
182
176
 
183
177
  const grouped = {}
184
178
  connections.forEach(conn => {
185
- const { name, flags, 'tot-mem': totMem } = conn
179
+ const { name, flags, 'tot-mem': totMem, cmd } = conn
186
180
 
187
181
  // build grouping key (includes default gauge labels later)
188
- const key = JSON.stringify({ name, flags })
182
+ const key = JSON.stringify({ name, flags, cmd })
189
183
 
190
184
  if (!grouped[key]) {
191
185
  grouped[key] = {
192
- labels: { name, flags },
186
+ labels: { name, flags, cmd },
193
187
  count: 0,
194
188
  memory: 0,
195
189
  }