UNKNOWN
Project description
An asyncio library for graphite.
What is aiographite ?
aiographite is Python3 library ultilizing asyncio, designed to help Graphite users to send data into graphite easily.
Installing it globally
You can install aiographite globally with any Python package manager:
pip install aiographite
Quick start
Let’s get started.
"""
Initialize a aiographite instance
"""
loop = asyncio.get_event_loop()
plaintext_protocol = PlaintextProtocol()
aiographite = AIOGraphite(*httpd.address, plaintext_protocol, loop = loop)
await aiographite.connect()
"""
Send a tuple (metric, value , timestamp)
"""
aiographite.send(metric, value, timestamp)
"""
Send a list of tuples List[(metric, value , timestamp)]
"""
aiographite.send_multiple(list)
"""
aiographite library also provides GraphiteEncoder module,
which helps users to send valid metric name to graphite.
For Example: (metric_parts, value ,timestamp)
"""
metric = aiographite.clean_and_join_metric_parts(metric_parts)
aiographite.send(metric, value, timestamp)
Example
A simple example.
from aiographite.protocol import PlaintextProtocol
from aiographite.aiographite import AIOGraphite
import time
import asyncio
LOOP = asyncio.get_event_loop()
SERVER = '127.0.0.1'
PORT = 2003
def test_send_data():
# Initiazlize an aiographite instance
plaintext_protocol = PlaintextProtocol()
aiographite_instance = AIOGraphite(SERVER, PORT, plaintext_protocol, loop = LOOP)
# Connect to graphite server
LOOP.run_until_complete(aiographite_instance.connect())
# Send data
tasks = []
timestamp = time.time()
for i in range(10):
tasks.append(asyncio.ensure_future(aiographite_instance.send("yun_test.aiographite", i, timestamp + 60 * i)))
LOOP.run_until_complete(asyncio.gather(*tasks))
LOOP.close()
def main():
test_send_data()
if __name__ == '__main__':
main()
Development
Run unit tests.
./uranium test
Graphite setup
Do not have graphite instances ? Set up a graphite instance on your local machine!
Please refer:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aiographite-0.1.4.tar.gz
(7.0 kB
view details)
Built Distribution
File details
Details for the file aiographite-0.1.4.tar.gz
.
File metadata
- Download URL: aiographite-0.1.4.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4d2417b40ff844eb3133b35d018a5158f1e5b5f8513ffd08ee51d2b64d6ce37 |
|
MD5 | ea8f13ac9dd9248dd83bb1c4c196a35a |
|
BLAKE2b-256 | 13a2f76d9e67aaca3e59c1a0b19745d4af658ada5faed9210a31c2e3c7f71c2d |
Provenance
File details
Details for the file aiographite-0.1.4-py2.py3-none-any.whl
.
File metadata
- Download URL: aiographite-0.1.4-py2.py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8aebf976e2b6bb281c3269f6501e9e64dd0740e0145e13bef648f0263ce2538 |
|
MD5 | c791701a154ee7fd7e8b955304401310 |
|
BLAKE2b-256 | fe12c5000a76d3517509ba45f3edb1f3018cacd63ee0f4cd39db0552eef6f322 |