Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -258,6 +258,22 @@ List of fields out of `record` object to include in the `meta` object. By defaul

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.

Example usage to send 75% of your logs
```python
import logging
from logdna import LogDNAHandler, UniformSampling

log.getLogger('logdna_sample')

uniform_sampler = UniformSampling(send_ratio=.75)
options ={'hostname':'py_sample_test', 'sampling_instance':uniform_sampler}

logdna_handler = LogDNAHandler("API_KEY",options)
log.addHandler(logdna_handler)

log.info("Maybe I'll send, maybe I won't.")
```

### log(line, [options])

#### line
Expand Down
1 change: 1 addition & 0 deletions logdna/__init__.py
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
from .logdna import LogDNAHandler
from .sampling import Sampling, UniformSampling
__all__ = ['LogDNAHandler']

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