Documentation ¶
Overview ¶
Package target contains information about the thing that is sending metrics - either a NetworkDevice (a machine) or a Task (a service). There is a default target that is usually configured with commandline flags (flags.go), but a target can also be passed through the Context (context.go) if you need to set metric values for a different target.
Index ¶
- Variables
- func Get(ctx context.Context, tt types.TargetType) types.Target
- func NewFromFlags(fl *Flags) (types.Target, error)
- func RootLabel(key string, value any) *pb.MetricsCollection_RootLabels
- func Set(ctx context.Context, t types.Target) context.Context
- type Flags
- type NetworkDevice
- type SysInfo
- type Task
Constants ¶
This section is empty.
Variables ¶
var ( // NilType is given if a metric was created without the TargetType specified. NilType = types.TargetType{} DeviceType = (*NetworkDevice)(nil).Type() TaskType = (*Task)(nil).Type() )
Functions ¶
func NewFromFlags ¶
NewFromFlags returns a Target configured from commandline flags.
Types ¶
type Flags ¶
type Flags struct { TargetType types.TargetType DeviceHostname string DeviceRegion string DeviceRole string DeviceNetwork string TaskServiceName string TaskJobName string TaskRegion string TaskHostname string TaskNumber int AutoGenHostname bool // If nil, system info is computed from the actual host. Used // in tests. SysInfo *SysInfo }
Flags defines command line flags related to tsmon targets. Use NewFlags() to get a Flags struct with sensible default values.
func NewFlags ¶
func NewFlags() Flags
NewFlags returns a Flags struct with sensible default values. Hostname, region and network flags are expensive to compute, so get assigned default values later in SetDefaultsFromHostname.
func (*Flags) SetDefaultsFromHostname ¶
func (fl *Flags) SetDefaultsFromHostname()
SetDefaultsFromHostname computes the expensive default values for hostname, region and network fields.
type NetworkDevice ¶
A NetworkDevice is a machine that has a hostname.
func (*NetworkDevice) Clone ¶
func (t *NetworkDevice) Clone() types.Target
Clone returns a copy of this object.
func (*NetworkDevice) Hash ¶
func (t *NetworkDevice) Hash() uint64
Hash returns a uint64 hash of this target.
func (*NetworkDevice) PopulateProto ¶
func (t *NetworkDevice) PopulateProto(d *pb.MetricsCollection)
PopulateProto implements Target.
func (*NetworkDevice) Type ¶
func (t *NetworkDevice) Type() types.TargetType
Type returns the TargetType of NetworkDevice.