{"id":15569230,"url":"https://github.com/mosquito/carbon-client","last_synced_at":"2025-05-12T20:56:55.862Z","repository":{"id":62560893,"uuid":"37222534","full_name":"mosquito/carbon-client","owner":"mosquito","description":"graphite/carbon udp client for sending metrics","archived":false,"fork":false,"pushed_at":"2017-11-03T14:47:57.000Z","size":43,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-10T23:50:19.949Z","etag":null,"topics":["carbon","client-lib","graphite","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mosquito.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-10T21:03:26.000Z","updated_at":"2018-02-07T10:00:14.000Z","dependencies_parsed_at":"2022-11-03T14:45:36.226Z","dependency_job_id":null,"html_url":"https://github.com/mosquito/carbon-client","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mosquito%2Fcarbon-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mosquito%2Fcarbon-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mosquito%2Fcarbon-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mosquito%2Fcarbon-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mosquito","download_url":"https://codeload.github.com/mosquito/carbon-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235048996,"owners_count":18927717,"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":["carbon","client-lib","graphite","python"],"created_at":"2024-10-02T17:23:16.214Z","updated_at":"2025-01-22T02:05:45.671Z","avatar_url":"https://github.com/mosquito.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Carbon Client\n=============\n\n.. image:: https://travis-ci.org/mosquito/carbon-client.svg?branch=master\n    :target: https://travis-ci.org/mosquito/carbon-client\n\n.. image:: https://img.shields.io/pypi/v/carbon-client.svg\n    :target: https://pypi.python.org/pypi/carbon-client/\n    :alt: Latest Version\n\n.. image:: https://img.shields.io/pypi/wheel/carbon-client.svg\n    :target: https://pypi.python.org/pypi/carbon-client/\n\n.. image:: https://img.shields.io/pypi/pyversions/carbon-client.svg\n    :target: https://pypi.python.org/pypi/carbon-client/\n\n.. image:: https://img.shields.io/pypi/l/carbon-client.svg\n    :target: https://pypi.python.org/pypi/carbon-client/\n\n\nClient for sending metrics into carbon server\n\nInitialization\n++++++++++++++\n\nBy default carbon-client creates a client based on os.environ variables:\n\n* CARBON_HOST - Contains one or many endpoints (e.g \"127.0.0.1:2003, 10.2.1.0:2003\")\n* CARBON_NS - it's a namespace for sending metrics (e.g. \"carbon.coal-service\")\n\nActually you can configure this by hands.\n\nExample\n+++++++\n\nThe simple test :\n\n.. code-block:: python\n\n    # You should set ENV variables CARBON_HOST and CARBON_NS\n    # CARBON_HOST might contains multiple destinations (comma separated)\n    from time import sleep\n    from carbon.client import stat\n    from carbon.client.extras import SimpleCounter\n\n    # Will be pended one or two metrics\n    # carbon_client.counter_ok\n    # carbon_client.counter_fail - if exception will be raised\n    # carbon_client is namespace by default.\n    with SimpleCounter(\"counter\"):\n        sleep(1)\n\n    # Will be pended one metric\n    # carbon_client.timer_ok - if exception will be raised\n    # carbon_client.timer_fail - if exception will be raised\n    # carbon_client is namespace by default.\n    with SimpleTimer(\"timer\"):\n        sleep(1)\n\n    # Will be pended n metric\n    # carbon_client.collector\n    # carbon_client is namespace by default.\n    with SimpleCollector(\"collector\") as collector:\n        collector.add(123)\n        collector.add(122)\n        collector.add(-10)\n\n    # all metrics will sent.\n    stat.send()\n\n\nThe advanced test :\n\n.. code-block:: python\n\n    from time import sleep\n    from carbon.client import UDPClient\n    from carbon.client.extras import SimpleCounter, SimpleTimer, SimpleCollector\n\n    # Will be send to multiple destinations\n    client = UDPClient(\"127.0.0.1, 191.168.1.11:2003\", \"test\")\n\n    with SimpleCounter(\"counter\", client):\n        sleep(1)\n\n    with SimpleTimer(\"timer\", client):\n        sleep(1)\n\n    with SimpleCollector(\"collector\", client) as collector:\n        collector.add(123)\n\n    client.send()\n\n\nAnother test :\n\n.. code-block:: python\n\n    from time import sleep\n    from carbon.client import stat\n    from carbon.client import metrics\n\n    # Counter\n    stat['counter'] = metrics.Counter\n    stat['counter'].inc(1)\n    sleep(1)\n    stat['counter'].dec(1)\n\n    # Timer\n    stat['timer'] = metrics.Timer\n    stop_watch = stat['timer'].start()\n    sleep(1)\n    stat['timer'].stop(stop_watch)\n\n    # Collector\n    stat['collector'] = metrics.Collector\n    stat['collector'].add(1)\n    sleep(1)\n    stat['collector'].add(2)\n    sleep(1)\n    stat['collector'].add(3)\n    sleep(1)\n    stat['collector'].add(-10)\n\n    stat.send()\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmosquito%2Fcarbon-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmosquito%2Fcarbon-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmosquito%2Fcarbon-client/lists"}