You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+43Lines changed: 43 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -256,6 +256,49 @@ class MyComponent
256
256
end
257
257
```
258
258
259
+
### `init_label_set`
260
+
261
+
The time series of a metric are not initialiazed until something happens. For counters, for example, this means that the time series do not exist until the counter is increamented for the first time.
262
+
263
+
This can lead to cases that are hard to handle:
264
+
265
+
```ruby
266
+
counter =
267
+
Counter.new(
268
+
:http_requests_total,
269
+
docstring:'...',
270
+
labels: [:app, :env, :version],
271
+
)
272
+
273
+
# After declaring the counter nothing is exported because the time series have not been initialized
274
+
275
+
# We call increment for the first time and the time serie for the label set provided is initialiazed
# In the server when we calculate the increase of the counter, increase([1, 2]), we get 1 as a result although we increased the counter twice
288
+
```
289
+
290
+
To get around this problem the client provides the `init_label_set` method that can be used to initialises the time serie of a metric for a given label set. In the example above we would use it like so:
291
+
292
+
```ruby
293
+
# After declaring the counter we can initiliaze the metric by calling the #init_label_set method
0 commit comments