Monasca状态Python客户端

monasca-statsd的Python项目详细描述


团队和存储库标记

https://governance.openstack.org/tc/badges/monasca-statsd.svg

Monasca Statsd Python客户端。

快速入门指南

首先用pipeasy_install:安装库

# Install in system python ...
sudo pip install monasca-statsd

# .. or into a virtual env
pip install monasca-statsd

然后开始检测代码:

# Import the module.
import monascastatsd as mstatsd

# Create the connection
conn = mstatsd.Connection(host='localhost', port=8125)

# Create the client with optional dimensions
client = mstatsd.Client(connection=conn, dimensions={'env': 'test'})

NOTE: You can also create a client without specifying the connection and it will create the client
with the default connection information for the monasca-agent statsd processor daemon
which uses host='localhost' and port=8125.

client = mstatsd.Client(dimensions={'env': 'test'})

# Increment and decrement a counter.
counter = client.get_counter(name='page.views')

counter.increment()
counter += 3

counter.decrement()
counter -= 3

# Record a gauge 50% of the time.
gauge = client.get_gauge('gauge', dimensions={'env': 'test'})

gauge.send('metric', 123.4, sample_rate=0.5)

# Sample a histogram.
histogram = client.get_histogram('histogram', dimensions={'test': 'True'})

histogram.send('metric', 123.4, dimensions={'color': 'red'})

# Time a function call.
timer = client.get_timer()

@timer.timed('page.render')
def render_page():
    # Render things ...
    pass

# Time a block of code.
timer = client.get_timer()

with timer.time('t'):
    # Do stuff
    time.sleep(2)

# Add dimensions to any metric.
histogram = client.get_histogram('my_hist')
histogram.send('query.time', 10, dimensions = {'version': '1.0', 'environment': 'dev'})

反馈

建议功能、报告错误或参与常规 讨论,转到StoryBoard

许可证

请参阅许可证文件。代码最初是从datadog的 dogstatsd python,因此是双许可证。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java JDBC URL DB2编码字符   java远程jprofiler集成   Java8中日期对象的after函数问题   Java Swing GlassPane拖动性能   Java中的递归导致堆栈溢出错误   JavaJersey客户端3。Android上的x   java Exchange日历,创建约会和唯一ID   java将键盘布局从AZERTY转换为QWERTY   java无法反序列化启动数组JSON/Spring MVC之外的对象实例   java创建一个Word(.doc)文件,将其转换为PDF和HTML,无需打开Office端口   java操作超时tomcat amazon服务器   java如何创建通用XSD类型   java将代码的测量时间添加到列表中,并获取最小/最大/中间/平均时间   JSpinner的fireStateChanged()方法存在java问题   通过蛮力的爪哇硬币组合