@sentio/runtime 2.40.0-rc.4 → 2.40.0-rc.40
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/lib/chunk-P6GAI4NE.js +131 -0
- package/lib/chunk-P6GAI4NE.js.map +1 -0
- package/lib/index.d.ts +24 -9
- package/lib/index.js +2 -91
- package/lib/index.js.map +1 -0
- package/lib/processor-runner.d.ts +3 -0
- package/lib/processor-runner.js +58 -51468
- package/lib/processor-runner.js.map +1 -0
- package/package.json +1 -1
- package/src/db-context.ts +51 -44
- package/src/gen/processor/protos/processor.ts +121 -76
- package/src/index.ts +1 -0
- package/src/metrics.ts +138 -0
- package/src/multicall.ts +1615 -0
- package/src/plugin.ts +7 -3
- package/src/processor-runner.ts +62 -21
- package/src/provider.ts +3 -9
- package/src/service.ts +103 -42
- package/src/tsup.config.ts +2 -0
- package/src/utils.ts +11 -3
- package/lib/chunk-FGIYODHE.js +0 -78810
package/package.json
CHANGED
package/src/db-context.ts
CHANGED
@@ -8,55 +8,33 @@ import {
|
|
8
8
|
ProcessStreamResponse
|
9
9
|
} from '@sentio/protos'
|
10
10
|
import * as process from 'node:process'
|
11
|
-
import {
|
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
|
23
|
+
const STORE_UPSERT_NO_WAIT = process.env['STORE_UPSERT_NO_WAIT'] === 'true'
|
15
24
|
|
16
25
|
type Request = Omit<DBRequest, 'opId'>
|
17
26
|
type RequestType = keyof Request
|
18
27
|
|
19
|
-
const
|
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()
|
28
|
+
export const timeoutError = new Error('timeout')
|
51
29
|
|
52
30
|
export class StoreContext {
|
53
31
|
private static opCounter = 0n
|
54
|
-
|
55
32
|
private defers = new Map<
|
56
33
|
bigint,
|
57
34
|
{ resolve: (value: any) => void; reject: (reason?: any) => void; requestType?: RequestType }
|
58
35
|
>()
|
59
36
|
private statsInterval: NodeJS.Timeout | undefined
|
37
|
+
private pendings: Promise<unknown>[] = []
|
60
38
|
|
61
39
|
constructor(
|
62
40
|
readonly subject: Subject<DeepPartial<ProcessStreamResponse>>,
|
@@ -82,7 +60,7 @@ export class StoreContext {
|
|
82
60
|
|
83
61
|
const start = Date.now()
|
84
62
|
const promises = [promise]
|
85
|
-
console.debug('sending db request ', opId, request)
|
63
|
+
// console.debug('sending db request ', opId, request)
|
86
64
|
let timer: NodeJS.Timeout | undefined
|
87
65
|
if (timeoutSecs) {
|
88
66
|
const timeoutPromise = new Promise((_r, rej) => (timer = setTimeout(rej, timeoutSecs * 1000, timeoutError)))
|
@@ -99,9 +77,18 @@ export class StoreContext {
|
|
99
77
|
|
100
78
|
send_counts[requestType]?.add(1)
|
101
79
|
|
80
|
+
if (requestType === 'upsert' && STORE_UPSERT_NO_WAIT) {
|
81
|
+
this.pendings.push(promise)
|
82
|
+
return Promise.resolve({
|
83
|
+
opId,
|
84
|
+
} as DBResponse)
|
85
|
+
}
|
86
|
+
|
102
87
|
return Promise.race(promises)
|
103
88
|
.then((result: DBResponse) => {
|
104
|
-
|
89
|
+
if (timeoutSecs) {
|
90
|
+
console.debug('db request', requestType, 'op', opId, ' took', Date.now() - start, 'ms')
|
91
|
+
}
|
105
92
|
request_times[requestType]?.add(Date.now() - start)
|
106
93
|
return result
|
107
94
|
})
|
@@ -122,7 +109,7 @@ export class StoreContext {
|
|
122
109
|
result(dbResult: DBResponse) {
|
123
110
|
const opId = dbResult.opId
|
124
111
|
const defer = this.defers.get(opId)
|
125
|
-
console.debug('received db result ', opId, dbResult)
|
112
|
+
// console.debug('received db result ', opId, dbResult)
|
126
113
|
if (defer) {
|
127
114
|
if (defer.requestType) {
|
128
115
|
recv_counts[defer.requestType]?.add(1)
|
@@ -152,8 +139,8 @@ export class StoreContext {
|
|
152
139
|
|
153
140
|
close() {
|
154
141
|
for (const [opId, defer] of this.defers) {
|
155
|
-
console.warn('context closed before db response', opId)
|
156
|
-
defer.reject(new Error('context closed'))
|
142
|
+
// console.warn('context closed before db response', opId)
|
143
|
+
defer.reject(new Error('context closed before db response, processId: ' + this.processId + ' opId: ' + opId))
|
157
144
|
}
|
158
145
|
this.defers.clear()
|
159
146
|
if (this.statsInterval) {
|
@@ -180,29 +167,45 @@ export class StoreContext {
|
|
180
167
|
if (request.entity.length >= STORE_BATCH_SIZE) {
|
181
168
|
this.sendBatch()
|
182
169
|
}
|
170
|
+
if (STORE_UPSERT_NO_WAIT) {
|
171
|
+
return {
|
172
|
+
opId: this.upsertBatch.opId
|
173
|
+
}
|
174
|
+
}
|
175
|
+
|
183
176
|
return promise
|
184
177
|
} else {
|
185
178
|
const opId = StoreContext.opCounter++
|
186
|
-
const promise = this.newPromise<DBResponse>(opId, 'upsert')
|
187
179
|
const timeout = setTimeout(() => {
|
188
180
|
this.sendBatch()
|
189
181
|
}, STORE_BATCH_IDLE)
|
182
|
+
const start = Date.now()
|
183
|
+
const promise = this.newPromise<DBResponse>(opId, 'upsert').finally(() => {
|
184
|
+
request_times['upsert'].add(Date.now() - start)
|
185
|
+
})
|
190
186
|
|
191
187
|
this.upsertBatch = {
|
192
188
|
opId,
|
193
189
|
request: req,
|
194
190
|
promise,
|
195
|
-
timer: timeout
|
191
|
+
timer: timeout,
|
196
192
|
}
|
197
193
|
|
198
|
-
|
194
|
+
if (STORE_UPSERT_NO_WAIT) {
|
195
|
+
this.pendings.push(promise)
|
196
|
+
return {
|
197
|
+
opId: this.upsertBatch.opId
|
198
|
+
}
|
199
|
+
} else {
|
200
|
+
return promise
|
201
|
+
}
|
199
202
|
}
|
200
203
|
}
|
201
204
|
|
202
205
|
private sendBatch() {
|
203
206
|
if (this.upsertBatch) {
|
204
207
|
const { request, opId, timer } = this.upsertBatch
|
205
|
-
console.debug('sending batch upsert', opId, 'batch size', request?.entity.length)
|
208
|
+
// console.debug('sending batch upsert', opId, 'batch size', request?.entity.length)
|
206
209
|
clearTimeout(timer)
|
207
210
|
this.upsertBatch = undefined
|
208
211
|
this.subject.next({
|
@@ -217,4 +220,8 @@ export class StoreContext {
|
|
217
220
|
batched_total_count.add(request.entity.length)
|
218
221
|
}
|
219
222
|
}
|
223
|
+
|
224
|
+
async awaitPendings() {
|
225
|
+
await Promise.all(this.pendings)
|
226
|
+
}
|
220
227
|
}
|
@@ -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
|
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
|
-
|
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]:
|
1087
|
+
ethCallResults: { [key: string]: string };
|
1085
1088
|
}
|
1086
1089
|
|
1087
1090
|
export interface PreparedData_EthCallResultsEntry {
|
1088
1091
|
key: string;
|
1089
|
-
value:
|
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 {
|
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.
|
9346
|
-
writer.uint32(10).
|
9348
|
+
if (message.context !== undefined) {
|
9349
|
+
EthCallContext.encode(message.context, writer.uint32(10).fork()).ldelim();
|
9347
9350
|
}
|
9348
|
-
if (message.
|
9349
|
-
writer.uint32(18).string(message.
|
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.
|
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.
|
9376
|
+
message.calldata = reader.string();
|
9383
9377
|
continue;
|
9384
|
-
|
9385
|
-
|
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.
|
9448
|
+
message.chainId = reader.string();
|
9390
9449
|
continue;
|
9391
|
-
case
|
9392
|
-
if (tag !==
|
9450
|
+
case 2:
|
9451
|
+
if (tag !== 18) {
|
9393
9452
|
break;
|
9394
9453
|
}
|
9395
9454
|
|
9396
|
-
message.
|
9455
|
+
message.address = reader.string();
|
9397
9456
|
continue;
|
9398
|
-
case
|
9399
|
-
if (tag !==
|
9457
|
+
case 3:
|
9458
|
+
if (tag !== 26) {
|
9400
9459
|
break;
|
9401
9460
|
}
|
9402
9461
|
|
9403
|
-
message.
|
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):
|
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
|
-
|
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:
|
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.
|
9433
|
-
obj.
|
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<
|
9445
|
-
return
|
9495
|
+
create(base?: DeepPartial<EthCallContext>): EthCallContext {
|
9496
|
+
return EthCallContext.fromPartial(base ?? {});
|
9446
9497
|
},
|
9447
|
-
fromPartial(object: DeepPartial<
|
9448
|
-
const message =
|
9498
|
+
fromPartial(object: DeepPartial<EthCallContext>): EthCallContext {
|
9499
|
+
const message = createBaseEthCallContext();
|
9449
9500
|
message.chainId = object.chainId ?? "";
|
9450
9501
|
message.address = object.address ?? "";
|
9451
|
-
message.
|
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
|
-
|
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]:
|
9563
|
-
|
9564
|
-
|
9565
|
-
|
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
|
-
|
9594
|
-
|
9595
|
-
|
9596
|
-
|
9597
|
-
|
9598
|
-
|
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:
|
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 !==
|
9614
|
-
|
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 =
|
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:
|
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 !==
|
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 ??
|
9718
|
+
message.value = object.value ?? "";
|
9674
9719
|
return message;
|
9675
9720
|
},
|
9676
9721
|
};
|
package/src/index.ts
CHANGED
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
|
+
}
|