Skip to content

Commit

Permalink
docs: remove unused plugin for system metrics (#817)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kludex authored Jan 24, 2025
1 parent 1e96bff commit 257772a
Showing 1 changed file with 1 addition and 30 deletions.
31 changes: 1 addition & 30 deletions docs/plugins/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from mkdocs.structure.files import Files
from mkdocs.structure.pages import Page

from logfire._internal import config_params, metrics
from logfire._internal import config_params

LOGFIRE_DIR = Path(__file__).parent.parent.parent

Expand All @@ -20,7 +20,6 @@ def on_page_markdown(markdown: str, page: Page, config: Config, files: Files) ->
markdown = build_environment_variables_table(markdown, page)
markdown = logfire_print_help(markdown, page)
markdown = install_logfire(markdown, page)
markdown = check_documented_system_metrics(markdown, page)
markdown = integrations_metadata(markdown, page)
markdown = footer_web_frameworks(markdown, page)
return markdown
Expand All @@ -35,34 +34,6 @@ def on_files(files: Files, config: Config) -> None:
)


def check_documented_system_metrics(markdown: str, page: Page) -> str:
"""Check that all system metrics are documented.
The system metrics are the ones defined in `logfire._metrics.DEFAULT_CONFIG`.
The documentation is in `metrics.md`. The metrics are documented in bullet points, like this:
* `system.cpu.time`: The CPU time spent in different modes.
* `system.cpu.utilization`: The CPU utilization in different modes.
This function checks that all the metrics in `DEFAULT_CONFIG` are documented.
"""
if page.file.src_uri != 'guides/onboarding-checklist/06_add-metrics.md':
return markdown

metrics_documented: set[str] = set()
for line in markdown.splitlines():
match = re.search(r'\* `(.*)`: ', line)
if match:
metrics_documented.add(match.group(1))

# Check that all the metrics are documented.
for metric in metrics.DEFAULT_CONFIG:
if metric not in metrics_documented:
raise RuntimeError(f'Metric {metric} is not documented on the metrics page.')

return markdown


def logfire_print_help(markdown: str, page: Page) -> str:
# if you don't filter to the specific route that needs this substitution, things will be very slow
if page.file.src_uri != 'reference/cli.md':
Expand Down

0 comments on commit 257772a

Please sign in to comment.