Skip to content

Commit 126aa15

Browse files
Minor documentation improvements.
1 parent dd3b8aa commit 126aa15

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

context/getting-started.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ end
4343

4444
Metrics are tracked in memory and can be accessed programmatically. However, for inter-process communication (e.g., with a supervisor process), you'll want to use a shared memory observer.
4545

46+
## Using metrics from your own objects
47+
48+
Assign the handle from the registry to an instance variable (or replace it when you switch to a different registry):
49+
50+
```ruby
51+
@total_requests = registry.metric(:total_requests)
52+
```
53+
54+
Each call to `registry.metric(:field)` returns the **same** cached instance for that field. Setting `registry.observer = …` updates every metric the registry already holds, so you normally keep using the same handle. Fetch a new metric only when you use a different registry or a different field name.
55+
4656
## With Shared Memory Observer
4757

4858
When you need to share metrics with other processes (like a supervisor monitoring worker health), you can set up a shared memory observer:

guides/getting-started/readme.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ end
4343

4444
Metrics are tracked in memory and can be accessed programmatically. However, for inter-process communication (e.g., with a supervisor process), you'll want to use a shared memory observer.
4545

46+
## Using metrics from your own objects
47+
48+
Assign the handle from the registry to an instance variable (or replace it when you switch to a different registry):
49+
50+
```ruby
51+
@total_requests = registry.metric(:total_requests)
52+
```
53+
54+
Each call to `registry.metric(:field)` returns the **same** cached instance for that field. Setting `registry.observer = …` updates every metric the registry already holds, so you normally keep using the same handle. Fetch a new metric only when you use a different registry or a different field name.
55+
4656
## With Shared Memory Observer
4757

4858
When you need to share metrics with other processes (like a supervisor monitoring worker health), you can set up a shared memory observer:

0 commit comments

Comments
 (0)