@sentio/runtime 2.40.0-rc.5 → 2.40.0-rc.50
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/LICENSE +55 -0
- package/lib/chunk-N7A3MJFE.js +131 -0
- package/lib/chunk-N7A3MJFE.js.map +1 -0
- package/lib/index.d.ts +22 -9
- package/lib/index.js +2 -93
- 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 +14 -36
- package/src/db-context.ts +51 -44
- package/src/decode-benchmark.ts +0 -0
- 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/otlp.ts +50 -0
- package/src/plugin.ts +7 -3
- package/src/processor-runner.ts +64 -21
- package/src/provider.ts +3 -9
- package/src/service.ts +105 -42
- package/src/tsup.config.ts +2 -0
- package/src/utils.ts +11 -3
- package/.eslintrc.json +0 -5
- package/chains-config.json +0 -9
- package/lib/chunk-FFU5RYDX.js +0 -78856
- package/src/global-config.test.ts +0 -19
- package/src/logger.test.ts +0 -26
- package/src/seq-mode.test.ts +0 -80
- package/src/service.test.ts +0 -51
- package/src/state-storage.test.ts +0 -25
- package/tsconfig.json +0 -10
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
|
+
}
|