Skip to content

Commit

Permalink
Add System Metrics page (#43)
Browse files Browse the repository at this point in the history
Co-authored-by: Alex Hall <[email protected]>
  • Loading branch information
Kludex and alexmojaki authored Apr 30, 2024
1 parent c7b2115 commit 54c19b7
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 30 deletions.
33 changes: 6 additions & 27 deletions docs/guides/onboarding_checklist/add_metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,43 +221,22 @@ 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
[up-down-counter-metric]: https://opentelemetry.io/docs/specs/otel/metrics/api/#updowncounter
[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
30 changes: 28 additions & 2 deletions docs/integrations/system_metrics.md
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 5 additions & 1 deletion docs/plugins/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 54c19b7

Please sign in to comment.