# Knock Business Probes

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

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
Release files for knockprobe 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| knockprobe-1.0.2.tar.gz | 19.6 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| knockprobe-1.0.2-py3-none-any.whl | Python 3 | none | any | Details |
| knockprobe-1.0.2-py2-none-any.whl | Python 2 | none | any | Details |
Total release size:84.4 kB
Release files / knockprobe-1.0.2.tar.gz
| Download URL | knockprobe-1.0.2.tar.gz |
|---|---|
| Size | 19.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d2ecc9ccded8ec9e3e392d14606805aac8e4d57e59f64087e27004b93698ffcc
|
|
BLAKE2b-256 checksum How to use checksums |
0ffd5c819df03e7f12d413c81d295699780e5b833460921214f185ddc0c854b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / knockprobe-1.0.2-py3-none-any.whl
| Download URL | knockprobe-1.0.2-py3-none-any.whl |
|---|---|
| Size | 32.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8d36d35acabc943fe1d366588f87b9fcb5b301b81404be7bac6faa2aa769782e
|
|
BLAKE2b-256 checksum How to use checksums |
34547ec2421ddfd9ecbf0999b7c11f5e4a575bebe74ea4aff442ca78b860c099
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / knockprobe-1.0.2-py2-none-any.whl
| Download URL | knockprobe-1.0.2-py2-none-any.whl |
|---|---|
| Size | 32.4 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
63ef95c0f44e316df7f711eced9fc51613c8deb28176920d00ff60269b076dcc
|
|
BLAKE2b-256 checksum How to use checksums |
eb56ca7624c3a41883e27ad2d2fa62cbf275b6002f45fda8fc7970d69a05a75f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |