diff options
author | Elad <theman@elad.im> | 2018-12-11 16:21:58 +0800 |
---|---|---|
committer | Anton Evangelatov <anton.evangelatov@gmail.com> | 2018-12-11 16:21:58 +0800 |
commit | bb724080cac9fa36ec6b638cfd5cf0e54bc23362 (patch) | |
tree | 355425051728e3c3dd89565feefc46a81a3302f7 /metrics/influxdb | |
parent | b2aac658b0e366f128eda5e057e8e1bf5ec4e427 (diff) | |
download | go-tangerine-bb724080cac9fa36ec6b638cfd5cf0e54bc23362.tar go-tangerine-bb724080cac9fa36ec6b638cfd5cf0e54bc23362.tar.gz go-tangerine-bb724080cac9fa36ec6b638cfd5cf0e54bc23362.tar.bz2 go-tangerine-bb724080cac9fa36ec6b638cfd5cf0e54bc23362.tar.lz go-tangerine-bb724080cac9fa36ec6b638cfd5cf0e54bc23362.tar.xz go-tangerine-bb724080cac9fa36ec6b638cfd5cf0e54bc23362.tar.zst go-tangerine-bb724080cac9fa36ec6b638cfd5cf0e54bc23362.zip |
cmd/swarm, metrics, swarm/api/client, swarm/storage, swarm/metrics, swarm/api/http: add instrumentation (#18274)
Diffstat (limited to 'metrics/influxdb')
-rw-r--r-- | metrics/influxdb/influxdb.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/metrics/influxdb/influxdb.go b/metrics/influxdb/influxdb.go index 31a5c21b5..c4ef92723 100644 --- a/metrics/influxdb/influxdb.go +++ b/metrics/influxdb/influxdb.go @@ -58,6 +58,34 @@ func InfluxDBWithTags(r metrics.Registry, d time.Duration, url, database, userna rep.run() } +// InfluxDBWithTagsOnce runs once an InfluxDB reporter and post the given metrics.Registry with the specified tags +func InfluxDBWithTagsOnce(r metrics.Registry, url, database, username, password, namespace string, tags map[string]string) error { + u, err := uurl.Parse(url) + if err != nil { + return fmt.Errorf("Unable to parse InfluxDB. url: %s, err: %v", url, err) + } + + rep := &reporter{ + reg: r, + url: *u, + database: database, + username: username, + password: password, + namespace: namespace, + tags: tags, + cache: make(map[string]int64), + } + if err := rep.makeClient(); err != nil { + return fmt.Errorf("Unable to make InfluxDB client. err: %v", err) + } + + if err := rep.send(); err != nil { + return fmt.Errorf("Unable to send to InfluxDB. err: %v", err) + } + + return nil +} + func (r *reporter) makeClient() (err error) { r.client, err = client.NewClient(client.Config{ URL: r.url, |