{"id":20857395,"url":"https://github.com/unbounce/clojure-dogstatsd-client","last_synced_at":"2025-05-12T07:32:57.712Z","repository":{"id":52589746,"uuid":"119142153","full_name":"unbounce/clojure-dogstatsd-client","owner":"unbounce","description":"A thin veneer over the official java dogstatsd client","archived":false,"fork":false,"pushed_at":"2021-04-24T13:51:52.000Z","size":51,"stargazers_count":18,"open_issues_count":1,"forks_count":6,"subscribers_count":30,"default_branch":"master","last_synced_at":"2024-11-02T02:06:12.996Z","etag":null,"topics":["monitoring","owner-platform-services","ring-middleware","statsd-client"],"latest_commit_sha":null,"homepage":"https://cljdoc.org/d/com.unbounce/clojure-dogstatsd-client/","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/unbounce.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-27T07:10:57.000Z","updated_at":"2024-06-27T02:14:57.000Z","dependencies_parsed_at":"2022-09-24T02:51:03.048Z","dependency_job_id":null,"html_url":"https://github.com/unbounce/clojure-dogstatsd-client","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unbounce%2Fclojure-dogstatsd-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unbounce%2Fclojure-dogstatsd-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unbounce%2Fclojure-dogstatsd-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unbounce%2Fclojure-dogstatsd-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unbounce","download_url":"https://codeload.github.com/unbounce/clojure-dogstatsd-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225130085,"owners_count":17425459,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["monitoring","owner-platform-services","ring-middleware","statsd-client"],"created_at":"2024-11-18T04:38:35.530Z","updated_at":"2024-11-18T04:38:36.182Z","avatar_url":"https://github.com/unbounce.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# clojure-statsd-client\n\n[![Clojars Project](https://img.shields.io/clojars/v/com.unbounce/clojure-dogstatsd-client.svg)](https://clojars.org/com.unbounce/clojure-dogstatsd-client) [![CircleCI](https://circleci.com/gh/unbounce/clojure-dogstatsd-client/tree/master.svg?style=svg)](https://circleci.com/gh/unbounce/clojure-dogstatsd-client/tree/master)\n\nA thin veneer over the officia Java dogstatsd\n[client](https://github.com/DataDog/java-dogstatsd-client). This library favours\npragmatism where possible.\n\nInstrumenting your code should be easy, you shouldn't be forced to thread a\nstatsd client in your code. This library keeps a global client around so your\napplication doesn't need to know about it.\n\n## Usage\n\nSomewhere in your code, you should setup the client:\n\n``` clojure\n(require '[com.unbounce.dogstatsd.core :as statsd])\n\n;; Do this once in your code\n;; Or statd calls will default to use NoOpStatsDClient to avoid nullpointer exception\n;; You can also configure the host/port by setting the environment variables: DD_AGENT_HOST and DD_DOGSTATSD_PORT\n(statsd/setup! :host \"127.0.0.1\" :port 8125 :prefix \"my.app\")\n\n;; Increment or decrement a counter\n(statsd/increment \"counter\")           ; increment by 1\n(statsd/increment \"counter\" {:by 2.5}) ; increment by 2.5\n(statsd/decrement \"another.counter\")   ; decrement by 1\n\n;; Records a value at given time\n(statsd/gauge \"a.gauge\" 10)\n\n;; Record a histogram value (i.e for measuring percentiles)\n(statsd/histogram \"a.histogram\" 10)\n\n;; Time how long body takes and records it to the metric\n(statsd/time! [\"a.timed.body\" {}]\n  (Thread/sleep 100)\n  (Thread/sleep 100))\n\n;; Time how long it takes with a tag/sample-rate\n(statsd/time! [\"my.metric.with.tags\" {:tags #{\"foo\"} :sample-rate 0.3}}]\n  (Thread/sleep 1000))\n\n;; Shutdown client to ensure all messages are emitted to statsd and resources are cleaned up\n(statsd/shutdown!)\n```\n\n### Ring Middleware\n\nThis library also has comes with a ring middleware to capture HTTP requests.\nSee `com.unbounce.dogstatsd.ring` for more information.\n\nThe middleware provides these metrics:\n\n- http.1xx  counter of 1xx responses\n- http.2xx  counter of 2xx responses\n- http.3xx  counter of 3xx responses\n- http.4xx  counter of 4xx responses\n- http.5xx  counter of 5xx responses\n- http.count     counter for total requests\n- http.exception counter for exceptions raised\n- http.duration  histogram of request duration\n\nUsage:\n\n```\n(require '[com.unbounce.dogstatsd.ring :as dogstatsd.ring])\n\n;; by default instrument all requests\n(def handler (-\u003e (constantly {:status 200})\n                 (dogstatsd.ring/wrap-http-metrics)))\n\n;; when sample-rate is set, only 20% of requests will be instrumented\n(def handler (-\u003e (constantly {:status 200})\n                 (dogstatsd.ring/wrap-http-metrics {:sample-rate 0.2})))\n\n```\n\n\n\n## License\n\nCopyright © 2018 Unbounce Marketing Solutions Inc.\n\nDistributed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funbounce%2Fclojure-dogstatsd-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funbounce%2Fclojure-dogstatsd-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funbounce%2Fclojure-dogstatsd-client/lists"}