File tree 1 file changed +29
-0
lines changed
content/en/docs/languages/go
1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -534,6 +534,35 @@ func removeItem() {
534
534
}
535
535
```
536
536
537
+ ### Using Gauges
538
+
539
+ Gauges are used to measure non-additive values when changes occur.
540
+
541
+ For example, here's how you might report the current speed of a CPU fan:
542
+
543
+ ``` go
544
+ import (
545
+ " net/http"
546
+
547
+ " go.opentelemetry.io/otel/metric"
548
+ )
549
+
550
+ func init () {
551
+ speedGauge , err := meter.Int64Gauge (
552
+ " cpu.fan.speed" ,
553
+ metric.WithDescription (" Speed of CPU fan" ),
554
+ metric.WithUnit (" RPM" ),
555
+ )
556
+ if err != nil {
557
+ panic (err)
558
+ }
559
+ http.HandleFunc (" /" , func (w http.ResponseWriter , r *http.Request ) {
560
+ // hard-code 1500 RPM for demonstrative purposes
561
+ speedGauge.Record (r.Context (), 1500 )
562
+ })
563
+ }
564
+ ```
565
+
537
566
### Using Histograms
538
567
539
568
Histograms are used to measure a distribution of values over time.
You can’t perform that action at this time.
0 commit comments