Skip to content

Conversation

khvn26
Copy link
Member

@khvn26 khvn26 commented Apr 25, 2025

This PR adds the flagsmith docgen metrics command. The output is valid Markdown describing all Prometheus metrics exported by the application.

Besides that, several improvements and fixes are introduced:

  1. Prometheus client multiprocess mode does not support registry cleanup between tests. Because of that, prometheus_multiproc_dir is only used with tests where it's needed (currently just the one that tests the /metrics endpoint).
  2. snapshot fixture added to test_tools to enable snapshot testing. Snapshots are a convenient way to implement tests where outputs are asserted against reference values. pytest --snapshot-update option refreshes the snapshots automatically for the tests being run, and xfails the affected tests.
  3. clear_lru_caches fixture is tuned to expect dirty caches before the test starts.

@khvn26 khvn26 requested a review from a team as a code owner April 25, 2025 21:24
@khvn26 khvn26 requested review from gagantrivedi and removed request for a team April 25, 2025 21:24
@khvn26 khvn26 force-pushed the feat/docgen-metrics branch from d5b8a67 to 7c427d1 Compare April 26, 2025 17:46

Counter.

Total number of tests run by pytest
Copy link
Contributor

@emyller emyller Apr 29, 2025

Choose a reason for hiding this comment

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

Missing period.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in 6c14406

Copy link
Contributor

@emyller emyller left a comment

Choose a reason for hiding this comment

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

Couple nits but ✅able material already.

def __call__(self, name: str = "") -> "Snapshot": ...


class Snapshot:
Copy link
Contributor

Choose a reason for hiding this comment

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

docstring please!

Copy link
Member Author

Choose a reason for hiding this comment

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

Added in 83a0e21.



@pytest.fixture
def snapshot(request: pytest.FixtureRequest) -> SnapshotFixture:
Copy link
Contributor

Choose a reason for hiding this comment

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

docstring please!

Copy link
Member Author

Choose a reason for hiding this comment

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

Added in 83a0e21.

@khvn26 khvn26 requested review from matthewelwell and emyller April 30, 2025 08:41
@khvn26 khvn26 merged commit c9c4935 into main Apr 30, 2025
4 checks passed
This was referenced Jul 29, 2025
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.

3 participants