coco

package
v0.0.0-...-9fc61da Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2015 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Api

func Api(config ApiConfig, tiers *[]Tier, blacklisted *map[string]map[string]int64)

func Blacklist

func Blacklist(updates chan BlacklistItem, blacklisted *map[string]map[string]int64)

func BuildTiers

func BuildTiers(tiers *[]Tier)

BuildTiers sets up tiers so it's ready to dispatch metrics

func Encode

func Encode(packet collectd.Packet) []byte

Encode a Packet into the collectd wire protocol format.

func ExpvarHandler

func ExpvarHandler(w http.ResponseWriter, r *http.Request)

func Filter

func Filter(config FilterConfig, raw chan collectd.Packet, filtered chan collectd.Packet, blacklist chan BlacklistItem)

func Listen

func Listen(config ListenConfig, c chan collectd.Packet)

Listen takes collectd network packets and breaks them into individual samples.

func Measure

func Measure(config MeasureConfig, chans map[string]chan collectd.Packet, tiers *[]Tier)

func MetricName

func MetricName(packet collectd.Packet) string

func Send

func Send(tiers *[]Tier, filtered chan collectd.Packet)

func TierLookup

func TierLookup(params martini.Params, req *http.Request, tiers *[]Tier) []byte

Types

type ApiConfig

type ApiConfig struct {
	Bind string
}

type BlacklistItem

type BlacklistItem struct {
	Packet collectd.Packet
	Time   int64
}

type Config

type Config struct {
	Listen  ListenConfig
	Filter  FilterConfig
	Tiers   map[string]TierConfig
	Api     ApiConfig
	Fetch   FetchConfig
	Measure MeasureConfig
}

type Duration

type Duration struct {
	time.Duration
}

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(text []byte) error

type FetchConfig

type FetchConfig struct {
	Bind         string
	ProxyTimeout Duration `toml:"proxy_timeout"`
	// FIXME(lindsay): RemotePort is a bit of a code smell.
	// Ideally every target could define its own port for collectd + Visage.
	RemotePort string `toml:"remote_port"`
}

func (*FetchConfig) Timeout

func (f *FetchConfig) Timeout() time.Duration

Helper function to provide a default timeout value

type FilterConfig

type FilterConfig struct {
	Blacklist string
}

type ListenConfig

type ListenConfig struct {
	Bind    string
	Typesdb string
}

type MeasureConfig

type MeasureConfig struct {
	TickInterval Duration `toml:"interval"`
}

func (*MeasureConfig) Interval

func (m *MeasureConfig) Interval() time.Duration

Helper function to provide a default interval value

type Tier

type Tier struct {
	Name    string                 `json:"name"`
	Targets []string               `json:"targets"`
	Hash    *consistent.Consistent `json:"-"`
	Shadows map[string]string      `json:"shadows"`
	// map[target]map[sample host]map[sample metric name]last dispatched
	Mappings        map[string]map[string]map[string]int64 `json:"routes"`
	Connections     map[string]net.Conn                    `json:"connections,nil"`
	VirtualReplicas int                                    `json:"virtual_replicas"`
}

func (*Tier) Lookup

func (t *Tier) Lookup(name string) (string, error)

Lookup maps a name to a target in a tier's hash

func (*Tier) SetMagicVirtualReplicaNumber

func (t *Tier) SetMagicVirtualReplicaNumber(i int)

SetMagicVirtualReplicaNumber sets the number of virtual replicas on the hash.

Pass it the number of targets in a tier, and it looks up the optimal number of virtual replicas in the table of magic numbers and uses that on the hash.

The magic numbers are determined from the results output in consistent_test.go.

There are problems with this approach:

  • You can't change the number of virtual replicas on the hash after you've added sites to the hash.
  • If the number of connections actually established is different to the number of virtual replicas we set on the hash, we could get poor hashing performance.

For example, if you tell SetMagicVirtualReplicaNumber you have 12 targets and successfully connect to all of them on boot, your magic number will be 11. But if you can't connect to even one of them, your magic number will be 100, which will provide worse hashing performance.

type TierConfig

type TierConfig struct {
	Targets []string
}

Jump to

Keyboard shortcuts

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