1. 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.
2. 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.
3. High-Level API & Examples
Example 1: Basic Honeycomb Setup
python
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
python
import asyncio
async def send_async(sink):
await sink.alog("warning", "high latency", p99_ms=710)
# alog delegates to synchronous log() in this sink.4. 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(...).
5. Error Handling
- LoggerDependencyError when libhoney is unavailable.
- Event send exceptions are swallowed.
6. 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.