@@ -251,7 +251,7 @@ business metric such as transactions.
251251All metrics can be annotated with labels: additional qualifiers that help describe what
252252subdivision of the measurements the metric represents.
253253
254- The following is an example of metric usage:
254+ The following is an example of counter usage:
255255
256256``` java
257257// Gets or creates a named meter instance
@@ -271,6 +271,32 @@ BoundLongCounter someWorkCounter = counter.bind("Key", "SomeWork");
271271// Record data
272272someWorkCounter. add(123 );
273273
274+ // Alternatively, the user can use the unbounded counter and explicitly
275+ // specify the labels set at call-time:
276+ counter. add(123 , " Key" , " SomeWork" );
277+ ```
278+
279+ ` Observer ` is an additional instrument supporting an asynchronous API and
280+ collecting metric data on demand, once per collection interval.
281+
282+ The following is an example of observer usage:
283+
284+ ``` java
285+ // Build observer e.g. LongObserver
286+ LongObserver observer = meter
287+ .observerLongBuilder(" cpu_usage" )
288+ .setDescription(" CPU Usage" )
289+ .setUnit(" ms" )
290+ .build();
291+
292+ observer. setCallback(
293+ new LongObserver .Callback<LongObserver . ResultLongObserver >() {
294+ @Override
295+ public void update (ResultLongObserver result ) {
296+ // long getCpuUsage()
297+ result. observe(getCpuUsage(), " Key" , " SomeWork" );
298+ }
299+ });
274300```
275301
276302## Tracing SDK Configuration
0 commit comments