Verified Commit 1e518f23 authored by Hercules Merscher's avatar Hercules Merscher 🌴
Browse files

docs: README

parent ee62f3aa
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -161,6 +161,28 @@ experience.checkpoint
experience.complete
```

#### Observing a Past Experience

When an action already happened and you want to record its duration retroactively, use `observed`. It fires the start and end metrics without registering in the active context:

```ruby
duration_s = Time.now - start_time_of_past_action

Labkit::UserExperienceSli.observed('merge_request_creation', duration_s: duration_s)
```

You can also signal that an error occurred during the action:

```ruby
Labkit::UserExperienceSli.observed('merge_request_creation', duration_s: duration_s, error: true)
```

Extra labels are forwarded to both the start and end log events:

```ruby
Labkit::UserExperienceSli.observed('merge_request_creation', duration_s: duration_s, worker: 'MyWorker')
```

#### Resuming Experiences

You can resume a user experience SLI that was previously started and stored in the context. This is useful for distributed operations or when work spans multiple processes.