github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/internal/trace/v2/value.go (about)

     1  // Copyright 2023 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package trace
     6  
     7  // Value is a dynamically-typed value obtained from a trace.
     8  type Value struct {
     9  	kind   ValueKind
    10  	scalar uint64
    11  }
    12  
    13  // ValueKind is the type of a dynamically-typed value from a trace.
    14  type ValueKind uint8
    15  
    16  const (
    17  	ValueBad ValueKind = iota
    18  	ValueUint64
    19  )
    20  
    21  // Kind returns the ValueKind of the value.
    22  //
    23  // It represents the underlying structure of the value.
    24  //
    25  // New ValueKinds may be added in the future. Users of this type must be robust
    26  // to that possibility.
    27  func (v Value) Kind() ValueKind
    28  
    29  // Uint64 returns the uint64 value for a MetricSampleUint64.
    30  //
    31  // Panics if this metric sample's Kind is not MetricSampleUint64.
    32  func (v Value) Uint64() uint64