3535 "Number of channel status requests which have failed" ,
3636)
3737
38+
3839@CHANNEL_REQUEST_TIME .time ()
3940def measure_channel (name ):
4041 try :
4142 with CHANNEL_REQUEST_FAILURES .count_exceptions ():
42- result = requests .get (f"https://nixos.org/channels/{ name } /git-revision" , timeout = 10 )
43+ result = requests .get (
44+ f"https://nixos.org/channels/{ name } /git-revision" , timeout = 10
45+ )
4346
4447 try :
4548 return {
4649 "timestamp" : parse (result .headers ["last-modified" ]).timestamp (),
47- "revision" : result .text
50+ "revision" : result .text ,
4851 }
4952 except KeyError as e :
5053 print (f"Got KeyError after getting our result for { name } :" )
@@ -66,19 +69,29 @@ def measure_channel(name):
6669 revisions = {}
6770
6871 while True :
69- for ( channel , about ) in channels .items ():
72+ for channel , about in channels .items ():
7073 measurement = measure_channel (channel )
7174 if measurement is not None :
72- revision = measurement ['revision' ]
73- status = about .get ('status' , '' )
74- variant = about .get ('variant' , '' )
75- current = int (status != 'unmaintained' )
76- CHANNEL_UPDATE_TIME .labels (channel = channel ).set (measurement ['timestamp' ])
77- CHANNEL_REVISION .labels (channel = channel , revision = revision , status = status , variant = variant , current = current ).set (1 )
75+ revision = measurement ["revision" ]
76+ status = about .get ("status" , "" )
77+ variant = about .get ("variant" , "" )
78+ current = int (status != "unmaintained" )
79+ CHANNEL_UPDATE_TIME .labels (channel = channel ).set (
80+ measurement ["timestamp" ]
81+ )
82+ CHANNEL_REVISION .labels (
83+ channel = channel ,
84+ revision = revision ,
85+ status = status ,
86+ variant = variant ,
87+ current = current ,
88+ ).set (1 )
7889 CHANNEL_CURRENT .labels (channel = channel ).set (current )
79- print (' updated {}' .format (channel ))
90+ print (" updated {}" .format (channel ))
8091 previous_revision = revisions .pop (channel , None )
8192 revisions [channel ] = revision
8293 if previous_revision and previous_revision != revision :
83- CHANNEL_REVISION .remove (channel , previous_revision , status , variant , current )
94+ CHANNEL_REVISION .remove (
95+ channel , previous_revision , status , variant , current
96+ )
8497 time .sleep (55 )
0 commit comments