File tree Expand file tree Collapse file tree
packages/portalnetwork/src
wire/utp/PortalNetworkUtp Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -79,12 +79,27 @@ const ultralightMetrics = [
7979 metric : MetricType . Counter ,
8080 help : 'how many UTP packets have been received' ,
8181 } ,
82+ {
83+ name : 'utpStreamsTotal' ,
84+ metric : MetricType . Gauge ,
85+ help : 'how many total UTP streams were opened' ,
86+ } ,
87+ {
88+ name : 'utpWriteStreams' ,
89+ metric : MetricType . Gauge ,
90+ help : 'how many UTP write streams were opened' ,
91+ } ,
92+ {
93+ name : 'utpReadStreams' ,
94+ metric : MetricType . Gauge ,
95+ help : 'how many UTP read streams were opened' ,
96+ } ,
8297]
8398
8499export const setupMetrics = (
85100 networks : NetworkId [ ] = [ NetworkId . HistoryNetwork ] ,
86101) : PortalNetworkMetrics => {
87- const metrics = createMetrics ( ultralightMetrics , [ ...networks , NetworkId . UTPNetwork ] )
102+ const metrics = createMetrics ( ultralightMetrics , [ ...networks ] )
88103 return {
89104 ...metrics ,
90105 totalContentLookups : new Gauge < string > ( {
Original file line number Diff line number Diff line change @@ -90,6 +90,23 @@ export class PortalNetworkUTP {
9090
9191 async handleNewRequest ( params : INewRequest ) : Promise < ContentRequestType > {
9292 const { contentKeys, enr, connectionId, requestCode } = params
93+ if ( this . client . metrics ) {
94+ const utpMetric = ( NetworkNames [ params . networkId ] +
95+ '_utpStreamsTotal' ) as keyof PortalNetworkMetrics
96+ this . client . metrics [ utpMetric ] . inc ( )
97+ if (
98+ requestCode === RequestCode . FOUNDCONTENT_WRITE ||
99+ requestCode === RequestCode . OFFER_WRITE
100+ ) {
101+ const utpWriteMetric = ( NetworkNames [ params . networkId ] +
102+ '_utpWriteStreams' ) as keyof PortalNetworkMetrics
103+ this . client . metrics [ utpWriteMetric ] . inc ( )
104+ } else {
105+ const utpReadMetric = ( NetworkNames [ params . networkId ] +
106+ '_utpReadStreams' ) as keyof PortalNetworkMetrics
107+ this . client . metrics [ utpReadMetric ] . inc ( )
108+ }
109+ }
93110 if ( this . requestManagers [ enr . nodeId ] === undefined ) {
94111 this . requestManagers [ enr . nodeId ] = new RequestManager ( enr . nodeId , this . logger )
95112 }
You can’t perform that action at this time.
0 commit comments