From 54c19b7d18bf0c7914662bf1f9c59d1c8308fbeb Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Tue, 30 Apr 2024 15:16:44 +0200 Subject: [PATCH] Add System Metrics page (#43) Co-authored-by: Alex Hall --- .../onboarding_checklist/add_metrics.md | 33 ++++--------------- docs/integrations/system_metrics.md | 30 +++++++++++++++-- docs/plugins/main.py | 6 +++- 3 files changed, 39 insertions(+), 30 deletions(-) diff --git a/docs/guides/onboarding_checklist/add_metrics.md b/docs/guides/onboarding_checklist/add_metrics.md index 6c6190f3..ead021b7 100644 --- a/docs/guides/onboarding_checklist/add_metrics.md +++ b/docs/guides/onboarding_checklist/add_metrics.md @@ -221,39 +221,17 @@ logfire.metric_up_down_counter_callback( You can read more about the Up-Down Counter metric in the [OpenTelemetry documentation][up-down-counter-callback-metric]. - ## System Metrics By default, **Logfire** does not collect system metrics. -To enable metrics, you need to install the `logfire[system-metrics]` extra: +To enable metrics, you need just need install the `logfire[system-metrics]` extra: -```bash -pip install 'logfire[system-metrics]' -``` +{{ install_logfire(extras=['system-metrics']) }} + +**Logfire** will automatically collect system metrics if the `logfire[system-metrics]` extra is installed. -### Available Metrics - -Logfire collects the following system metrics: - -* `system.cpu.time`: CPU time spent in different modes. -* `system.cpu.utilization`: CPU utilization in different modes. -* `system.memory.usage`: Memory usage. -* `system.memory.utilization`: Memory utilization in different modes. -* `system.swap.usage`: Swap usage. -* `system.swap.utilization`: Swap utilization -* `system.disk.io`: Disk I/O operations (read/write). -* `system.disk.operations`: Disk operations (read/write). -* `system.disk.time`: Disk time (read/write). -* `system.network.dropped.packets`: Dropped packets (transmit/receive). -* `system.network.packets`: Packets (transmit/receive). -* `system.network.errors`: Network errors (transmit/receive). -* `system.network.io`: Network I/O (transmit/receive). -* `system.network.connections`: Network connections (family/type). -* `system.thread_count`: Thread count. -* `process.runtime.memory`: Process memory usage. -* `process.runtime.cpu.time`: Process CPU time. -* `process.runtime.gc_count`: Process garbage collection count. +To know more about which system metrics are collected, check the [System Metrics][system-metrics] documentation. [counter-metric]: https://opentelemetry.io/docs/specs/otel/metrics/api/#counter [histogram-metric]: https://opentelemetry.io/docs/specs/otel/metrics/api/#histogram @@ -261,3 +239,4 @@ Logfire collects the following system metrics: [counter-callback-metric]: https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-counter [gauge-callback-metric]: https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-gauge [up-down-counter-callback-metric]: https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-updowncounter +[system-metrics]: ../../integrations/system_metrics.md diff --git a/docs/integrations/system_metrics.md b/docs/integrations/system_metrics.md index f2900862..0cb81191 100644 --- a/docs/integrations/system_metrics.md +++ b/docs/integrations/system_metrics.md @@ -1,2 +1,28 @@ -!!! warning "🚧 Work in Progress 🚧" - This page is yet to be written, [contact us](../help.md) if you have any questions. +By default, **Logfire** does not collect system metrics. + +To enable metrics, you need to install the `logfire[system-metrics]` extra: + +{{ install_logfire(extras=['system-metrics']) }} + +### Available Metrics + +Logfire collects the following system metrics: + +* `system.cpu.time`: CPU time spent in different modes. +* `system.cpu.utilization`: CPU utilization in different modes. +* `system.memory.usage`: Memory usage. +* `system.memory.utilization`: Memory utilization in different modes. +* `system.swap.usage`: Swap usage. +* `system.swap.utilization`: Swap utilization +* `system.disk.io`: Disk I/O operations (read/write). +* `system.disk.operations`: Disk operations (read/write). +* `system.disk.time`: Disk time (read/write). +* `system.network.dropped.packets`: Dropped packets (transmit/receive). +* `system.network.packets`: Packets (transmit/receive). +* `system.network.errors`: Network errors (transmit/receive). +* `system.network.io`: Network I/O (transmit/receive). +* `system.network.connections`: Network connections (family/type). +* `system.thread_count`: Thread count. +* `process.runtime.memory`: Process memory usage. +* `process.runtime.cpu.time`: Process CPU time. +* `process.runtime.gc_count`: Process garbage collection count. diff --git a/docs/plugins/main.py b/docs/plugins/main.py index 3e8a93a1..b184ba44 100644 --- a/docs/plugins/main.py +++ b/docs/plugins/main.py @@ -93,7 +93,11 @@ def build_environment_variables_table(markdown: str, page: Page) -> str: def install_logfire(markdown: str, page: Page) -> str: """Build the installation instructions for each integration.""" - if not (page.file.src_uri.startswith('integrations/') or page.file.src_uri.endswith('first_steps/index.md')): + if not ( + page.file.src_uri.startswith('integrations/') + or page.file.src_uri.endswith('first_steps/index.md') + or page.file.src_uri.endswith('onboarding_checklist/add_metrics.md') + ): return markdown # Match instructions like "{{ install_logfire(extras=['fastapi']) }}". Get the extras, if any.