@@ -127,6 +127,8 @@ export class Upgrader implements UpgraderInterface {
127127 private readonly metrics : {
128128 dials ?: CounterGroup < 'inbound' | 'outbound' >
129129 errors ?: CounterGroup < 'inbound' | 'outbound' >
130+ inboundErrors ?: CounterGroup
131+ outboundErrors ?: CounterGroup
130132 }
131133
132134 constructor ( components : UpgraderComponents , init : UpgraderInit ) {
@@ -155,7 +157,9 @@ export class Upgrader implements UpgraderInterface {
155157 this . events = components . events
156158 this . metrics = {
157159 dials : components . metrics ?. registerCounterGroup ( 'libp2p_connection_manager_dials_total' ) ,
158- errors : components . metrics ?. registerCounterGroup ( 'libp2p_connection_manager_dial_errors_total' )
160+ errors : components . metrics ?. registerCounterGroup ( 'libp2p_connection_manager_dial_errors_total' ) ,
161+ inboundErrors : components . metrics ?. registerCounterGroup ( 'libp2p_connection_manager_dials_inbound_errors_total' ) ,
162+ outboundErrors : components . metrics ?. registerCounterGroup ( 'libp2p_connection_manager_dials_outbound_errors_total' )
159163 }
160164 }
161165
@@ -213,10 +217,13 @@ export class Upgrader implements UpgraderInterface {
213217 ...opts ,
214218 signal
215219 } )
216- } catch ( err ) {
220+ } catch ( err : any ) {
217221 this . metrics . errors ?. increment ( {
218222 inbound : true
219223 } )
224+ this . metrics . inboundErrors ?. increment ( {
225+ [ err . name ?? 'Error' ] : true
226+ } )
220227
221228 throw err
222229 } finally {
@@ -253,10 +260,13 @@ export class Upgrader implements UpgraderInterface {
253260 }
254261
255262 return await this . _performUpgrade ( maConn , direction , opts )
256- } catch ( err ) {
263+ } catch ( err : any ) {
257264 this . metrics . errors ?. increment ( {
258265 outbound : true
259266 } )
267+ this . metrics . outboundErrors ?. increment ( {
268+ [ err . name ?? 'Error' ] : true
269+ } )
260270
261271 throw err
262272 }
0 commit comments