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

flexype-honeycomb (Private Package)

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

Installation

Copy the honeycomb_client.py file (and __init__.py) into your project, or install as a private 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.0.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.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: capture_hc-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 0f35a205ab5786ec8cf44506fbefc5a2f5f18ee52080ac12e93e293bb0553de4
MD5 e1d2a80b75b39fdcd4692bc50424e5b9
BLAKE2b-256 003c2940fc2959e1860b063060651e8b804ffed18bfad62a67d544a2a0542f20

See more details on using hashes here.

File details

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

File metadata

  • Download URL: capture_hc-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eeda93e0cc394f2838881bd02b6a3f55d1a442c210cd29e4343c942e155c8244
MD5 456ca39a2c616efc7e309d54360726f3
BLAKE2b-256 792d234ca299b9ab4f9d27873301abcdbde641cb2571bc5b607cf9e01c387e61

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