Back to godoc.org

Package field

v0.0.0-...-d4769a7
Latest Go to latest

The latest major version is .

Published: Aug 1, 2020 | License: Apache-2.0 | Module: github.com/luci/luci-go

Overview

Package field contains constructors for metric field definitions.

When you create a metric you must specify the names and types of the fields that can appear on that metric. When you increment the metric's value you must then pass values for all the fields you defined earlier.

Index

func Canonicalize

func Canonicalize(fields []Field, fieldVals []interface{}) ([]interface{}, error)

Canonicalize returns a copy of fieldVals converted to the canonical types for the metric's fields (string, int64, or bool). Canonicalize returns an error if fieldVals is the wrong length or contains value of the wrong type.

func Hash

func Hash(fieldVals []interface{}) uint64

Hash returns a uint64 hash of fieldVals.

func Serialize

func Serialize(fields []Field, values []interface{}) []*pb.MetricsData_MetricField

Serialize returns a slice of ts_mon_proto.MetricsData.MetricsField messages representing the field names and values.

func SerializeDescriptor

func SerializeDescriptor(fields []Field) []*pb.MetricsDataSet_MetricFieldDescriptor

SerializeDescriptor returns a slice of field descriptors, representing just the names and types of fields.

type Field

type Field struct {
	Name string
	Type Type
}

Field is the definition of a metric field. It has a name and a type (string, int or bool).

func Bool

func Bool(name string) Field

Bool returns a new bool-typed field.

func Int

func Int(name string) Field

Int returns a new int-typed field. Internally values for these fields are stored as int64s.

func String

func String(name string) Field

String returns a new string-typed field.

func (Field) String

func (f Field) String() string

type Type

type Type int
const (
	StringType Type = iota + 1
	IntType
	BoolType
)

func (Type) String

func (t Type) String() string

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier