luci: go.chromium.org/luci/common/tsmon/target Index | Files

package target

import "go.chromium.org/luci/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.

Index

Package Files

context.go flags.go populate.go target.go targetType.go

Constants

const (
    // DeviceType is a device target type.
    DeviceType = Type("device")
    // TaskType represents a task target type.
    TaskType = Type("task")
)

func Get Uses

func Get(ctx context.Context) types.Target

Get returns the target set in this context.

func GetWithDefault Uses

func GetWithDefault(ctx context.Context, def types.Target) types.Target

GetWithDefault is like Get, except it returns the given default value if there is no target set in the context.

func NewFromFlags Uses

func NewFromFlags(fl *Flags) (types.Target, error)

NewFromFlags returns a Target configured from commandline flags.

func Set Uses

func Set(ctx context.Context, t types.Target) context.Context

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 Uses

type Flags struct {
    TargetType      Type
    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 Uses

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) Register Uses

func (fl *Flags) Register(f *flag.FlagSet)

Register adds tsmon target related flags to a FlagSet.

func (*Flags) SetDefaultsFromHostname Uses

func (fl *Flags) SetDefaultsFromHostname()

SetDefaultsFromHostname computes the expensive default values for hostname, region and network fields.

type NetworkDevice Uses

type NetworkDevice struct {
    Metro     string
    Role      string
    Hostname  string
    Hostgroup string
}

A NetworkDevice is a machine that has a hostname.

func (*NetworkDevice) Clone Uses

func (t *NetworkDevice) Clone() types.Target

Clone returns a copy of this object.

func (*NetworkDevice) Hash Uses

func (t *NetworkDevice) Hash() uint64

Hash returns a uint64 hash of this target.

func (*NetworkDevice) PopulateProto Uses

func (t *NetworkDevice) PopulateProto(d *pb.MetricsCollection)

PopulateProto implements Target.

type SysInfo Uses

type SysInfo struct {
    Hostname string
    Region   string
}

SysInfo overrides system's hostname and region for tests.

type Task Uses

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.

func (*Task) Clone Uses

func (t *Task) Clone() types.Target

Clone returns a copy of this object.

func (*Task) Hash Uses

func (t *Task) Hash() uint64

Hash returns a uint64 hash of this target.

func (*Task) PopulateProto Uses

func (t *Task) PopulateProto(d *pb.MetricsCollection)

PopulateProto implements Target.

type Type Uses

type Type string

Type is a target type enumeration.

func (*Type) Set Uses

func (tt *Type) Set(v string) error

Set implements flag.Value.

func (*Type) String Uses

func (tt *Type) String() string

Package target imports 12 packages (graph) and is imported by 17 packages. Updated 2018-10-19. Refresh now. Tools for package owners.