Skip to content

Adds metrics helper test fixture#514

Open
Stringy wants to merge 1 commit intomainfrom
giles/metrics-test-utils
Open

Adds metrics helper test fixture#514
Stringy wants to merge 1 commit intomainfrom
giles/metrics-test-utils

Conversation

@Stringy
Copy link
Copy Markdown
Contributor

@Stringy Stringy commented Apr 15, 2026

Description

During the work on rate limiting tests in #499, I thought it might be useful to have a metrics fixture to get a snapshot of the metrics to reason about Fact's state.

Checklist

  • Investigated and inspected CI test results
  • Updated documentation accordingly

Automated testing

  • Added unit tests
  • Added integration tests
  • Added regression tests

If any of these don't apply, please comment below.

Testing Performed

CI is enough.

Comment thread tests/metrics.py
Comment on lines +47 to +51
if name.startswith(cls._PREFIX):
name = name[len(cls._PREFIX):]
if name.endswith(cls._TOTAL_SUFFIX):
name = name[:-len(cls._TOTAL_SUFFIX)]
return name
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if name.startswith(cls._PREFIX):
name = name[len(cls._PREFIX):]
if name.endswith(cls._TOTAL_SUFFIX):
name = name[:-len(cls._TOTAL_SUFFIX)]
return name
return name.removeprefix(cls._PREFIX).removesuffix(cls._TOTAL_SUFFIX)

Comment thread tests/test_rate_limit.py
if len(parts) >= 2:
dropped_count = int(parts[1])
break
ss = metrics.snapshot()
Copy link
Copy Markdown
Contributor

@JoukoVirtanen JoukoVirtanen Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ultra nit] I don't like ss. I guess the the less a variable is used the shorter it can be, but I would still prefer metric_snapshot here.

@JoukoVirtanen
Copy link
Copy Markdown
Contributor

Please rebase and remove get_metric_value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants