Created
July 31, 2017 10:27
-
-
Save YarekTyshchenko/db4ebbc11037d39cc26b9bbe20a67868 to your computer and use it in GitHub Desktop.
Makefile statsd instrumentation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
STATSD_HOST ?= graphite.example.com | |
STATSD_PREFIX := development.makefile | |
# Start timer | |
# $(call start,test.counter) | |
define start | |
-@perl -MTime::HiRes=time -we"open my \$$f, '>', '._timing_$(1)'; print \$$f int time * 1000; close \$$f" | |
endef | |
# End timer, and send metric | |
# $(call end,test.counter) | |
define end | |
-@printf "$(STATSD_PREFIX).%s:%d|ms\n" $(1) $$(perl -MTime::HiRes=time -we"open my \$$f, '<', '._timing_$(1)'; print int time * 1000 - <\$$f>") | nc -w 0 -u $(STATSD_HOST) 8125 | |
-@rm ._timing_$(1) | |
endef | |
# Send counter metric | |
# $(call count,test.counter) | |
define count | |
-@printf "$(STATSD_PREFIX).%s:1|c\n" $(1) | nc -w 0 -u $(STATSD_HOST) 8125 | |
endef |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment