Skip to content

Commit

Permalink
update timer docs for deprecation (#154)
Browse files Browse the repository at this point in the history
Update docs to stop recommending a deprecated method.
  • Loading branch information
brharrington authored Jan 18, 2024
1 parent 1db64e7 commit 12a5616
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions docs/spectator/lang/java/meters/timer.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Then wrap the call you need to measure, preferably using a lambda:

```java
public Response handle(Request request) {
return requestLatency.record(() -> handleImpl(request));
return requestLatency.recordRunnable(() -> handleImpl(request));
}
```

Expand Down Expand Up @@ -75,9 +75,9 @@ public class MetadataService {
```

The id value returned by the `start` method is used to keep track of a particular task being
measured by the Timer. It must be stopped using the provided id. Note that unlike a regular Timer
that does not do anything until the final duration is recorded, a long duration Timer will report
as two Gauges:
measured by the LongTaskTimer. It must be stopped using the provided id. Note that unlike a
regular Timer that does not do anything until the final duration is recorded, a LongTaskTimer
will report as two Gauges:

* `duration`: total duration spent within all currently running tasks.
* `activeTasks`: number of currently running tasks.
Expand All @@ -90,11 +90,3 @@ e.g., update a different Timer, if an exception is thrown.
* Being a Gauge, it is inappropriate for short tasks. In particular, Gauges are sampled and if it
is not sampled during the execution, or the sampling period is a significant subset of the expected
duration, then the duration value will not be meaningful.

Like a regular Timer, the duration Timer also supports using a lambda to simplify the common case:

```java
private void refresh() {
metadataRefresh.record(this::refreshImpl);
}
```

0 comments on commit 12a5616

Please sign in to comment.