field

package
v0.0.0-...-1643519 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2024 License: Apache-2.0 Imports: 4 Imported by: 24

Documentation

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

Constants

This section is empty.

Variables

This section is empty.

Functions

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.

Types

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL