Skip to main content

A simple, user-friendly Python client for sending events and traces to Honeycomb, with decorator support for timing and custom fields.

Project description

Honeycomb Python Client

A simple, user-friendly wrapper for sending events to Honeycomb using libhoney, for use across any Python codebase.

Installation

Copy the honeycomb_client.py file (and __init__.py) into your project, or install as a public package if set up.

Usage

from capture_hc.honeycomb_client import HoneycombClient

# Initialize the client (use your own writekey and dataset)
honey = HoneycombClient(writekey="<YOUR_WRITE_KEY>", dataset="<YOUR_DATASET>")

# Send an event (fields as a dictionary)
honey.send_event({
    "alert_name": "Test Alert",
    "priority": "P1",
    "message": "Something happened!",
    "duration_ms": 123.4
})

# Use the timed decorator to automatically measure and send duration
@honey.timed({"alert_name": "important_task"})
def important_task(x, y, event=None):
    # ... your code ...
    event.add_field("result", x + y)
    return x + y

important_task(1, 2)

# You can also customize the event variable name
@honey.timed({"alert_name": "custom_var"}, event_arg='track')
def another_task(x, y, track=None):
    track.add_field("custom_field", x * y)
    return x * y

another_task(2, 3)

Features

  • Only initialize once per process.
  • Simple send_event(dict) interface.
  • All fields are added to the event.
  • Handles flush automatically.
  • @honey.timed({...}) decorator to measure and send function execution time automatically.

Advanced

You can pass debug=True

Integration Example

Set your environment variables and run the script to send a test event and a timed event:

export HONEYCOMB_WRITEKEY=your_writekey
export HONEYCOMB_DATASET=your_dataset
python -m integration_example

This will:

  • Send a simple event to Honeycomb
  • Use the @honey.timed decorator to send a timed event with custom fields

Example from integration_example.py:

@honey.timed({'alert_name': 'decorator_test'})
def test_func(event=None):
    event.add_field('custom_field', 123)
    return 'decorator event sent!'

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

capture_hc-0.1.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

capture_hc-0.1.1-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file capture_hc-0.1.1.tar.gz.

File metadata

  • Download URL: capture_hc-0.1.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for capture_hc-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f43c3bff6aad197e802586cc5d5ae65b635dce4f69042397a027167f69c5734a
MD5 326e4a952f491be6dac2b29843479c86
BLAKE2b-256 1a383862673cadc8bb408e61e0728fae7906433ca576c21cf0af485f790f7528

See more details on using hashes here.

File details

Details for the file capture_hc-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: capture_hc-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for capture_hc-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5a81237ad4266585db7f248039be5ecab2f48a75d000c7978fc3673a69ed38e1
MD5 6e2a25666b1e583192339c22e421e5a6
BLAKE2b-256 8bda3a454b17bf93845a43d71c41b249ec5e0ebbe9d97fdf6a69b7a62ebfa19c

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