@chainlink/external-adapter-framework 0.18.0 → 0.19.0
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.
- package/adapter/basic.js +10 -31
- package/adapter/basic.js.map +1 -1
- package/background-executor.js +4 -26
- package/background-executor.js.map +1 -1
- package/cache/metrics.d.ts +1 -7
- package/cache/metrics.js +10 -102
- package/cache/metrics.js.map +1 -1
- package/cache/redis.d.ts +3 -4
- package/cache/redis.js +13 -37
- package/cache/redis.js.map +1 -1
- package/index.d.ts +0 -5
- package/index.js +2 -33
- package/index.js.map +1 -1
- package/metrics/index.d.ts +43 -5
- package/metrics/index.js +194 -31
- package/metrics/index.js.map +1 -1
- package/package.json +3 -3
- package/rate-limiting/metrics.d.ts +0 -2
- package/rate-limiting/metrics.js +1 -30
- package/rate-limiting/metrics.js.map +1 -1
- package/transports/abstract/subscription.js +3 -25
- package/transports/abstract/subscription.js.map +1 -1
- package/transports/http.js +7 -33
- package/transports/http.js.map +1 -1
- package/transports/metrics.d.ts +0 -9
- package/transports/metrics.js +8 -74
- package/transports/metrics.js.map +1 -1
- package/transports/websocket.js +7 -35
- package/transports/websocket.js.map +1 -1
- package/util/metrics.d.ts +7 -8
- package/util/metrics.js +22 -25
- package/util/metrics.js.map +1 -1
- package/util/requester.js +11 -32
- package/util/requester.js.map +1 -1
package/metrics/index.d.ts
CHANGED
|
@@ -12,8 +12,46 @@ export declare const setupMetrics: (name: string) => void;
|
|
|
12
12
|
* @returns the cache middleware function
|
|
13
13
|
*/
|
|
14
14
|
export declare const buildMetricsMiddleware: (req: AdapterRequest, res: FastifyReply, done: HookHandlerDoneFunction) => void;
|
|
15
|
-
export declare
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
export declare class Metrics<T extends Record<string, unknown>> {
|
|
16
|
+
private metricsDefinition;
|
|
17
|
+
private metrics?;
|
|
18
|
+
constructor(metricsDefinition: () => T);
|
|
19
|
+
initialize(): void;
|
|
20
|
+
get<K extends keyof T>(name: K): T[K];
|
|
21
|
+
}
|
|
22
|
+
export declare const buildHttpRequestMetricsLabel: (feedId: string, error?: AdapterError | Error, cacheHit?: boolean) => Record<string, string | number | undefined>;
|
|
23
|
+
export declare const dataProviderMetricsLabel: (providerStatusCode?: number, method?: string) => {
|
|
24
|
+
provider_status_code: number | undefined;
|
|
25
|
+
method: string;
|
|
26
|
+
};
|
|
27
|
+
export declare const retrieveCost: <ProviderResponseBody>(data: ProviderResponseBody) => number;
|
|
28
|
+
export declare const metrics: Metrics<{
|
|
29
|
+
httpRequestsTotal: client.Counter<"type" | "method" | "status_code" | "retry" | "is_cache_warming" | "feed_id" | "provider_status_code">;
|
|
30
|
+
httpRequestDurationSeconds: client.Histogram<string>;
|
|
31
|
+
dataProviderRequests: client.Counter<"method" | "provider_status_code">;
|
|
32
|
+
dataProviderRequestDurationSeconds: client.Histogram<string>;
|
|
33
|
+
requesterQueueSize: client.Gauge<string>;
|
|
34
|
+
requesterQueueOverflow: client.Counter<string>;
|
|
35
|
+
bgExecuteSubscriptionSetCount: client.Gauge<"endpoint" | "transport_type">;
|
|
36
|
+
bgExecuteTotal: client.Counter<"endpoint">;
|
|
37
|
+
bgExecuteDurationSeconds: client.Gauge<"endpoint">;
|
|
38
|
+
cacheDataGetCount: client.Counter<"feed_id" | "participant_id" | "cache_type" | "is_from_ws" | "experimental">;
|
|
39
|
+
cacheDataGetValues: client.Gauge<"feed_id" | "participant_id" | "cache_type" | "is_from_ws" | "experimental">;
|
|
40
|
+
cacheDataMaxAge: client.Gauge<"feed_id" | "participant_id" | "cache_type" | "is_from_ws" | "experimental">;
|
|
41
|
+
cacheDataSetCount: client.Counter<"status_code" | "feed_id" | "participant_id" | "cache_type" | "is_from_ws" | "experimental">;
|
|
42
|
+
cacheDataStalenessSeconds: client.Gauge<"feed_id" | "participant_id" | "cache_type" | "is_from_ws" | "experimental">;
|
|
43
|
+
totalDataStalenessSeconds: client.Gauge<"feed_id" | "participant_id" | "cache_type" | "is_from_ws" | "experimental">;
|
|
44
|
+
providerTimeDelta: client.Gauge<"feed_id">;
|
|
45
|
+
redisConnectionsOpen: client.Counter<string>;
|
|
46
|
+
redisRetriesCount: client.Counter<string>;
|
|
47
|
+
redisCommandsSentCount: client.Counter<"status" | "function_name">;
|
|
48
|
+
cacheWarmerCount: client.Gauge<"isBatched">;
|
|
49
|
+
wsConnectionActive: client.Gauge<"url">;
|
|
50
|
+
wsConnectionErrors: client.Counter<"message" | "url">;
|
|
51
|
+
wsSubscriptionActive: client.Gauge<"feed_id" | "connection_url" | "subscription_key">;
|
|
52
|
+
wsSubscriptionTotal: client.Counter<"feed_id" | "connection_url" | "subscription_key">;
|
|
53
|
+
wsMessageTotal: client.Counter<"direction" | "feed_id" | "subscription_key">;
|
|
54
|
+
transportPollingFailureCount: client.Counter<"endpoint">;
|
|
55
|
+
transportPollingDurationSeconds: client.Gauge<"succeeded" | "endpoint">;
|
|
56
|
+
rateLimitCreditsSpentTotal: client.Counter<"feed_id" | "participant_id">;
|
|
57
|
+
}>;
|
package/metrics/index.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
29
|
+
exports.metrics = exports.retrieveCost = exports.dataProviderMetricsLabel = exports.buildHttpRequestMetricsLabel = exports.Metrics = exports.buildMetricsMiddleware = exports.setupMetrics = exports.setupMetricsServer = void 0;
|
|
30
30
|
const client = __importStar(require("prom-client"));
|
|
31
31
|
const constants_1 = require("./constants");
|
|
32
32
|
const util_1 = require("../util");
|
|
@@ -75,13 +75,49 @@ const buildMetricsMiddleware = (req, res, done) => {
|
|
|
75
75
|
const feedId = req.requestContext?.meta?.metrics?.feedId || 'N/A';
|
|
76
76
|
const labels = (0, exports.buildHttpRequestMetricsLabel)(feedId, req.requestContext?.meta?.error, req.requestContext?.meta?.metrics?.cacheHit);
|
|
77
77
|
// Record number of requests sent to EA
|
|
78
|
-
exports.httpRequestsTotal.labels(labels).inc();
|
|
78
|
+
exports.metrics.get('httpRequestsTotal').labels(labels).inc();
|
|
79
79
|
// Record response time of request through entire EA
|
|
80
|
-
exports.httpRequestDurationSeconds.observe(res.getResponseTime() / 1000);
|
|
80
|
+
exports.metrics.get('httpRequestDurationSeconds').observe(res.getResponseTime() / 1000);
|
|
81
81
|
logger.debug(`Response time for ${feedId}: ${res.getResponseTime()}ms`);
|
|
82
82
|
done();
|
|
83
83
|
};
|
|
84
84
|
exports.buildMetricsMiddleware = buildMetricsMiddleware;
|
|
85
|
+
class Metrics {
|
|
86
|
+
constructor(metricsDefinition) {
|
|
87
|
+
this.metricsDefinition = metricsDefinition;
|
|
88
|
+
}
|
|
89
|
+
// Register metrics and set the metrics map for use during runtime
|
|
90
|
+
// Ideally called on adapter startup to avoid metrics conflicts
|
|
91
|
+
initialize() {
|
|
92
|
+
if (!this.metrics) {
|
|
93
|
+
this.metrics = this.metricsDefinition();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
get(name) {
|
|
97
|
+
const metric = this.metrics?.[name];
|
|
98
|
+
if (!metric) {
|
|
99
|
+
throw new Error(`Metric "${name}" was not initialized before use`);
|
|
100
|
+
}
|
|
101
|
+
return metric;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.Metrics = Metrics;
|
|
105
|
+
const httpRequestsTotalLabels = [
|
|
106
|
+
'method',
|
|
107
|
+
'status_code',
|
|
108
|
+
'retry',
|
|
109
|
+
'type',
|
|
110
|
+
'is_cache_warming',
|
|
111
|
+
'feed_id',
|
|
112
|
+
'provider_status_code',
|
|
113
|
+
];
|
|
114
|
+
const cacheMetricsLabels = [
|
|
115
|
+
'feed_id',
|
|
116
|
+
'participant_id',
|
|
117
|
+
'cache_type',
|
|
118
|
+
'is_from_ws',
|
|
119
|
+
'experimental',
|
|
120
|
+
];
|
|
85
121
|
const buildHttpRequestMetricsLabel = (feedId, error, cacheHit) => {
|
|
86
122
|
const labels = {};
|
|
87
123
|
labels.method = 'POST';
|
|
@@ -111,33 +147,160 @@ const buildHttpRequestMetricsLabel = (feedId, error, cacheHit) => {
|
|
|
111
147
|
return labels;
|
|
112
148
|
};
|
|
113
149
|
exports.buildHttpRequestMetricsLabel = buildHttpRequestMetricsLabel;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
'method',
|
|
119
|
-
'status_code',
|
|
120
|
-
'retry',
|
|
121
|
-
'type',
|
|
122
|
-
'is_cache_warming',
|
|
123
|
-
'feed_id',
|
|
124
|
-
'provider_status_code',
|
|
125
|
-
],
|
|
126
|
-
});
|
|
127
|
-
exports.httpRequestDurationSeconds = new client.Histogram({
|
|
128
|
-
name: 'http_request_duration_seconds',
|
|
129
|
-
help: 'A histogram bucket of the distribution of http request durations',
|
|
130
|
-
buckets: constants_1.requestDurationBuckets,
|
|
131
|
-
});
|
|
132
|
-
// V3 specific metrics
|
|
133
|
-
exports.bgExecuteTotal = new client.Counter({
|
|
134
|
-
name: 'bg_execute_total',
|
|
135
|
-
help: 'The number of background executes performed per endpoint',
|
|
136
|
-
labelNames: ['endpoint'],
|
|
137
|
-
});
|
|
138
|
-
exports.bgExecuteDurationSeconds = new client.Gauge({
|
|
139
|
-
name: 'bg_execute_duration_seconds',
|
|
140
|
-
help: 'A histogram bucket of the distribution of background execute durations',
|
|
141
|
-
labelNames: ['endpoint'],
|
|
150
|
+
// Data Provider Requests Metrics
|
|
151
|
+
const dataProviderMetricsLabel = (providerStatusCode, method = 'get') => ({
|
|
152
|
+
provider_status_code: providerStatusCode,
|
|
153
|
+
method: method.toUpperCase(),
|
|
142
154
|
});
|
|
155
|
+
exports.dataProviderMetricsLabel = dataProviderMetricsLabel;
|
|
156
|
+
// Retrieve cost field from response if exists
|
|
157
|
+
// If not return default cost of 1
|
|
158
|
+
const retrieveCost = (data) => {
|
|
159
|
+
const cost = data?.['cost'];
|
|
160
|
+
if (typeof cost === 'number' || typeof cost === 'string') {
|
|
161
|
+
return Number(cost);
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
return 1;
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
exports.retrieveCost = retrieveCost;
|
|
168
|
+
exports.metrics = new Metrics(() => ({
|
|
169
|
+
httpRequestsTotal: new client.Counter({
|
|
170
|
+
name: 'http_requests_total',
|
|
171
|
+
help: 'The number of http requests this external adapter has serviced for its entire uptime',
|
|
172
|
+
labelNames: httpRequestsTotalLabels,
|
|
173
|
+
}),
|
|
174
|
+
httpRequestDurationSeconds: new client.Histogram({
|
|
175
|
+
name: 'http_request_duration_seconds',
|
|
176
|
+
help: 'A histogram bucket of the distribution of http request durations',
|
|
177
|
+
buckets: constants_1.requestDurationBuckets,
|
|
178
|
+
}),
|
|
179
|
+
dataProviderRequests: new client.Counter({
|
|
180
|
+
name: 'data_provider_requests',
|
|
181
|
+
help: 'The number of http requests that are made to a data provider',
|
|
182
|
+
labelNames: ['method', 'provider_status_code'],
|
|
183
|
+
}),
|
|
184
|
+
dataProviderRequestDurationSeconds: new client.Histogram({
|
|
185
|
+
name: 'data_provider_request_duration_seconds',
|
|
186
|
+
help: 'A histogram bucket of the distribution of data provider request durations',
|
|
187
|
+
buckets: constants_1.requestDurationBuckets,
|
|
188
|
+
}),
|
|
189
|
+
requesterQueueSize: new client.Gauge({
|
|
190
|
+
name: 'requester_queue_size',
|
|
191
|
+
help: 'The number of provider http requests currently queued to be executed',
|
|
192
|
+
}),
|
|
193
|
+
requesterQueueOverflow: new client.Counter({
|
|
194
|
+
name: 'requester_queue_overflow',
|
|
195
|
+
help: 'Total times the requester queue replaced the oldest item to avoid an overflow',
|
|
196
|
+
}),
|
|
197
|
+
bgExecuteSubscriptionSetCount: new client.Gauge({
|
|
198
|
+
name: 'bg_execute_subscription_set_count',
|
|
199
|
+
help: 'The number of active subscriptions in background execute',
|
|
200
|
+
labelNames: ['endpoint', 'transport_type'],
|
|
201
|
+
}),
|
|
202
|
+
bgExecuteTotal: new client.Counter({
|
|
203
|
+
name: 'bg_execute_total',
|
|
204
|
+
help: 'The number of background executes performed per endpoint',
|
|
205
|
+
labelNames: ['endpoint'],
|
|
206
|
+
}),
|
|
207
|
+
bgExecuteDurationSeconds: new client.Gauge({
|
|
208
|
+
name: 'bg_execute_duration_seconds',
|
|
209
|
+
help: 'A histogram bucket of the distribution of background execute durations',
|
|
210
|
+
labelNames: ['endpoint'],
|
|
211
|
+
}),
|
|
212
|
+
cacheDataGetCount: new client.Counter({
|
|
213
|
+
name: 'cache_data_get_count',
|
|
214
|
+
help: 'A counter that increments every time a value is fetched from the cache',
|
|
215
|
+
labelNames: cacheMetricsLabels,
|
|
216
|
+
}),
|
|
217
|
+
cacheDataGetValues: new client.Gauge({
|
|
218
|
+
name: 'cache_data_get_values',
|
|
219
|
+
help: 'A gauge keeping track of values being fetched from cache',
|
|
220
|
+
labelNames: cacheMetricsLabels,
|
|
221
|
+
}),
|
|
222
|
+
cacheDataMaxAge: new client.Gauge({
|
|
223
|
+
name: 'cache_data_max_age',
|
|
224
|
+
help: 'A gauge tracking the max age of stored values in the cache',
|
|
225
|
+
labelNames: cacheMetricsLabels,
|
|
226
|
+
}),
|
|
227
|
+
cacheDataSetCount: new client.Counter({
|
|
228
|
+
name: 'cache_data_set_count',
|
|
229
|
+
help: 'A counter that increments every time a value is set to the cache',
|
|
230
|
+
labelNames: [...cacheMetricsLabels, 'status_code'],
|
|
231
|
+
}),
|
|
232
|
+
cacheDataStalenessSeconds: new client.Gauge({
|
|
233
|
+
name: 'cache_data_staleness_seconds',
|
|
234
|
+
help: 'Observes the cache staleness of the data returned (i.e., time since the data was written to the cache)',
|
|
235
|
+
labelNames: cacheMetricsLabels,
|
|
236
|
+
}),
|
|
237
|
+
totalDataStalenessSeconds: new client.Gauge({
|
|
238
|
+
name: 'total_data_staleness_seconds',
|
|
239
|
+
help: 'Observes the total staleness of the data returned (i.e., time since the provider indicated the data was sent)',
|
|
240
|
+
labelNames: cacheMetricsLabels,
|
|
241
|
+
}),
|
|
242
|
+
providerTimeDelta: new client.Gauge({
|
|
243
|
+
name: 'provider_time_delta',
|
|
244
|
+
help: 'Measures the difference between the time indicated by a DP for a value vs the time it was written to cache',
|
|
245
|
+
labelNames: ['feed_id'],
|
|
246
|
+
}),
|
|
247
|
+
redisConnectionsOpen: new client.Counter({
|
|
248
|
+
name: 'redis_connections_open',
|
|
249
|
+
help: 'The number of redis connections that are open',
|
|
250
|
+
}),
|
|
251
|
+
redisRetriesCount: new client.Counter({
|
|
252
|
+
name: 'redis_retries_count',
|
|
253
|
+
help: 'The number of retries that have been made to establish a redis connection',
|
|
254
|
+
}),
|
|
255
|
+
redisCommandsSentCount: new client.Counter({
|
|
256
|
+
name: 'redis_commands_sent_count',
|
|
257
|
+
help: 'The number of redis commands sent',
|
|
258
|
+
labelNames: ['status', 'function_name'],
|
|
259
|
+
}),
|
|
260
|
+
cacheWarmerCount: new client.Gauge({
|
|
261
|
+
name: 'cache_warmer_get_count',
|
|
262
|
+
help: 'The number of cache warmers running',
|
|
263
|
+
labelNames: ['isBatched'],
|
|
264
|
+
}),
|
|
265
|
+
wsConnectionActive: new client.Gauge({
|
|
266
|
+
name: 'ws_connection_active',
|
|
267
|
+
help: 'The number of active connections',
|
|
268
|
+
labelNames: ['url'],
|
|
269
|
+
}),
|
|
270
|
+
wsConnectionErrors: new client.Counter({
|
|
271
|
+
name: 'ws_connection_errors',
|
|
272
|
+
help: 'The number of connection errors',
|
|
273
|
+
labelNames: ['url', 'message'],
|
|
274
|
+
}),
|
|
275
|
+
wsSubscriptionActive: new client.Gauge({
|
|
276
|
+
name: 'ws_subscription_active',
|
|
277
|
+
help: 'The number of currently active subscriptions',
|
|
278
|
+
labelNames: ['connection_url', 'feed_id', 'subscription_key'],
|
|
279
|
+
}),
|
|
280
|
+
wsSubscriptionTotal: new client.Counter({
|
|
281
|
+
name: 'ws_subscription_total',
|
|
282
|
+
help: 'The number of subscriptions opened in total',
|
|
283
|
+
labelNames: ['connection_url', 'feed_id', 'subscription_key'],
|
|
284
|
+
}),
|
|
285
|
+
wsMessageTotal: new client.Counter({
|
|
286
|
+
name: 'ws_message_total',
|
|
287
|
+
help: 'The number of messages sent in total',
|
|
288
|
+
labelNames: ['feed_id', 'subscription_key', 'direction'],
|
|
289
|
+
}),
|
|
290
|
+
transportPollingFailureCount: new client.Counter({
|
|
291
|
+
name: 'transport_polling_failure_count',
|
|
292
|
+
help: 'The number of times the polling mechanism ran out of attempts and failed to return a response',
|
|
293
|
+
labelNames: ['endpoint'],
|
|
294
|
+
}),
|
|
295
|
+
transportPollingDurationSeconds: new client.Gauge({
|
|
296
|
+
name: 'transport_polling_duration_seconds',
|
|
297
|
+
help: 'A histogram bucket of the distribution of transport polling idle time durations',
|
|
298
|
+
labelNames: ['endpoint', 'succeeded'],
|
|
299
|
+
}),
|
|
300
|
+
rateLimitCreditsSpentTotal: new client.Counter({
|
|
301
|
+
name: 'rate_limit_credits_spent_total',
|
|
302
|
+
help: 'The number of data provider credits the adapter is consuming',
|
|
303
|
+
labelNames: ['participant_id', 'feed_id'],
|
|
304
|
+
}),
|
|
305
|
+
}));
|
|
143
306
|
//# sourceMappingURL=index.js.map
|
package/metrics/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/metrics/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAqC;AACrC,2CAAqE;AACrE,kCAAoD;AAEpD,sDAAwE;AACxE,+BAA2B;AAC3B,+CAAkD;AAClD,oCAAuD;AAEvD,MAAM,MAAM,GAAG,IAAA,iBAAU,EAAC,SAAS,CAAC,CAAA;AAEpC,SAAgB,kBAAkB,CAAC,IAAY,EAAE,MAAqB;IACpE,MAAM,WAAW,GAA2C,IAAA,sBAA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AAS,EAAE,kBAAkB,EAAE,WAAW,CAAU;KAClE,CAAC;IACF,4BAA4B,EAAE,IAAI,MAAM,CAAC,OAAO,CAAC;QAC/C,IAAI,EAAE,iCAAiC;QACvC,IAAI,EAAE,+FAA+F;QACrG,UAAU,EAAE,CAAC,UAAU,CAAU;KAClC,CAAC;IACF,+BAA+B,EAAE,IAAI,MAAM,CAAC,KAAK,CAAC;QAChD,IAAI,EAAE,oCAAoC;QAC1C,IAAI,EAAE,iFAAiF;QACvF,UAAU,EAAE,CAAC,UAAU,EAAE,WAAW,CAAU;KAC/C,CAAC;IACF,0BAA0B,EAAE,IAAI,MAAM,CAAC,OAAO,CAAC;QAC7C,IAAI,EAAE,gCAAgC;QACtC,IAAI,EAAE,8DAA8D;QACpE,UAAU,EAAE,CAAC,gBAAgB,EAAE,SAAS,CAAU;KACnD,CAAC;CACH,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainlink/external-adapter-framework",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"dependencies": {
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"lint-fix": "eslint --max-warnings=0 --fix ./src && prettier --write ./src/**/*.ts ./*.{json,js,yaml}",
|
|
22
22
|
"lint": "eslint --max-warnings=0 ./src && prettier --check ./src/**/*.ts ./*.{json,js,yaml}",
|
|
23
23
|
"start": "ts-node -e 'import(`./src/examples/${process.argv[1]}/src/index`).then(ea => ea.server())'",
|
|
24
|
-
"test-debug": "EA_HOST=localhost
|
|
25
|
-
"test": "EA_HOST=localhost
|
|
24
|
+
"test-debug": "EA_HOST=localhost LOG_LEVEL=trace DEBUG=true EA_PORT=0 c8 ava --verbose",
|
|
25
|
+
"test": "EA_HOST=localhost LOG_LEVEL=error EA_PORT=0 c8 ava",
|
|
26
26
|
"verify": "yarn lint && yarn build && yarn build -p ./test/tsconfig.json && yarn test && yarn code-coverage",
|
|
27
27
|
"code-coverage": "c8 check-coverage --statements 95 --lines 95 --functions 95 --branches 90"
|
|
28
28
|
},
|
package/rate-limiting/metrics.js
CHANGED
|
@@ -1,30 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
27
|
-
const client = __importStar(require("prom-client"));
|
|
3
|
+
exports.retrieveCost = void 0;
|
|
28
4
|
// Retrieve cost field from response if exists
|
|
29
5
|
// If not return default cost of 1
|
|
30
6
|
const retrieveCost = (data) => {
|
|
@@ -37,9 +13,4 @@ const retrieveCost = (data) => {
|
|
|
37
13
|
}
|
|
38
14
|
};
|
|
39
15
|
exports.retrieveCost = retrieveCost;
|
|
40
|
-
exports.rateLimitCreditsSpentTotal = new client.Counter({
|
|
41
|
-
name: 'rate_limit_credits_spent_total',
|
|
42
|
-
help: 'The number of data provider credits the adapter is consuming',
|
|
43
|
-
labelNames: ['participant_id', 'feed_id'],
|
|
44
|
-
});
|
|
45
16
|
//# sourceMappingURL=metrics.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../../src/rate-limiting/metrics.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../../src/rate-limiting/metrics.ts"],"names":[],"mappings":";;;AAAA,8CAA8C;AAC9C,kCAAkC;AAC3B,MAAM,YAAY,GAAG,CAAuB,IAA0B,EAAU,EAAE;IACvF,MAAM,IAAI,GAAI,IAAgC,EAAE,CAAC,MAAM,CAAC,CAAA;IACxD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QACxD,OAAO,MAAM,CAAC,IAAI,CAAC,CAAA;KACpB;SAAM;QACL,OAAO,CAAC,CAAA;KACT;AACH,CAAC,CAAA;AAPY,QAAA,YAAY,gBAOxB"}
|
|
@@ -1,31 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.SubscriptionTransport = void 0;
|
|
27
4
|
const util_1 = require("../../util");
|
|
28
|
-
const
|
|
5
|
+
const metrics_1 = require("../../metrics");
|
|
29
6
|
const logger = (0, util_1.makeLogger)('SubscriptionTransport');
|
|
30
7
|
/**
|
|
31
8
|
* Abstract Transport that will take incoming requests and add them to a subscription set as part
|
|
@@ -50,7 +27,8 @@ class SubscriptionTransport {
|
|
|
50
27
|
// Keep track of active subscriptions for background execute
|
|
51
28
|
// Note: for those coming from reasonable OOP languages, don't fret; this is JS:
|
|
52
29
|
// this.constructor.name will resolve to the instance name, not the class one (i.e., will use the implementing class' name)
|
|
53
|
-
|
|
30
|
+
metrics_1.metrics
|
|
31
|
+
.get('bgExecuteSubscriptionSetCount')
|
|
54
32
|
.labels({ endpoint: context.endpointName, transport_type: this.constructor.name })
|
|
55
33
|
.set(entries.length);
|
|
56
34
|
await this.backgroundHandler(context, entries);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription.js","sourceRoot":"","sources":["../../../../src/transports/abstract/subscription.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"subscription.js","sourceRoot":"","sources":["../../../../src/transports/abstract/sub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AAO,CAAC,MAAM,CAAC,CAAA;QAEtB,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAChD,CAAC;CAmBF;AAlED,sDAkEC"}
|
package/transports/http.js
CHANGED
|
@@ -1,35 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.HttpTransport = void 0;
|
|
27
4
|
const axios_1 = require("axios");
|
|
28
|
-
const cacheMetrics = __importStar(require("../cache/metrics"));
|
|
29
|
-
const rateLimitMetrics = __importStar(require("../rate-limiting/metrics"));
|
|
30
5
|
const util_1 = require("../util");
|
|
31
6
|
const error_1 = require("../validation/error");
|
|
32
7
|
const subscription_1 = require("./abstract/subscription");
|
|
8
|
+
const metrics_1 = require("../metrics");
|
|
33
9
|
const WARMUP_BATCH_REQUEST_ID = '9002';
|
|
34
10
|
const logger = (0, util_1.makeLogger)('HttpTransport');
|
|
35
11
|
/**
|
|
@@ -62,7 +38,7 @@ class HttpTransport extends subscription_1.SubscriptionTransport {
|
|
|
62
38
|
logger.debug(`No entries in subscription set, sleeping for ${context.adapterConfig.BACKGROUND_EXECUTE_MS_HTTP}ms...`);
|
|
63
39
|
if (this.WARMER_ACTIVE) {
|
|
64
40
|
// Decrement count when warmer changed from having entries to having none
|
|
65
|
-
|
|
41
|
+
metrics_1.metrics.get('cacheWarmerCount').labels({ isBatched: 'true' }).dec();
|
|
66
42
|
this.WARMER_ACTIVE = false;
|
|
67
43
|
}
|
|
68
44
|
await (0, util_1.sleep)(context.adapterConfig.BACKGROUND_EXECUTE_MS_HTTP);
|
|
@@ -70,7 +46,7 @@ class HttpTransport extends subscription_1.SubscriptionTransport {
|
|
|
70
46
|
}
|
|
71
47
|
else if (this.WARMER_ACTIVE === false) {
|
|
72
48
|
// Increment count when warmer changed from having no entries to having some
|
|
73
|
-
|
|
49
|
+
metrics_1.metrics.get('cacheWarmerCount').labels({ isBatched: 'true' }).inc();
|
|
74
50
|
this.WARMER_ACTIVE = true;
|
|
75
51
|
}
|
|
76
52
|
logger.trace(`Have ${entries.length} entries in batch, preparing requests...`);
|
|
@@ -128,12 +104,10 @@ class HttpTransport extends subscription_1.SubscriptionTransport {
|
|
|
128
104
|
return result;
|
|
129
105
|
});
|
|
130
106
|
// Record cost of data provider call
|
|
131
|
-
const cost =
|
|
132
|
-
|
|
133
|
-
.
|
|
134
|
-
feed_id: 'N/A',
|
|
135
|
-
participant_id: WARMUP_BATCH_REQUEST_ID,
|
|
136
|
-
})
|
|
107
|
+
const cost = (0, metrics_1.retrieveCost)(requesterResult.response.data);
|
|
108
|
+
metrics_1.metrics
|
|
109
|
+
.get('rateLimitCreditsSpentTotal')
|
|
110
|
+
.labels({ feed_id: 'N/A', participant_id: WARMUP_BATCH_REQUEST_ID })
|
|
137
111
|
.inc(cost);
|
|
138
112
|
return results;
|
|
139
113
|
}
|
package/transports/http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../../src/transports/http.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../../src/transports/http.ts"],"names":[],"mappings":";;;AAAA,iCAAqE;AAGrE,kCAA2C;AAG3C,+CAAqF;AAErF,0DAA+D;AAC/D,wCAAkD;AAElD,MAAM,uBAAuB,GAAG,MAAM,CAAA;AAEtC,MAAM,MAAM,GAAG,IAAA,iBAAU,EAAC,eAAe,CAAC,CAAA;AA4E1C;;;;;;;;;GASG;AACH,MAAa,aAA+C,SAAQ,oCAAwB;IAM1F,YAAoB,MAA8B;QAChD,KAAK,EAAE,CAAA;QADW,WAAM,GAAN,MAAM,CAAwB;QALlD,uGAAuG;QACvG,gEAAgE;QAChE,kBAAa,GAAG,KAAK,CAAA;IAKrB,CAAC;IAEQ,KAAK,CAAC,UAAU,CACvB,YAAsC,EACtC,MAA0C,EAC1C,YAAoB;QAEpB,MAAM,KAAK,CAAC,UAAU,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,CAAC,CAAA;QAC1D,IAAI,CAAC,SAAS,GAAG,YAAY,CAAC,SAAS,CAAA;IACzC,CAAC;IAED,4BAA4B,CAAC,MAA0C;QACrE,OAAO,MAAM,CAAC,uBAAuB,CAAA;IACvC,CAAC;IAED,KAAK,CAAC,iBAAiB,CACrB,OAA2B,EAC3B,OAAiC;QAEjC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YACnB,MAAM,CAAC,KAAK,CACV,gDAAgD,OAAO,CAAC,aAAa,CAAC,0BAA0B,OAAO,CACxG,CAAA;YACD,IAAI,IAAI,CAAC,aAAa,EAAE;gBACtB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iBAAM,IAAI,CAAC,YAAY,6BAAqB,EAAE;gBAC7C,MAAM,GAAG,GAAG,CAA0B,CAAA;gBACtC,OAAO,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;oBAC1C,MAAM,EAAE,KAAK;oBACb,QAAQ,EAAE;wBACR,YAAY,EAAE,GAAG,CAAC,OAAO;wBACzB,UAAU,EAAE,GAAG;wBACf,UAAU,EAAE;4BACV,oBAAoB,EAAE,CAAC;4BACvB,qBAAqB,EAAE,CAAC;4BACxB,qBAAqB,EAAE,SAAS;yBACjC;qBACF;iBACF,CAAC,CAAC,CAAA;aACJ;iBAAM;gBACL,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;gBACf,OAAO,EAAE,CAAA;aACV;SACF;IACH,CAAC;CACF;AAhKD,sCAgKC"}
|
package/transports/metrics.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as client from 'prom-client';
|
|
2
1
|
import { TransportGenerics } from '.';
|
|
3
2
|
import { EndpointContext } from '../adapter';
|
|
4
3
|
import { AdapterConfig } from '../config';
|
|
@@ -16,11 +15,3 @@ export declare const messageSubsLabels: <T extends TransportGenerics>(context: {
|
|
|
16
15
|
subscription_key: string;
|
|
17
16
|
};
|
|
18
17
|
export declare const recordWsMessageMetrics: <T extends TransportGenerics>(context: EndpointContext<T>, subscribes: T["Request"]["Params"][], unsubscribes: T["Request"]["Params"][]) => void;
|
|
19
|
-
export declare const wsConnectionActive: client.Gauge<"url">;
|
|
20
|
-
export declare const wsConnectionErrors: client.Counter<"message" | "url">;
|
|
21
|
-
export declare const wsSubscriptionActive: client.Gauge<"feed_id" | "subscription_key" | "connection_url">;
|
|
22
|
-
export declare const wsSubscriptionTotal: client.Counter<"feed_id" | "subscription_key" | "connection_url">;
|
|
23
|
-
export declare const wsMessageTotal: client.Counter<"direction" | "feed_id" | "subscription_key">;
|
|
24
|
-
export declare const bgExecuteSubscriptionSetCount: client.Gauge<"endpoint" | "transport_type">;
|
|
25
|
-
export declare const transportPollingFailureCount: client.Counter<"endpoint">;
|
|
26
|
-
export declare const transportPollingDurationSeconds: client.Gauge<"succeeded" | "endpoint">;
|