honeyhive.tracer.core
Core HoneyHive tracer implementation with dynamic composition.
This module provides the main HoneyHiveTracer class composed from multiple mixins using dynamic inheritance patterns. It maintains full backward compatibility while providing a clean, modular architecture.
NoOpSpan
No-op span implementation for graceful degradation.
This class provides a safe default span that implements the same interface as a real span but performs no operations. This follows OpenTelemetry best practices for error handling - never return None, always return a usable object.
Source code in src/honeyhive/tracer/core/base.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
kind
instance-attribute
kind = SpanKind.INTERNAL
set_attribute
Set attribute (no-op).
Source code in src/honeyhive/tracer/core/base.py
104 105 | |
set_attributes
Set multiple attributes (no-op).
Source code in src/honeyhive/tracer/core/base.py
107 108 | |
add_event
add_event(
name: str,
attributes: Optional[Dict[str, Any]] = None,
timestamp: Optional[int] = None,
) -> None
Add event (no-op).
Source code in src/honeyhive/tracer/core/base.py
110 111 112 113 114 115 116 | |
record_exception
record_exception(
exception: Exception,
attributes: Optional[Dict[str, Any]] = None,
timestamp: Optional[int] = None,
escaped: bool = False,
) -> None
Record exception (no-op).
Source code in src/honeyhive/tracer/core/base.py
118 119 120 121 122 123 124 125 | |
set_status
Set status (no-op).
Source code in src/honeyhive/tracer/core/base.py
127 128 | |
update_name
update_name(name: str) -> None
Update name (no-op).
Source code in src/honeyhive/tracer/core/base.py
130 131 | |
end
End span (no-op).
Source code in src/honeyhive/tracer/core/base.py
133 134 | |
is_recording
is_recording() -> bool
Check if span is recording (always False for no-op).
Source code in src/honeyhive/tracer/core/base.py
136 137 138 | |
get_span_context
get_span_context() -> Any
Get span context (returns invalid context).
Source code in src/honeyhive/tracer/core/base.py
140 141 142 | |
HoneyHiveTracer
Bases: HoneyHiveTracerBase, TracerOperationsMixin, TracerContextMixin
HoneyHive OpenTelemetry tracer with dynamic multi-instance architecture.
This tracer class is composed from multiple mixins using dynamic inheritance, providing a comprehensive tracing solution with flexible configuration, robust error handling, and multi-instance support.
The class combines: - HoneyHiveTracerBase: Core initialization and configuration - TracerOperationsMixin: Span creation and event management - TracerContextMixin: Context and baggage management
All operations use dynamic logic for flexible parameter handling, automatic error recovery, and graceful degradation.
Accepted keys
Ingestion API key; Project API key (deprecated)
Example
New Pydantic config approach (recommended)
config = TracerConfig(api_key="...", project="...", verbose=True) tracer = HoneyHiveTracer(config=config)
Backwards compatible approach
tracer = HoneyHiveTracer(api_key="...", project="...", verbose=True)
Dynamic span creation
with tracer.start_span("operation") as span: ... span.set_attribute("key", "value")
Dynamic event creation
event_id = tracer.create_event( ... event_name="my_event", ... event_type="tool", ... inputs={"input": "data"}, ... outputs={"output": "result"} ... )
Source code in src/honeyhive/tracer/core/tracer.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
get_baggage
Get baggage value by key.
Delegates to TracerContextMixin implementation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The baggage key to retrieve |
required |
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Baggage value or None if not found |
Source code in src/honeyhive/tracer/core/tracer.py
56 57 58 59 60 61 62 63 64 65 66 67 | |
flush
Flush tracer data. Alias for force_flush().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout_millis
|
float
|
Timeout in milliseconds (default 30000) |
30000
|
Returns:
| Type | Description |
|---|---|
bool
|
True if flush successful, False otherwise |
Source code in src/honeyhive/tracer/core/tracer.py
69 70 71 72 73 74 75 76 77 78 | |
flush_all
classmethod
Flush all active tracer instances.
This is a convenience class method that flushes all active tracers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout_millis
|
float
|
Timeout in milliseconds (default 30000) |
30000
|
Returns:
| Type | Description |
|---|---|
bool
|
True if all flushes successful, False otherwise |
Source code in src/honeyhive/tracer/core/tracer.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |