Sinks
Honeycomb Sink
HoneycombLogger sends log-derived events to Honeycomb using the libhoney client.
Behavior and Context
The sink initializes libhoney globally with write key and dataset, then creates an event per log call and attaches log fields plus structured extras.
Purpose
- Observability Enrichment: Route structured operational events into Honeycomb.
- Simple Event Model: One log call maps to one Honeycomb event.
- Minimal Setup: API key and dataset are sufficient.
High-Level API & Examples
Example 1: Basic Honeycomb Setup
from jazzmine.logging.sinks.honeycomb_sink import HoneycombLogger
sink = HoneycombLogger(
sink_config={
"type": "honeycomb",
"api_key": "<honeycomb_key>",
"dataset": "chat-api-logs",
},
logger_name="chat-api",
level="INFO",
use_json=True,
)
sink.initialize()
sink.info("request completed", status=200, latency_ms=23)
sink.shutdown()Example 2: Async Path
import asyncio
async def send_async(sink):
await sink.alog("warning", "high latency", p99_ms=710)
# alog delegates to synchronous log() in this sink.Detailed Class Functionality
initialize()
- Imports libhoney lazily.
- Raises LoggerDependencyError if missing.
- Reads api_key and optional dataset (defaults to logger name).
- Calls libhoney.init(writekey=..., dataset=...).
log(level, msg, **kwargs)
- Creates a new Honeycomb event.
- Adds core fields: level, message, logger.
- Adds all extra kwargs as event fields.
- Sends event via event.send().
shutdown()
Closes libhoney client with libhoney.close().
alog(...)
Delegates to log(...).
Error Handling
- LoggerDependencyError when libhoney is unavailable.
- Event send exceptions are swallowed.
Remarks
- Because libhoney uses process-wide initialization, coordinate with any other Honeycomb integrations in the same runtime.
- Confirm dataset naming conventions with observability governance standards.