From 8074237a5f56e156d11fb28b09f53a87136d21dc Mon Sep 17 00:00:00 2001 From: Mike Fiedler Date: Sat, 2 Apr 2016 19:50:15 -0400 Subject: [PATCH] statsd.cr, v0.1.0 - Create a CHANGELOG.md file - Add benchmark.cr to examples - Update README.md - Update Makefile for current targets --- CHANGELOG.md | 8 ++++++++ LICENSE | 2 +- Makefile | 15 +++++++++------ README.md | 22 +++++++++++----------- bin/.gitkeep | 0 examples/benchmark.cr | 14 ++++++++++++++ 6 files changed, 43 insertions(+), 18 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 bin/.gitkeep create mode 100644 examples/benchmark.cr diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..8e1e947 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,8 @@ +# Change Log + +All notable changes to this project will be documented in this file. +This project aims to adhere to [Semantic Versioning](http://semver.org/). + +# 0.1.0 / 2016-04-01 + +- Initial release, supporting all statsd spec & extended spec for histograms and tags. diff --git a/LICENSE b/LICENSE index f175791..4bac70b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015 Mike Fiedler +Copyright (c) 2015,2016 Mike Fiedler Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Makefile b/Makefile index 550d5df..9b14e2e 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,15 @@ -.PHONY: all build clean format spec release +.PHONY: all benchmark clean docs format spec release -all: build +all: spec -build: - crystal build --stats -o bin/statsd src/statsd.cr +benchmark: clean + crystal run --release examples/benchmark.cr clean: - rm -fr .crystal/ bin/statsd + rm -fr .crystal/ doc/ bin/* + +docs: + crystal docs format: crystal tool format @@ -15,4 +18,4 @@ spec: crystal spec release: clean - crystal build --stats -o bin/statsd --release src/statsd.cr + # TODO: shards release diff --git a/README.md b/README.md index 6a797c1..9b52cb3 100644 --- a/README.md +++ b/README.md @@ -17,30 +17,30 @@ dependencies: ## Usage - ```crystal require "statsd" statsd = Statsd::Client.new statsd.increment "myapp.login_page", 1 -``` - -TODO: Write usage instructions here +# Datadog-compliant statsd tags: +statsd.increment "page.views", tags: ["page:login", "app:myapp"] +``` -## Development +See `examples/test.cr` for more. -TODO: Write development instructions here ## Contributing 1. Fork it ( https://github.com/[your-github-name]/statsd/fork ) 2. Create your feature branch (git checkout -b my-new-feature) -3. Commit your changes (git commit -am 'Add some feature') -4. Push to the branch (git push origin my-new-feature) -5. Create a new Pull Request +3. Test your changes with `make spec` +4. Commit your changes (git commit -am 'Add some feature') +5. Push to the branch (git push origin my-new-feature) +6. Create a new Pull Request + ## Contributors -Leans heavily on [syslog.cr](https://github.com/comandeo/syslog.cr) and [statsd](https://github.com/reinh/statsd) for inspiration. +Inspired by [syslog.cr](https://github.com/comandeo/syslog.cr) and [statsd](https://github.com/reinh/statsd). -- [miketheman](https://github.com/miketheman) Mike Fiedler - creator, maintainer +- [@miketheman](https://github.com/miketheman) Mike Fiedler - creator, maintainer diff --git a/bin/.gitkeep b/bin/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/examples/benchmark.cr b/examples/benchmark.cr new file mode 100644 index 0000000..10da08f --- /dev/null +++ b/examples/benchmark.cr @@ -0,0 +1,14 @@ +require "benchmark" +require "../src/statsd.cr" + +Benchmark.ips do |x| + statsd = Statsd::Client.new + + x.report("increments") { statsd.increment "page.views" } + x.report("increments w/tags") { statsd.increment "page.views", tags: ["foo:bar"] } + x.report("decrements") { statsd.decrement "page.views" } + x.report("gauges") { statsd.gauge("users.current", 5) } + x.report("gauges w/tags") { statsd.gauge("users.current", 5, tags: ["foo:bar"]) } + x.report("timing") { statsd.timing("db.query", 100) } + x.report("time") { statsd.time("timed.block") { true } } +end