knockprobe SDK
Project description
# Knock Business Probes
![CI status](https://codeship.com/projects/73e7a970-966e-0134-0b1c-664c28e74ab1/status?branch=master)
Welcome to Knock Business SDK source code repository
https://knock.center
Copyright (C) 2013/2014/2015/2016 Laurent Champagnac / Laurent Labatut
# Source code
* We are pep8 compliant (as far as we can, with some exemptions)
* We use a right margin of 360 characters (please don't talk me about 80 chars)
* SDK code is located inside "./knock"
* Unittests are located inside "./knock_test"
* All test files must begin with `test_`, should implement setUp & tearDown methods
* All tests must adapt to any running directory
* The whole sdk is backed by [pythonsol lib](https://bitbucket.org/LoloCH/pythonsol)
* The daemon is not using threads but relies on coroutines (gevent greenlets) is use if already loaded before
* We are still bound to python 2.7 (we will move to python 3 later on)
* We are using docstring (:return, :rtype, :param, :type etc..), PyCharm "noinspection", feel free to use them
# Requirements
- Knockdaemon
- An account on [Knock](https://knock.center)
# Install
Knock Probe is available on pypi
```bash
pip install knockprobe
```
# Type of probe
## Gauge
A simple counter, storing a current instant value. Last value provided wins.
Gauges are used in quantity cases. For example, a gauge could be defined by the amount of basket being processed.
## Increment
A simple counter, storing cumulative values and graphing them as delta per second.
Increment is typically an recurrent event. For example, an increment could be defined by the number of basket validated.
## Delay
A simple counter, storing execution time and graphing them by execution time interval.
For example, a delay could be defined by the time of execution of external request.
# Samples
## Push a Gauge Probe
You can push a gauge probe one by one without declare first.
```
from knockprobe import Knock
Knock.gauge('gauge_total_amount', 1257.42)
Knock.commit()
```
Or in bulk mode
```
from knockprobe import Knock
Knock.gauge('gauge_total_amount', 1257.42)
Knock.gauge('gauge_shoes_amount', 854.65)
Knock.commit()
```
## Push a Counter Probe
You can push a curent instant value probe one by one without declare first.
```
from knockprobe import Knock
if do_something():
Knock.increment('counter_do_something', 1)
Knock.commit()
```
Or in bulk mode
```
from knockprobe import Knock
if do_something('step1'):
Knock.increment('counter_do_something', 1)
if do_something('step2'):
Knock.increment('counter_do_something', 1)
Knock.commit()
```
## Delay to Count
Delay to count is a special probe. This probe agregate all execution time in a dict of range of time.
```
from knockprobe import Knock
t1 = Knock.start_delay('time_manager_init')
m = my_manager()
Knock.stop_delay(t1)
t2 = Knock.start_delay('time_manager_exec')
m.exec()
Knock.stop_delay(t1)
Knock.commit()
```
# Important information
Knock lib is an singleton. So for performance improvement you can commit through multiple objects.
For non persistent script, a commit is launch at exit.
So it's not possible to un-commit a probe.
--------
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
![CI status](https://codeship.com/projects/73e7a970-966e-0134-0b1c-664c28e74ab1/status?branch=master)
Welcome to Knock Business SDK source code repository
https://knock.center
Copyright (C) 2013/2014/2015/2016 Laurent Champagnac / Laurent Labatut
# Source code
* We are pep8 compliant (as far as we can, with some exemptions)
* We use a right margin of 360 characters (please don't talk me about 80 chars)
* SDK code is located inside "./knock"
* Unittests are located inside "./knock_test"
* All test files must begin with `test_`, should implement setUp & tearDown methods
* All tests must adapt to any running directory
* The whole sdk is backed by [pythonsol lib](https://bitbucket.org/LoloCH/pythonsol)
* The daemon is not using threads but relies on coroutines (gevent greenlets) is use if already loaded before
* We are still bound to python 2.7 (we will move to python 3 later on)
* We are using docstring (:return, :rtype, :param, :type etc..), PyCharm "noinspection", feel free to use them
# Requirements
- Knockdaemon
- An account on [Knock](https://knock.center)
# Install
Knock Probe is available on pypi
```bash
pip install knockprobe
```
# Type of probe
## Gauge
A simple counter, storing a current instant value. Last value provided wins.
Gauges are used in quantity cases. For example, a gauge could be defined by the amount of basket being processed.
## Increment
A simple counter, storing cumulative values and graphing them as delta per second.
Increment is typically an recurrent event. For example, an increment could be defined by the number of basket validated.
## Delay
A simple counter, storing execution time and graphing them by execution time interval.
For example, a delay could be defined by the time of execution of external request.
# Samples
## Push a Gauge Probe
You can push a gauge probe one by one without declare first.
```
from knockprobe import Knock
Knock.gauge('gauge_total_amount', 1257.42)
Knock.commit()
```
Or in bulk mode
```
from knockprobe import Knock
Knock.gauge('gauge_total_amount', 1257.42)
Knock.gauge('gauge_shoes_amount', 854.65)
Knock.commit()
```
## Push a Counter Probe
You can push a curent instant value probe one by one without declare first.
```
from knockprobe import Knock
if do_something():
Knock.increment('counter_do_something', 1)
Knock.commit()
```
Or in bulk mode
```
from knockprobe import Knock
if do_something('step1'):
Knock.increment('counter_do_something', 1)
if do_something('step2'):
Knock.increment('counter_do_something', 1)
Knock.commit()
```
## Delay to Count
Delay to count is a special probe. This probe agregate all execution time in a dict of range of time.
```
from knockprobe import Knock
t1 = Knock.start_delay('time_manager_init')
m = my_manager()
Knock.stop_delay(t1)
t2 = Knock.start_delay('time_manager_exec')
m.exec()
Knock.stop_delay(t1)
Knock.commit()
```
# Important information
Knock lib is an singleton. So for performance improvement you can commit through multiple objects.
For non persistent script, a commit is launch at exit.
So it's not possible to un-commit a probe.
--------
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
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
knockprobe-1.0.2.tar.gz
(19.6 kB
view details)
Built Distributions
File details
Details for the file knockprobe-1.0.2.tar.gz
.
File metadata
- Download URL: knockprobe-1.0.2.tar.gz
- Upload date:
- Size: 19.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2ecc9ccded8ec9e3e392d14606805aac8e4d57e59f64087e27004b93698ffcc |
|
MD5 | 771fa8aec84b3ce88a711a6f4cba317f |
|
BLAKE2b-256 | 0ffd5c819df03e7f12d413c81d295699780e5b833460921214f185ddc0c854b9 |
File details
Details for the file knockprobe-1.0.2-py3-none-any.whl
.
File metadata
- Download URL: knockprobe-1.0.2-py3-none-any.whl
- Upload date:
- Size: 32.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d36d35acabc943fe1d366588f87b9fcb5b301b81404be7bac6faa2aa769782e |
|
MD5 | 52cadb9fa19a1f3c6200ed7adbad9479 |
|
BLAKE2b-256 | 34547ec2421ddfd9ecbf0999b7c11f5e4a575bebe74ea4aff442ca78b860c099 |
File details
Details for the file knockprobe-1.0.2-py2-none-any.whl
.
File metadata
- Download URL: knockprobe-1.0.2-py2-none-any.whl
- Upload date:
- Size: 32.4 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63ef95c0f44e316df7f711eced9fc51613c8deb28176920d00ff60269b076dcc |
|
MD5 | a553023a13600b5ff97bc82c340df480 |
|
BLAKE2b-256 | eb56ca7624c3a41883e27ad2d2fa62cbf275b6002f45fda8fc7970d69a05a75f |