NewClient connects to addr for StatsD. If addr is empty, returns Noop and nil error. namespace is typically "gh_ost." (metrics are named namespace + short name, e.g. gh_ost.startup). tags are global tags applied to every metric (repeatable --statsd-tags).
(addr string, tags []string, namespace string)
| 25 | // namespace is typically "gh_ost." (metrics are named namespace + short name, e.g. gh_ost.startup). |
| 26 | // tags are global tags applied to every metric (repeatable --statsd-tags). |
| 27 | func NewClient(addr string, tags []string, namespace string) (*Client, error) { |
| 28 | if addr == "" { |
| 29 | return Noop, nil |
| 30 | } |
| 31 | sd, err := statsd.New(addr, |
| 32 | statsd.WithNamespace(namespace), |
| 33 | statsd.WithTags(tags), |
| 34 | statsd.WithoutTelemetry(), |
| 35 | statsd.WithoutOriginDetection(), |
| 36 | statsd.WithClientSideAggregation(), |
| 37 | statsd.WithExtendedClientSideAggregation(), |
| 38 | statsd.WithMaxSamplesPerContext(1_000), |
| 39 | statsd.WithMaxBytesPerPayload(8_172), |
| 40 | statsd.WithAggregationInterval(5*time.Second), |
| 41 | ) |
| 42 | if err != nil { |
| 43 | return nil, err |
| 44 | } |
| 45 | log.Infof("metrics: DogStatsD client connected to %s (namespace: %s)", addr, namespace) |
| 46 | return &Client{sd: sd}, nil |
| 47 | } |
| 48 | |
| 49 | func (c *Client) Gauge(name string, value float64, tags ...string) { |
| 50 | if c.sd == nil { |
searching dependent graphs…