Skip to content

Commit 46aa7c6

Browse files
authored
Sampling Example (#78)
added sampling usage example to repo
1 parent f0d62cf commit 46aa7c6

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,22 @@ List of fields out of `record` object to include in the `meta` object. By defaul
258258

259259
Instance of a "sampling class". Used to decide if a log should be sent via a random selection over some distribution. The default sends everything. However, the `UniformSampling` class is included and extension of `Sampling` is welcome.
260260

261+
Example usage to send 75% of your logs
262+
```python
263+
import logging
264+
from logdna import LogDNAHandler, UniformSampling
265+
266+
log.getLogger('logdna_sample')
267+
268+
uniform_sampler = UniformSampling(send_ratio=.75)
269+
options = {'hostname':'py_sample_test', 'sampling_instance':uniform_sampler}
270+
271+
logdna_handler = LogDNAHandler("API_KEY",options)
272+
log.addHandler(logdna_handler)
273+
274+
log.info("Maybe I'll send, maybe I won't.")
275+
```
276+
261277
### log(line, [options])
262278

263279
#### line

logdna/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from .logdna import LogDNAHandler
2+
from .sampling import Sampling, UniformSampling
23
__all__ = ['LogDNAHandler']
34

45
# Publish this class to the "logging.handlers" module so that it can be use

0 commit comments

Comments
 (0)