Skip to content

Commit

Permalink
Issues/109 (#126)
Browse files Browse the repository at this point in the history
What:
- test and docs on how to integrate `naz` with bug trackers like sentry.io

Why:
- Fixes: #109
  • Loading branch information
komuw authored Jun 1, 2019
1 parent 112d80d commit 14fe3be
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ naz is in active development and it's API may change in backward incompatible wa
+ [monitoring-and-observability](#2-monitoring-and-observability)
+ [logging](#21-logging)
+ [hooks](#22-hooks)
+ [integration with bug trackers(eg Sentry )](#23-integration-with-bug-trackers)
+ [Rate limiting](#3-rate-limiting)
+ [Throttle handling](#4-throttle-handling)
+ [Queuing](#5-queuing)
Expand Down Expand Up @@ -256,6 +257,34 @@ cli = naz.Client(
```


#### 2.3 integration with bug trackers
If you want to integrate `naz` with your bug/issue/bug tracker of choice, all you have to do is use their logging integrator.
As an example, to integrate `naz` with [sentry](https://sentry.io/), all you have to do is import and init the sentry sdk. A good place to do that would be in the naz config file, ie;
`/tmp/my_config.py`
```python
import naz
from myfile import ExampleQueue

import sentry_sdk # import sentry SDK
sentry_sdk.init("https://<YOUR_SENTRY_PUBLIC_KEY>@sentry.io/<YOUR_SENTRY_PROJECT_ID>")

my_naz_client = naz.Client(
smsc_host="127.0.0.1",
smsc_port=2775,
system_id="smppclient1",
password="password",
outboundqueue=ExampleQueue()
)
```

then run the `naz-cli` as usaul:
`naz-cli --client tmp.my_config.my_naz_client`
And just like that you are good to go. This is what errors from `naz` will look like on sentry:

![naz integration with sentry](https://raw.githubusercontent.com/komuw/naz/master/documentation/sphinx-docs/naz-sentry.png "naz integration with sentry")



#### 3. Rate limiting
Sometimes you want to control the rate at which the client sends requests to an SMSC/server. `naz` lets you do this, by allowing you to specify a custom rate limiter.
By default, `naz` uses a simple token bucket rate limiting algorithm [implemented here](https://github.com/komuw/naz/blob/master/naz/ratelimiter.py).
Expand Down
31 changes: 31 additions & 0 deletions documentation/sphinx-docs/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,37 @@ another example is if you want to update a database record whenever you get a de
)
3.2.3 integration with bug trackers
=====================
| If you want to integrate `naz` with your bug/issue/bug tracker of choice, all you have to do is use their logging integrator.
| As an example, to integrate ``naz`` with `sentry <https://sentry.io/>`_, all you have to do is import and init the sentry sdk. A good place to do that would be in the naz config file, ie;
``/tmp/my_config.py``

.. code-block:: python
import naz
from myfile import ExampleQueue
import sentry_sdk # import sentry SDK
sentry_sdk.init("https://<YOUR_SENTRY_PUBLIC_KEY>@sentry.io/<YOUR_SENTRY_PROJECT_ID>")
my_naz_client = naz.Client(
smsc_host="127.0.0.1",
smsc_port=2775,
system_id="smppclient1",
password="password",
outboundqueue=ExampleQueue()
)
| then run the `naz-cli` as usaul:
| ``naz-cli --client tmp.my_config.my_naz_client``
| And just like that you are good to go. This is what errors from `naz` will look like on sentry:
.. image:: naz-sentry.png
:width: 400
:alt: photo of naz integration with sentry


3.3 Rate limiting
=====================
| Sometimes you want to control the rate at which the client sends requests to an SMSC/server. ``naz`` lets you do this, by allowing you to specify a custom rate limiter.
Expand Down

0 comments on commit 14fe3be

Please sign in to comment.