You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kratos/contrib/metrics/datadog/client.go

29 lines
550 B

package datadog
import (
"fmt"
"github.com/DataDog/datadog-go/statsd"
)
var defaultClient *statsd.Client
func init() {
var err error
// use the default env: DD_AGENT_HOST/DD_DOGSTATSD_PORT/8125
if defaultClient, err = statsd.New(""); err != nil {
panic(fmt.Sprintf("datadog client initialize error %v\n", err))
}
}
func withValues(labels, values []string) []string {
if len(labels) != len(values) {
return nil
}
lvs := make([]string, 0, len(labels))
for i, v := range values {
lvs = append(lvs, labels[i]+":"+v)
}
return lvs
}