92
92
* const stream = await connection.newStream('/my/protocol')
93
93
* const streams = metrics.trackProtocolStream(stream)
94
94
* ```
95
- *
96
95
*/
97
96
98
- import type { CalculatedMetricOptions , Counter , CounterGroup , Metric , MetricGroup , MetricOptions , Metrics } from '@libp2p/interface-metrics'
99
- import { collectDefaultMetrics , DefaultMetricsCollectorConfiguration , register , Registry } from 'prom-client'
100
- import type { MultiaddrConnection , Stream , Connection } from '@libp2p/interface-connection'
101
- import type { Duplex } from 'it-stream-types'
97
+ import { logger } from '@libp2p/logger'
102
98
import each from 'it-foreach'
103
- import { PrometheusMetric } from './metric.js'
104
- import { PrometheusMetricGroup } from './metric-group.js'
105
- import { PrometheusCounter } from './counter.js'
99
+ import { collectDefaultMetrics , type DefaultMetricsCollectorConfiguration , register , type Registry } from 'prom-client'
106
100
import { PrometheusCounterGroup } from './counter-group.js'
107
- import { logger } from '@libp2p/logger'
101
+ import { PrometheusCounter } from './counter.js'
102
+ import { PrometheusMetricGroup } from './metric-group.js'
103
+ import { PrometheusMetric } from './metric.js'
104
+ import type { MultiaddrConnection , Stream , Connection } from '@libp2p/interface-connection'
105
+ import type { CalculatedMetricOptions , Counter , CounterGroup , Metric , MetricGroup , MetricOptions , Metrics } from '@libp2p/interface-metrics'
106
+ import type { Duplex , Source } from 'it-stream-types'
108
107
109
108
const log = logger ( 'libp2p:prometheus-metrics' )
110
109
@@ -194,7 +193,7 @@ class PrometheusMetrics implements Metrics {
194
193
* Increment the transfer stat for the passed key, making sure
195
194
* it exists first
196
195
*/
197
- _incrementValue ( key : string , value : number ) {
196
+ _incrementValue ( key : string , value : number ) : void {
198
197
const existing = this . transferStats . get ( key ) ?? 0
199
198
200
199
this . transferStats . set ( key , existing + value )
@@ -204,7 +203,7 @@ class PrometheusMetrics implements Metrics {
204
203
* Override the sink/source of the stream to count the bytes
205
204
* in and out
206
205
*/
207
- _track ( stream : Duplex < any > , name : string ) {
206
+ _track ( stream : Duplex < Source < any > > , name : string ) : void {
208
207
const self = this
209
208
210
209
const sink = stream . sink
0 commit comments