@sentio/runtime 2.40.0-rc.3 → 2.40.0-rc.31

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentio/runtime",
3
- "version": "2.40.0-rc.3",
3
+ "version": "2.40.0-rc.31",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
package/src/db-context.ts CHANGED
@@ -8,46 +8,23 @@ import {
8
8
  ProcessStreamResponse
9
9
  } from '@sentio/protos'
10
10
  import * as process from 'node:process'
11
- import { Attributes, Counter, metrics } from '@opentelemetry/api'
12
-
11
+ import { dbMetrics } from './metrics.js'
12
+ const {
13
+ request_errors,
14
+ unsolved_requests,
15
+ request_times,
16
+ batched_request_count,
17
+ batched_total_count,
18
+ send_counts,
19
+ recv_counts
20
+ } = dbMetrics
13
21
  const STORE_BATCH_IDLE = process.env['STORE_BATCH_MAX_IDLE'] ? parseInt(process.env['STORE_BATCH_MAX_IDLE']) : 1
14
22
  const STORE_BATCH_SIZE = process.env['STORE_BATCH_SIZE'] ? parseInt(process.env['STORE_BATCH_SIZE']) : 10
15
23
 
16
24
  type Request = Omit<DBRequest, 'opId'>
17
25
  type RequestType = keyof Request
18
26
 
19
- const meter = metrics.getMeter('processor_store')
20
- const send_counts: Record<RequestType, Counter<Attributes>> = {
21
- get: meter.createCounter('store_get_count'),
22
- upsert: meter.createCounter('store_upsert_count'),
23
- list: meter.createCounter('store_list_count'),
24
- delete: meter.createCounter('store_delete_count')
25
- }
26
- const recv_counts: Record<RequestType, Counter<Attributes>> = {
27
- get: meter.createCounter('store_get_count'),
28
- upsert: meter.createCounter('store_upsert_count'),
29
- list: meter.createCounter('store_list_count'),
30
- delete: meter.createCounter('store_delete_count')
31
- }
32
- const request_times: Record<RequestType, Counter<Attributes>> = {
33
- get: meter.createCounter('store_get_time'),
34
- upsert: meter.createCounter('store_upsert_time'),
35
- list: meter.createCounter('store_list_time'),
36
- delete: meter.createCounter('store_delete_time')
37
- }
38
- const request_errors: Record<RequestType, Counter<Attributes>> = {
39
- get: meter.createCounter('store_get_error'),
40
- upsert: meter.createCounter('store_upsert_error'),
41
- list: meter.createCounter('store_list_error'),
42
- delete: meter.createCounter('store_delete_error')
43
- }
44
-
45
- const batched_total_count = meter.createCounter('batched_total_count')
46
- const batched_request_count = meter.createCounter('batched_request_count')
47
-
48
- const unsolved_requests = meter.createGauge('store_unsolved_requests')
49
-
50
- export const timeoutError = Symbol()
27
+ export const timeoutError = new Error('timeout')
51
28
 
