import "github.com/luci/luci-go/common/tsmon/target"
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.
context.go flags.go populate.go target.go target_type.go
var ( // NilType is given if a metric was created without the TargetType specified. NilType = types.TargetType{} DeviceType = (*NetworkDevice)(nil).Type() TaskType = (*Task)(nil).Type() )
Get returns the target set in this context.
NewFromFlags returns a Target configured from commandline flags.
func RootLabel(key string, value interface{}) *pb.MetricsCollection_RootLabels
Set returns a new context with the given target set. If this context is passed to metric Set, Get or Incr methods the metrics for that target will be affected. A nil target means to use the default target.
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.
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.
Register adds tsmon target related flags to a FlagSet.
SetDefaultsFromHostname computes the expensive default values for hostname, region and network fields.
A NetworkDevice is a machine that has a hostname.
func (t *NetworkDevice) Clone() types.Target
Clone returns a copy of this object.
func (t *NetworkDevice) Hash() uint64
Hash returns a uint64 hash of this target.
func (t *NetworkDevice) PopulateProto(d *pb.MetricsCollection)
PopulateProto implements Target.
func (t *NetworkDevice) Type() types.TargetType
Type returns the TargetType of NetworkDevice.
SysInfo overrides system's hostname and region for tests.
type Task struct { ServiceName string JobName string DataCenter string HostName string TaskNum int32 }
A Task is a process or a service running on one or more machine.
Clone returns a copy of this object.
Hash returns a uint64 hash of this target.
func (t *Task) PopulateProto(d *pb.MetricsCollection)
PopulateProto implements Target.
func (t *Task) Type() types.TargetType
Type returns the TargetType of Task.
Package target imports 13 packages (graph) and is imported by 3 packages. Updated 2019-12-14. Refresh now. Tools for package owners.