MCPcopy
hub / github.com/github/gh-ost / NewClient

Function NewClient

go/metrics/client.go:27–47  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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).
27func 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
49func (c *Client) Gauge(name string, value float64, tags ...string) {
50 if c.sd == nil {

Callers 2

mainFunction · 0.92

Calls 1

InfofMethod · 0.65

Used in the wild real call sites across dependent graphs

searching dependent graphs…