Skip to main content

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


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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

libsampled-0.1.5-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file libsampled-0.1.5.tar.gz.

File metadata

  • Download URL: libsampled-0.1.5.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for libsampled-0.1.5.tar.gz
Algorithm Hash digest
SHA256 e2868ff69587a0ad8ffb22fea3afe00abf1e75f8975c69c258fa2a6afddf0637
MD5 1b66ea67c441ef2b7e86d670dcd4e54c
BLAKE2b-256 1f765ae366448eb721345516a4f956ccd8eee12a3eb462ab87358e60bee7b682

See more details on using hashes here.

File details

Details for the file libsampled-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: libsampled-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for libsampled-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 2798bb59fc9729b13c44ad4aa33143b832e70d2009a9be761306e94a2a296029
MD5 3968dafbe5adee955146a0a0c553caa1
BLAKE2b-256 1fc0fe3a79d53c6b169934c36ab5bc93e41c2fde8d28a44480f6675a40202605

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page