smira / go-statsd Goto Github PK
View Code? Open in Web Editor NEWGo statsd client library with zero allocation overhead, great performance and reconnects
License: MIT License
Go statsd client library with zero allocation overhead, great performance and reconnects
License: MIT License
Hello,
with your statsd client I can't send metrics to any statsd server. In my case it's telegraf on localhost:2002. I'm using go 1.13.
I tested it from cmd line via
$ echo "foobar.test,region=eu:$(shuf -i 10-999 -n 1)|ms" | nc -w 1 -u localhost 2002
This works.
`> select * from "foobar.test"
name: foobar.test
time count host lower mean metric_type region stddev sum upper
2019-09-23T13:04:10Z 1 jenkinssol 733 733 timing eu 0 733 733`
What am I doing wrong?
My code
`package main
import (
"github.com/smira/go-statsd"
)
func main() {
client := statsd.NewClient("localhost:2002",
statsd.MaxPacketSize(1400),
statsd.MetricPrefix("foobar."))
start := time.Now()
client.Incr("requests.http", 1)
client.PrecisionTiming("requests.route.api.latency", time.Since(start))
client.Close()
}`
Are you planning to support setting the sample rate on the client?
Hello,
yesterday i saw your keynote at GopherCon Russia 2018. Excellent work!
Please, add possibility to add tags, maybe as client Option:
InfluxDB tag format: ,tag1=payroll,region=us-west
Datadog tag format: |#tag1:value1,tag2:value2
It's boring to write every time c.incr('some.data,rack=v6,region=eu,switch=12')
;)
Thanks!
I've been trying out the library in a component that receives periodic remote writes from prometheus, converts metrics and forwards to a statsd(udp) destination. With the default initialization, I've been observing logs from the library indicating packet loss.
I then tried bumping up the buffer pool capacity, send queue capacity and the send loop, after which these error logs disappeared, but I'm still observing a small amount of dropped metrics in the destination.
Is this something anyone else has observed?
looking at telegraf default config, we can see that he seperate the metric by a dot.
if you define a Prefix with go-statsd, you have to add a dot at the end or else telegraf will not move it on.
should we add dot at the end of the prefix by default ?
Line 137 in af08c05
Hello!
Could you add an okmeter tag support?
I guess I can't simply use basic TagFormat because separator is a string _is_
// Tag types
const (
typeString = iota
typeInt64
)
// Tag is metric-specific tag
type Tag struct {
name string
strvalue string
intvalue int64
typ byte
}
We need to sanitize tag names and values.
Hello.
I'm using your go-statsd to count events in my logs shipper app.
Everytimes it receives an event, it increases stat.inputEvents by one. Then, every second, I push that counter to telegraf server. Then, I use grafana to visualize this stat:
SELECT "value" FROM "stat_inputEvents" WHERE $timeFilter GROUP BY time($interval)
My settings is:
statsd.NewClient(statsdHost + ":" + strconv.Itoa(statsdPort), statsd.MaxPacketSize(400), statsd.MetricPrefix(""), statsd.FlushInterval(time.Second))
Since I flush it every second. Shouldn't this graph show Events Per Second of my shipper?
But it has almost 300k EPS average while the source that provides events to my shipper only has 60k EPS...
Can you tell me what I did wrong here please? Thank you so much!
Hi,
Is go-statsd
compatible with brubeck (https://github.com/github/brubeck)?
It seems like counters work well, but other types of metrics (gauge, timers) not.
When build with GOARCH=386 I get this whenever reportLoop ticks:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x8049fcc]
goroutine 8 [running]:
runtime/internal/atomic.Xchg64(0xa8794e4, 0x0, 0x0, 0x1, 0x1)
/usr/local/go/src/runtime/internal/atomic/asm_386.s:151 +0xc
github.com/smira/go-statsd.(*transport).reportLoop(0xa8794a0, 0xf8475800, 0xd, 0x85bf3f0, 0xa8568d0)
/usr/src/app/vendor/github.com/smira/go-statsd/loops.go:161 +0x111
created by github.com/smira/go-statsd.NewClient
/usr/src/app/vendor/github.com/smira/go-statsd/client.go:112 +0x3f7
Fortunately I can just switch to amd64 and it works
// ReconnectInterval controls UDP socket reconnects
//
// Reconnecting is important to follow DNS changes, e.g. in
// dynamic container environments like K8s where statsd server
// instance might be relocated leading to new IP address.
//
// By default reconnects are disabled
func ReconnectInterval(interval time.Duration) Option {
return func(c *ClientOptions) {
c.ReconnectInterval = interval
}
}
// RetryTimeout controls how often client should attempt reconnecting
// to statsd server on failure
//
// Default value is 5 seconds
func RetryTimeout(timeout time.Duration) Option {
return func(c *ClientOptions) {
c.RetryTimeout = timeout
}
}
Hey all,
Is there any interest in making the logger here configurable? I want to use go-statsd but am logging out to structured JSON and would like to use the library with different loggers. I'd be happy to contribute this if it's something the maintainer would accept.
I would like to be able to make new clients from an existing one, which extended global tags.
client := statsd.NewClient(statsd.DefaultTags(statsd.StringTag("foo", "bar")))
extra := []statsd.Tags{statsd.StringTag("url", "/foo")}
child := client.WithTags(extra...)
child.Incr("counter", 10) // Tags: foo=bar,url=/foo
let me know what you are your thoughts.
Hi!
thanks for this statsd golang client! I'm using it and noticed there's no support for float gauges/counters, is this something you'd be interested in having?
A project I'm working on is reviewing different StatsD client implementations.
Is this client maintained, or should I opt for another?
Hi!
I ran into a weird issue running this piece of code:
package main
import (
"log"
"github.com/smira/go-statsd"
)
func main() {
client := statsd.NewClient("BOOM:BOOM")
if err := client.Close(); err != nil {
log.Fatalf("could not close, but got error: %v", err)
}
log.Print("all good!")
}
It hangs forever (apparently) saying:
[STATSD] 2019/05/15 18:33:38 [STATSD] Error connecting to server: dial udp: address udp/BOOM: unknown port
I would have expected Close()
to return an error, maybe telling me the address is incorrect or that it cannot be resolved.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.