// GetGraphiteContext returns a Graphite context which contains all the information needed // to query Graphite. A nil context is returned if GraphiteHost is not set. func (sc *SystemConf) GetGraphiteContext() graphite.Context { if sc.GraphiteConf.Host == "" { return nil } if len(sc.GraphiteConf.Headers) > 0 { headers := http.Header(make(map[string][]string)) for k, v := range sc.GraphiteConf.Headers { headers.Add(k, v) } return graphite.HostHeader{ Host: sc.GraphiteConf.Host, Header: headers, } } return graphite.Host(sc.GraphiteConf.Host) }
// GraphiteContext returns a Graphite context. A nil context is returned if // GraphiteHost is not set. func (c *Conf) GraphiteContext() graphite.Context { if c.GraphiteHost == "" { return nil } if len(c.GraphiteHeaders) > 0 { headers := http.Header(make(map[string][]string)) for _, s := range c.GraphiteHeaders { kv := strings.Split(s, ":") headers.Add(kv[0], kv[1]) } return graphite.HostHeader{ Host: c.GraphiteHost, Header: headers, } } return graphite.Host(c.GraphiteHost) }
// GraphiteContext returns a Graphite context. A nil context is returned if // GraphiteHost is not set. func (c *Conf) GraphiteContext() graphite.Context { if c.GraphiteHost == "" { return nil } return graphite.Host(c.GraphiteHost) }