Skip to content

Commit

Permalink
Update URL for usecounter enums (#4740)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrobbins authored Jan 28, 2025
1 parent 6a022a8 commit dd2b29b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions internals/fetchmetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
UMA_QUERY_SERVER = 'https://uma-export.appspot.com/chromestatus/'

HISTOGRAMS_URL = 'https://chromium.googlesource.com/chromium/src/+/main/' \
'tools/metrics/histograms/enums.xml?format=TEXT'
'tools/metrics/histograms/metadata/blink/enums.xml?format=TEXT'

# After we have processed all metrics data for a given kind on a given day,
# we create a capstone entry with this otherwise unused bucket_id. Later
Expand Down Expand Up @@ -257,7 +257,7 @@ def get_template_data(self, **kwargs):

if (response.status_code != 200):
logging.error('Unable to retrieve chromium histograms mapping file.')
return
self.abort(500)

histograms_content = base64.b64decode(response.content).decode()
dom = minidom.parseString(histograms_content)
Expand All @@ -267,13 +267,19 @@ def get_template_data(self, **kwargs):
# <int value="0" label="OBSOLETE_PageDestruction"/>
# <int value="1" label="LegacyNotifications"/>

enum_tags = dom.getElementsByTagName('enum')
enum_els = dom.getElementsByTagName('enum')

# Save bucket ids for each histogram type, FeatureObserver and
# MappedCSSProperties.
for histogram_id in list(self.MODEL_CLASS.keys()):
enum = [enum for enum in enum_tags
if enum.attributes['name'].value == histogram_id][0]
matching_els = [el for el in enum_els
if el.attributes['name'].value == histogram_id]
if matching_els:
enum = matching_els[0]
else:
logging.error(f'Unable to find <enum name="{histogram_id}">.')
self.abort(500)

for child in enum.getElementsByTagName('int'):
self._SaveData({
'bucket_id': child.attributes['value'].value,
Expand Down

0 comments on commit dd2b29b

Please sign in to comment.