Standard library / runtime/metrics

metrics.Sample

Pairs a metric name with its most recently read Value. Reusing the slice is efficient but not safe during concurrent access. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
type Sample struct {  Name string
  Value Value}

Working Example

Example Snippetgo
package main
import (  "fmt"  "runtime/metrics")
func main() {  s := []metrics.Sample{{Name: "/gc/heap/allocs:bytes"}}  metrics.Read(s)  fmt.Println(s[0].Name == "/gc/heap/allocs:bytes")}
Go Reference