diff --git a/content/en/docs/languages/go/instrumentation.md b/content/en/docs/languages/go/instrumentation.md index c9b61dc8ddbe..873614be8594 100644 --- a/content/en/docs/languages/go/instrumentation.md +++ b/content/en/docs/languages/go/instrumentation.md @@ -534,6 +534,35 @@ func removeItem() { } ``` +### Using Gauges + +Gauges are used to measure non-additive values when changes occur. + +For example, here's how you might report the current speed of a CPU fan: + +```go +import ( + "net/http" + + "go.opentelemetry.io/otel/metric" +) + +func init() { + speedGauge, err := meter.Int64Gauge( + "cpu.fan.speed", + metric.WithDescription("Speed of CPU fan"), + metric.WithUnit("RPM"), + ) + if err != nil { + panic(err) + } + http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + // hard-code 1500 RPM for demonstrative purposes + speedGauge.Record(r.Context(), 1500) + }) +} +``` + ### Using Histograms Histograms are used to measure a distribution of values over time.