Replaces tab to 4 whitespaces

This commit also aligns an indent and fixes some syntax.

Change-Id: I6aeb7bd4f27a7853f4152e07999776731a7a1a3b
This commit is contained in:
Yushiro FURUKAWA 2016-09-28 22:03:29 +09:00
parent c8a299e9c8
commit 51edaa7a86
3 changed files with 77 additions and 62 deletions

View File

@ -141,38 +141,53 @@ The [monasca-statsd](https://github.com/openstack/monasca-statsd library provide
of a statsd client but also adds the ability to add dimensions to the statsd metrics for the client.
Here are some examples of how code can be instrumented using calls to monasca-statsd.
```
* Import the module once it's installed.
* Import the module once it's installed.
```python
from monascastatsd import monasca_statsd
statsd = monasca_statsd.MonascaStatsd()
```
* Optionally, configure the host and port if you're running Statsd on a non-standard port.
* Optionally, configure the host and port if you're running Statsd on a non-standard port.
```python
statsd.connect('localhost', 8125)
```
* Increment a counter.
* Increment a counter.
```python
statsd.increment('page_views')
With dimensions:
statsd.increment('page_views', 5, dimensions={'Hostname': 'prod.mysql.abccorp.com'})
```
* Record a gauge 50% of the time.
* Record a gauge 50% of the time.
```python
statsd.gauge('users_online', 91, sample_rate=0.5)
With dimensions:
statsd.gauge('users_online', 91, dimensions={'Origin': 'Dev', 'Environment': 'Test'})
```
* Time a function call.
* Time a function call.
```python
@statsd.timed('page.render')
def render_page():
# Render things...
```
* Time a block of code.
* Time a block of code.
```python
with statsd.time('database_read_time',
dimensions={'db_host': 'mysql1.mycompany.net'}):
# Do something...
```
```
# License
(C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP