Collect samples/events for ingest to sampled
Project description
libsampled - py3
Allows developers to emit samples for ingestion into SampleD
Sample Collection
Sample collection is non-blocking. Samples are sent for ingestion in a background thread.
Samples are batched for ingest once either SAMPLED_BUFFER_FLUSH_SIZE
samples have been collected or SAMPLED_BUFFER_FLUSH_INTERVAL_MS
milliseconds have passed since the last batch was sent.
On shutdown of your python program samples may be left un-sent, samples are always best-effort delivery.
A sample is a dictionary with str
keys and Union[str, int, float, List[str]]
values.
Usage Example
from libsampled import sampled, canonical
def main() {
// do your logic
sampled.add_sample(dataset="my_awesome_dataset", sample={
"hostname": canonical.hostname(),
"logic": __name__,
"foo": 123,
"bar": 0.98,
"baz": ["a", "b", "c"]
})
}
if __name__ == "__main__":
main()
Configuration
The following environment variables are available:
Environment Variable | Description | Default |
---|---|---|
SAMPLED_BUFFER_FLUSH_SIZE | How many samples to keep before sending for ingest | 100 |
SAMPLED_BUFFER_FLUSH_INTERVAL_MS | Interval in milliseconds between batches being sent | 1000 |
SAMPLED_DAEMON_HOST | host/ipv4/ipv6 address to send samples to | localhost |
SAMPLED_DAEMON_PORT | TCP port number to send samples to | 7675 |
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
libsampled-0.1.5.tar.gz
(3.8 kB
view hashes)
Built Distribution
Close
Hashes for libsampled-0.1.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2798bb59fc9729b13c44ad4aa33143b832e70d2009a9be761306e94a2a296029 |
|
MD5 | 3968dafbe5adee955146a0a0c553caa1 |
|
BLAKE2b-256 | 1fc0fe3a79d53c6b169934c36ab5bc93e41c2fde8d28a44480f6675a40202605 |