52
29
  export class StoreContext {
53
30
  private static opCounter = 0n
@@ -82,7 +59,7 @@ export class StoreContext {
82
59
 
83
60
  const start = Date.now()
84
61
  const promises = [promise]
85
- console.debug('sending db request ', opId, request)
62
+ // console.debug('sending db request ', opId, request)
86
63
  let timer: NodeJS.Timeout | undefined
87
64
  if (timeoutSecs) {
88
65
  const timeoutPromise = new Promise((_r, rej) => (timer = setTimeout(rej, timeoutSecs * 1000, timeoutError)))
@@ -101,7 +78,9 @@ export class StoreContext {
101
78
 
102
79
  return Promise.race(promises)
103
80
  .then((result: DBResponse) => {
104
- console.debug('db request', requestType, 'op', opId, ' took', Date.now() - start, 'ms')
81
+ if (timeoutSecs) {
82
+ console.debug('db request', requestType, 'op', opId, ' took', Date.now() - start, 'ms')
83
+ }
105
84
  request_times[requestType]?.add(Date.now() - start)
106
85
  return result
107
86
  })
@@ -122,7 +101,7 @@ export class StoreContext {
122
101
  result(dbResult: DBResponse) {
123
102
  const opId = dbResult.opId
124
103
  const defer = this.defers.get(opId)
125
- console.debug('received db result ', opId, dbResult)
104
+ // console.debug('received db result ', opId, dbResult)
126
105
  if (defer) {
127
106
  if (defer.requestType) {
128
107
  recv_counts[defer.requestType]?.add(1)
@@ -152,8 +131,8 @@ export class StoreContext {
152
131
 
153
132
  close() {
154
133
  for (const [opId, defer] of this.defers) {
155
- console.warn('context closed before db response', opId)
156
- defer.reject(new Error('context closed'))
134
+ // console.warn('context closed before db response', opId)
135
+ defer.reject(new Error('context closed before db response, processId: ' + this.processId + ' opId: ' + opId))
157
136
  }
158
137
  this.defers.clear()
159
138
  if (this.statsInterval) {
@@ -188,21 +167,24 @@ export class StoreContext {
188
167
  this.sendBatch()
189
168
  }, STORE_BATCH_IDLE)
190
169
 
170
+ const start = Date.now()
191
171
  this.upsertBatch = {
192
172
  opId,
193
173
  request: req,
194
174
  promise,
195
- timer: timeout
175
+ timer: timeout,
196
176
  }
197
177
 
198
- return promise
178
+ return promise.finally(() => {
179
+ request_times['upsert'].add(Date.now() - start)
180
+ })
199
181
  }
200
182
  }
201
183
 
202
184
  private sendBatch() {
203
185
  if (this.upsertBatch) {
204
186
  const { request, opId, timer } = this.upsertBatch
205
- console.debug('sending batch upsert', opId, 'batch size', request?.entity.length)
187
+ // console.debug('sending batch upsert', opId, 'batch size', request?.entity.length)
206
188
  clearTimeout(timer)
207
189
  this.upsertBatch = undefined
208
190
  this.subject.next({
@@ -3,7 +3,7 @@ import Long from "long";
3
3
  import type { CallContext, CallOptions } from "nice-grpc-common";
4
4
  import _m0 from "protobufjs/minimal.js";
5
5
  import { Empty } from "../../google/protobuf/empty.js";
6
- import { ListValue, Struct, Value } from "../../google/protobuf/struct.js";
6
+ import { ListValue, Struct } from "../../google/protobuf/struct.js";
7
7
  import { Timestamp } from "../../google/protobuf/timestamp.js";
8
8
  import { BigInteger, CoinID, RichStruct, RichStructList, RichValueList } from "../../service/common/protos/common.js";
9
9
 
@@ -1069,11 +1069,14 @@ export interface ProcessResult {
1069
1069
  }
1070
1070
 
1071
1071
  export interface EthCallParam {
1072
+ context: EthCallContext | undefined;
1073
+ calldata: string;
1074
+ }
1075
+
1076
+ export interface EthCallContext {
1072
1077
  chainId: string;
1073
1078
  address: string;
1074
- function: string;
1075
- signature: string;
1076
- args: any[];
1079
+ blockTag: string;
1077
1080
  }
1078
1081
 
1079
1082
  export interface PreprocessResult {
@@ -1081,12 +1084,12 @@ export interface PreprocessResult {
1081
1084
  }
1082
1085
 
1083
1086
  export interface PreparedData {
1084
- ethCallResults: { [key: string]: Array<any> | undefined };
1087
+ ethCallResults: { [key: string]: string };
1085
1088
  }
1086
1089
 
1087
1090
  export interface PreparedData_EthCallResultsEntry {
1088
1091
  key: string;
1089
- value: Array<any> | undefined;
1092
+ value: string;
1090
1093
  }
1091
1094
 
1092
1095
  export interface RecordMetaData {
@@ -9337,25 +9340,16 @@ export const ProcessResult = {
9337
9340
  };
9338
9341
 
9339
9342
  function createBaseEthCallParam(): EthCallParam {
9340
- return { chainId: "", address: "", function: "", signature: "", args: [] };
9343
+ return { context: undefined, calldata: "" };
9341
9344
  }
9342
9345
 
9343
9346
  export const EthCallParam = {
9344
9347
  encode(message: EthCallParam, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
9345
- if (message.chainId !== "") {
9346
- writer.uint32(10).string(message.chainId);
9348
+ if (message.context !== undefined) {
9349
+ EthCallContext.encode(message.context, writer.uint32(10).fork()).ldelim();
9347
9350
  }
9348
- if (message.address !== "") {
9349
- writer.uint32(18).string(message.address);
9350
- }
9351
- if (message.function !== "") {
9352
- writer.uint32(26).string(message.function);
9353
- }
9354
- if (message.signature !== "") {
9355
- writer.uint32(34).string(message.signature);
9356
- }
9357
- for (const v of message.args) {
9358
- Value.encode(Value.wrap(v!), writer.uint32(42).fork()).ldelim();
9351
+ if (message.calldata !== "") {
9352
+ writer.uint32(18).string(message.calldata);
9359
9353
  }
9360
9354
  return writer;
9361
9355
  },
@@ -9372,35 +9366,100 @@ export const EthCallParam = {
9372
9366
  break;
9373
9367
  }
9374
9368
 
9375
- message.chainId = reader.string();
9369
+ message.context = EthCallContext.decode(reader, reader.uint32());
9376
9370
  continue;
9377
9371
  case 2:
9378
9372
  if (tag !== 18) {
9379
9373
  break;
9380
9374
  }
9381
9375
 
9382
- message.address = reader.string();
9376
+ message.calldata = reader.string();
9383
9377
  continue;
9384
- case 3:
9385
- if (tag !== 26) {
9378
+ }
9379
+ if ((tag & 7) === 4 || tag === 0) {
9380
+ break;
9381
+ }
9382
+ reader.skipType(tag & 7);
9383
+ }
9384
+ return message;
9385
+ },
9386
+
9387
+ fromJSON(object: any): EthCallParam {
9388
+ return {
9389
+ context: isSet(object.context) ? EthCallContext.fromJSON(object.context) : undefined,
9390
+ calldata: isSet(object.calldata) ? globalThis.String(object.calldata) : "",
9391
+ };
9392
+ },
9393
+
9394
+ toJSON(message: EthCallParam): unknown {
9395
+ const obj: any = {};
9396
+ if (message.context !== undefined) {
9397
+ obj.context = EthCallContext.toJSON(message.context);
9398
+ }
9399
+ if (message.calldata !== "") {
9400
+ obj.calldata = message.calldata;
9401
+ }
9402
+ return obj;
9403
+ },
9404
+
9405
+ create(base?: DeepPartial<EthCallParam>): EthCallParam {
9406
+ return EthCallParam.fromPartial(base ?? {});
9407
+ },
9408
+ fromPartial(object: DeepPartial<EthCallParam>): EthCallParam {
9409
+ const message = createBaseEthCallParam();
9410
+ message.context = (object.context !== undefined && object.context !== null)
9411
+ ? EthCallContext.fromPartial(object.context)
9412
+ : undefined;
9413
+ message.calldata = object.calldata ?? "";
9414
+ return message;
9415
+ },
9416
+ };
9417
+
9418
+ function createBaseEthCallContext(): EthCallContext {
9419
+ return { chainId: "", address: "", blockTag: "" };
9420
+ }
9421
+
9422
+ export const EthCallContext = {
9423
+ encode(message: EthCallContext, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
9424
+ if (message.chainId !== "") {
9425
+ writer.uint32(10).string(message.chainId);
9426
+ }
9427
+ if (message.address !== "") {
9428
+ writer.uint32(18).string(message.address);
9429
+ }
9430
+ if (message.blockTag !== "") {
9431
+ writer.uint32(26).string(message.blockTag);
9432
+ }
9433
+ return writer;
9434
+ },
9435
+
9436
+ decode(input: _m0.Reader | Uint8Array, length?: number): EthCallContext {
9437
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
9438
+ let end = length === undefined ? reader.len : reader.pos + length;
9439
+ const message = createBaseEthCallContext();
9440
+ while (reader.pos < end) {
9441
+ const tag = reader.uint32();
9442
+ switch (tag >>> 3) {
9443
+ case 1:
9444
+ if (tag !== 10) {
9386
9445
  break;
9387
9446
  }
9388
9447
 
9389
- message.function = reader.string();
9448
+ message.chainId = reader.string();
9390
9449
  continue;
9391
- case 4:
9392
- if (tag !== 34) {
9450
+ case 2:
9451
+ if (tag !== 18) {
9393
9452
  break;
9394
9453
  }
9395
9454
 
9396
- message.signature = reader.string();
9455
+ message.address = reader.string();
9397
9456
  continue;
9398
- case 5:
9399
- if (tag !== 42) {
9457
+ case 3:
9458
+ if (tag !== 26) {
9400
9459
  break;
9401
9460
  }
9402
9461
 
9403
- message.args.push(Value.unwrap(Value.decode(reader, reader.uint32())));
9462
+ message.blockTag = reader.string();
9404
9463
  continue;
9405
9464
  }
9406
9465
  if ((tag & 7) === 4 || tag === 0) {
@@ -9411,17 +9470,15 @@ export const EthCallParam = {
9411
9470
  return message;
9412
9471
  },
9413
9472
 
9414
- fromJSON(object: any): EthCallParam {
9473
+ fromJSON(object: any): EthCallContext {
9415
9474
  return {
9416
9475
  chainId: isSet(object.chainId) ? globalThis.String(object.chainId) : "",
9417
9476
  address: isSet(object.address) ? globalThis.String(object.address) : "",
9418
- function: isSet(object.function) ? globalThis.String(object.function) : "",
9419
- signature: isSet(object.signature) ? globalThis.String(object.signature) : "",
9420
- args: globalThis.Array.isArray(object?.args) ? [...object.args] : [],
9477
+ blockTag: isSet(object.blockTag) ? globalThis.String(object.blockTag) : "",
9421
9478
  };
9422
9479
  },
9423
9480
 
9424
- toJSON(message: EthCallParam): unknown {
9481
+ toJSON(message: EthCallContext): unknown {
9425
9482
  const obj: any = {};
9426
9483
  if (message.chainId !== "") {
9427
9484
  obj.chainId = message.chainId;
@@ -9429,28 +9486,20 @@ export const EthCallParam = {
9429
9486
  if (message.address !== "") {
9430
9487
  obj.address = message.address;
9431
9488
  }
9432
- if (message.function !== "") {
9433
- obj.function = message.function;
9434
- }
9435
- if (message.signature !== "") {
9436
- obj.signature = message.signature;
9437
- }
9438
- if (message.args?.length) {
9439
- obj.args = message.args;
9489
+ if (message.blockTag !== "") {
9490
+ obj.blockTag = message.blockTag;
9440
9491
  }
9441
9492
  return obj;
9442
9493
  },
9443
9494
 
9444
- create(base?: DeepPartial<EthCallParam>): EthCallParam {
9445
- return EthCallParam.fromPartial(base ?? {});
9495
+ create(base?: DeepPartial<EthCallContext>): EthCallContext {
9496
+ return EthCallContext.fromPartial(base ?? {});
9446
9497
  },
9447
- fromPartial(object: DeepPartial<EthCallParam>): EthCallParam {
9448
- const message = createBaseEthCallParam();
9498
+ fromPartial(object: DeepPartial<EthCallContext>): EthCallContext {
9499
+ const message = createBaseEthCallContext();
9449
9500
  message.chainId = object.chainId ?? "";
9450
9501
  message.address = object.address ?? "";
9451
- message.function = object.function ?? "";
9452
- message.signature = object.signature ?? "";
9453
- message.args = object.args?.map((e) => e) || [];
9502
+ message.blockTag = object.blockTag ?? "";
9454
9503
  return message;
9455
9504
  },
9456
9505
  };
@@ -9523,9 +9572,7 @@ function createBasePreparedData(): PreparedData {
9523
9572
  export const PreparedData = {
9524
9573
  encode(message: PreparedData, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
9525
9574
  Object.entries(message.ethCallResults).forEach(([key, value]) => {
9526
- if (value !== undefined) {
9527
- PreparedData_EthCallResultsEntry.encode({ key: key as any, value }, writer.uint32(10).fork()).ldelim();
9528
- }
9575
+ PreparedData_EthCallResultsEntry.encode({ key: key as any, value }, writer.uint32(10).fork()).ldelim();
9529
9576
  });
9530
9577
  return writer;
9531
9578
  },
@@ -9559,13 +9606,10 @@ export const PreparedData = {
9559
9606
  fromJSON(object: any): PreparedData {
9560
9607
  return {
9561
9608
  ethCallResults: isObject(object.ethCallResults)
9562
- ? Object.entries(object.ethCallResults).reduce<{ [key: string]: Array<any> | undefined }>(
9563
- (acc, [key, value]) => {
9564
- acc[key] = value as Array<any> | undefined;
9565
- return acc;
9566
- },
9567
- {},
9568
- )
9609
+ ? Object.entries(object.ethCallResults).reduce<{ [key: string]: string }>((acc, [key, value]) => {
9610
+ acc[key] = String(value);
9611
+ return acc;
9612
+ }, {})
9569
9613
  : {},
9570
9614
  };
9571
9615
  },
@@ -9589,20 +9633,21 @@ export const PreparedData = {
9589
9633
  },
9590
9634
  fromPartial(object: DeepPartial<PreparedData>): PreparedData {
9591
9635
  const message = createBasePreparedData();
9592
- message.ethCallResults = Object.entries(object.ethCallResults ?? {}).reduce<
9593
- { [key: string]: Array<any> | undefined }
9594
- >((acc, [key, value]) => {
9595
- if (value !== undefined) {
9596
- acc[key] = value;
9597
- }
9598
- return acc;
9599
- }, {});
9636
+ message.ethCallResults = Object.entries(object.ethCallResults ?? {}).reduce<{ [key: string]: string }>(
9637
+ (acc, [key, value]) => {
9638
+ if (value !== undefined) {
9639
+ acc[key] = globalThis.String(value);
9640
+ }
9641
+ return acc;
9642
+ },
9643
+ {},
9644
+ );
9600
9645
  return message;
9601
9646
  },
9602
9647
  };
9603
9648
 
9604
9649
  function createBasePreparedData_EthCallResultsEntry(): PreparedData_EthCallResultsEntry {
9605
- return { key: "", value: undefined };
9650
+ return { key: "", value: "" };
9606
9651
  }
9607
9652
 
9608
9653
  export const PreparedData_EthCallResultsEntry = {
@@ -9610,8 +9655,8 @@ export const PreparedData_EthCallResultsEntry = {
9610
9655
  if (message.key !== "") {
9611
9656
  writer.uint32(10).string(message.key);
9612
9657
  }
9613
- if (message.value !== undefined) {
9614
- ListValue.encode(ListValue.wrap(message.value), writer.uint32(18).fork()).ldelim();
9658
+ if (message.value !== "") {
9659
+ writer.uint32(18).string(message.value);
9615
9660
  }
9616
9661
  return writer;
9617
9662
  },
@@ -9635,7 +9680,7 @@ export const PreparedData_EthCallResultsEntry = {
9635
9680
  break;
9636
9681
  }
9637
9682
 
9638
- message.value = ListValue.unwrap(ListValue.decode(reader, reader.uint32()));
9683
+ message.value = reader.string();
9639
9684
  continue;
9640
9685
  }
9641
9686
  if ((tag & 7) === 4 || tag === 0) {
@@ -9649,7 +9694,7 @@ export const PreparedData_EthCallResultsEntry = {
9649
9694
  fromJSON(object: any): PreparedData_EthCallResultsEntry {
9650
9695
  return {
9651
9696
  key: isSet(object.key) ? globalThis.String(object.key) : "",
9652
- value: globalThis.Array.isArray(object.value) ? [...object.value] : undefined,
9697
+ value: isSet(object.value) ? globalThis.String(object.value) : "",
9653
9698
  };
9654
9699
  },
9655
9700
 
@@ -9658,7 +9703,7 @@ export const PreparedData_EthCallResultsEntry = {
9658
9703
  if (message.key !== "") {
9659
9704
  obj.key = message.key;
9660
9705
  }
9661
- if (message.value !== undefined) {
9706
+ if (message.value !== "") {
9662
9707
  obj.value = message.value;
9663
9708
  }
9664
9709
  return obj;
@@ -9670,7 +9715,7 @@ export const PreparedData_EthCallResultsEntry = {
9670
9715
  fromPartial(object: DeepPartial<PreparedData_EthCallResultsEntry>): PreparedData_EthCallResultsEntry {
9671
9716
  const message = createBasePreparedData_EthCallResultsEntry();
9672
9717
  message.key = object.key ?? "";
9673
- message.value = object.value ?? undefined;
9718
+ message.value = object.value ?? "";
9674
9719
  return message;
9675
9720
  },
9676
9721
  };
package/src/index.ts CHANGED
@@ -6,3 +6,4 @@ export * from './chain-config.js'
6
6
  export * from './service.js'
7
7
  export { GLOBAL_CONFIG, type GlobalConfig } from './global-config.js'
8
8
  export * from './db-context.js'
9
+ export * from './provider.js'
package/src/metrics.ts ADDED
@@ -0,0 +1,138 @@
1
+ import { Attributes, Counter, metrics, Gauge } from '@opentelemetry/api'
2
+
3
+ const meter = metrics.getMeter('processor')
4
+
5
+ class C {
6
+ private counter: Counter<Attributes>
7
+ private value: number = 0
8
+
9
+ constructor(name: string) {
10
+ this.counter = meter.createCounter(name)
11
+ }
12
+
13
+ add(value: number, attributes?: Attributes) {
14
+ this.counter.add(value, attributes)
15
+ this.value += value
16
+ }
17
+
18
+ get() {
19
+ return this.value
20
+ }
21
+ }
22
+
23
+ class G {
24
+ private gauge: Gauge<Attributes>
25
+ private value: number = 0
26
+
27
+ constructor(name: string) {
28
+ this.gauge = meter.createGauge(name)
29
+ }
30
+
31
+ record(value: number, attributes?: Attributes) {
32
+ this.gauge.record(value, attributes)
33
+ this.value = value
34
+ }
35
+
36
+ get() {
37
+ return this.value
38
+ }
39
+ }
40
+
41
+ export const dbMetrics = {
42
+ send_counts: {
43
+ get: new C('store_get_send'),
44
+ upsert: new C('store_upsert_send'),
45
+ list: new C('store_list_send'),
46
+ delete: new C('store_delete_send')
47
+ },
48
+ recv_counts: {
49
+ get: new C('store_get_recv'),
50
+ upsert: new C('store_upsert_recv'),
51
+ list: new C('store_list_recv'),
52
+ delete: new C('store_delete_recv')
53
+ },
54
+ request_times: {
55
+ get: new C('store_get_time'),
56
+ upsert: new C('store_upsert_time'),
57
+ list: new C('store_list_time'),
58
+ delete: new C('store_delete_time')
59
+ },
60
+ request_errors: {
61
+ get: new C('store_get_error'),
62
+ upsert: new C('store_upsert_error'),
63
+ list: new C('store_list_error'),
64
+ delete: new C('store_delete_error')
65
+ },
66
+ batched_total_count: new C('batched_total_count'),
67
+ batched_request_count: new C('batched_request_count'),
68
+ unsolved_requests: new G('store_unsolved_requests'),
69
+
70
+ stats() {
71
+ return {
72
+ send_counts: {
73
+ get: this.send_counts.get.get(),
74
+ upsert: this.send_counts.upsert.get(),
75
+ list: this.send_counts.list.get(),
76
+ delete: this.send_counts.delete.get()
77
+ },
78
+ recv_counts: {
79
+ get: this.recv_counts.get.get(),
80
+ upsert: this.recv_counts.upsert.get(),
81
+ list: this.recv_counts.list.get(),
82
+ delete: this.recv_counts.delete.get()
83
+ },
84
+ request_times: {
85
+ get: this.request_times.get.get(),
86
+ upsert: this.request_times.upsert.get(),
87
+ list: this.request_times.list.get(),
88
+ delete: this.request_times.delete.get()
89
+ },
90
+ request_errors: {
91
+ get: this.request_errors.get.get(),
92
+ upsert: this.request_errors.upsert.get(),
93
+ list: this.request_errors.list.get(),
94
+ delete: this.request_errors.delete.get()
95
+ },
96
+ batched_total_count: this.batched_total_count.get(),
97
+ batched_request_count: this.batched_request_count.get(),
98
+ unsolved_requests: this.unsolved_requests.get(),
99
+ average_request_time: {
100
+ get: this.request_times.get.get() / this.send_counts.get.get(),
101
+ upsert: this.request_times.upsert.get() / this.send_counts.upsert.get(),
102
+ list: this.request_times.list.get() / this.send_counts.list.get()
103
+ }
104
+ }
105
+ }
106
+ }
107
+
108
+ export const providerMetrics = {
109
+ hit_count: new C('provider_hit_count'),
110
+ miss_count: new C('provider_miss_count'),
111
+ queue_size: new G('provider_queue_size'),
112
+ total_duration: new C('provider_total_duration'),
113
+ total_queued: new C('provider_total_queued'),
114
+ stats() {
115
+ return {
116
+ hit_count: this.hit_count.get(),
117
+ miss_count: this.miss_count.get(),
118
+ queue_size: this.queue_size.get(),
119
+ total_duration: this.total_duration.get(),
120
+ total_queued: this.total_queued.get(),
121
+ average_queue_time: this.total_queued.get() / (this.hit_count.get() + this.miss_count.get()),
122
+ average_duration: this.total_duration.get() / (this.hit_count.get() + this.miss_count.get())
123
+ }
124
+ }
125
+ }
126
+
127
+ export const processMetrics = {
128
+ process_binding_count: new C('process_binding_count'),
129
+ process_binding_time: new C('process_binding_time'),
130
+ process_binding_error: new C('process_binding_error'),
131
+ stats() {
132
+ return {
133
+ process_binding_count: this.process_binding_count.get(),
134
+ process_binding_time: this.process_binding_time.get(),
135
+ process_binding_error: this.process_binding_error.get()
136
+ }
137
+ }
138
+ }