Observability¶
The observability subsystem provides OpenTelemetry instrumentation for HoloDeck agents, following GenAI semantic conventions. It manages traces, metrics, and logs through a unified initialization lifecycle and supports multiple exporters (console, OTLP, with Prometheus and Azure Monitor planned).
Package entry point¶
observability
¶
OpenTelemetry observability module for HoloDeck.
This module provides telemetry instrumentation for HoloDeck agents, following OpenTelemetry GenAI semantic conventions.
Public API
initialize_observability: Initialize all telemetry providers shutdown_observability: Gracefully shutdown providers get_tracer: Get a tracer for creating spans get_meter: Get a meter for creating metrics enable_semantic_kernel_telemetry: Enable SK's native GenAI instrumentation ObservabilityContext: Container for initialized providers
Errors
ObservabilityError: Base exception for observability errors ObservabilityConfigError: Invalid configuration error
Example
from holodeck.lib.observability import initialize_observability from holodeck.lib.observability import shutdown_observability from holodeck.models.observability import ObservabilityConfig
config = ObservabilityConfig(enabled=True) context = initialize_observability(config, agent_name="my-agent") try: ... # Run agent ... pass ... finally: ... shutdown_observability(context)
Task: T053 - Export public API from init.py
ObservabilityContext(tracer_provider, meter_provider, logger_provider, exporters=list(), resource=Resource.create())
dataclass
¶
Container for initialized observability components.
Holds references to all telemetry providers and tracks which exporters are active. Used for lifecycle management and provider access.
Attributes:
| Name | Type | Description |
|---|---|---|
tracer_provider |
TracerProvider | None
|
OpenTelemetry TracerProvider instance |
meter_provider |
MeterProvider | None
|
OpenTelemetry MeterProvider instance |
logger_provider |
Any
|
OpenTelemetry LoggerProvider instance |
exporters |
list[str]
|
List of enabled exporter names (e.g., ["console", "otlp"]) |
resource |
Resource
|
Shared OpenTelemetry Resource |
get_resource()
¶
Get the shared OpenTelemetry resource.
Returns:
| Type | Description |
|---|---|
Resource
|
The Resource instance shared by all providers. |
Source code in src/holodeck/lib/observability/providers.py
72 73 74 75 76 77 78 | |
is_enabled()
¶
Check if observability is active.
Returns:
| Type | Description |
|---|---|
bool
|
True if all providers are initialized, False otherwise. |
Source code in src/holodeck/lib/observability/providers.py
60 61 62 63 64 65 66 67 68 69 70 | |
ObservabilityError(message)
¶
Bases: HoloDeckError
Base exception for all observability-related errors.
All observability-specific exceptions inherit from this class, enabling centralized exception handling for telemetry operations.
Attributes:
| Name | Type | Description |
|---|---|---|
message |
Human-readable error message |
Initialize ObservabilityError with message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Descriptive error message |
required |
Source code in src/holodeck/lib/observability/errors.py
21 22 23 24 25 26 27 28 | |
ObservabilityConfigError(field, message)
¶
Bases: ObservabilityError
Exception raised for observability configuration errors.
Raised when observability configuration is invalid or incomplete, such as missing required fields or invalid exporter settings.
Attributes:
| Name | Type | Description |
|---|---|---|
field |
The configuration field that caused the error |
|
message |
Human-readable error message |
Initialize ObservabilityConfigError with field and message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Configuration field name where error occurred |
required |
message
|
str
|
Descriptive error message |
required |
Source code in src/holodeck/lib/observability/errors.py
42 43 44 45 46 47 48 49 50 51 | |
initialize_observability(config, agent_name, verbose=False, quiet=False)
¶
Initialize all telemetry providers based on configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ObservabilityConfig
|
Observability configuration from agent.yaml |
required |
agent_name
|
str
|
Agent name from agent.yaml (used for default service name) |
required |
verbose
|
bool
|
If True, set log level to DEBUG |
False
|
quiet
|
bool
|
If True, set log level to WARNING (overrides verbose) |
False
|
Returns:
| Type | Description |
|---|---|
ObservabilityContext
|
ObservabilityContext with initialized providers |
Raises:
| Type | Description |
|---|---|
ObservabilityConfigError
|
If configuration is invalid |
Note
Initialization order is critical: 1. Configure logging first (prevents double logging) 2. Set up logging provider 3. Set up tracing provider 4. Set up metrics provider
Example
from holodeck.lib.observability import initialize_observability from holodeck.models.observability import ObservabilityConfig
config = ObservabilityConfig(enabled=True) context = initialize_observability(config, agent_name="my-agent")
Source code in src/holodeck/lib/observability/providers.py
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | |
shutdown_observability(context)
¶
Flush pending telemetry and shutdown providers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
ObservabilityContext
|
ObservabilityContext from initialize_observability |
required |
Note
Should be called during application shutdown. Blocks until all pending spans/metrics are flushed.
Source code in src/holodeck/lib/observability/providers.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | |
get_tracer(name)
¶
Get an OpenTelemetry tracer instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Tracer name (typically name) |
required |
Returns:
| Type | Description |
|---|---|
Tracer
|
OpenTelemetry Tracer instance |
Example
tracer = get_tracer(name) with tracer.start_as_current_span("my-operation"): ... # do work
Source code in src/holodeck/lib/observability/providers.py
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | |
get_meter(name)
¶
Get an OpenTelemetry meter instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Meter name (typically name) |
required |
Returns:
| Type | Description |
|---|---|
Meter
|
OpenTelemetry Meter instance |
Example
meter = get_meter(name) counter = meter.create_counter("requests") counter.add(1)
Source code in src/holodeck/lib/observability/providers.py
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | |
get_observability_context()
¶
Return the current ObservabilityContext, or None if not initialized.
Thread-safety note: This accessor reads module-level state that is set
by initialize_observability() in the CLI layer's main thread, before
asyncio.run() is called. All async tasks (including
ClaudeBackend.initialize()) run in the same thread, so no
synchronization is needed. If future code introduces background task
spawning that accesses this state, thread synchronization will be
required.
Source code in src/holodeck/lib/observability/providers.py
396 397 398 399 400 401 402 403 404 405 406 407 | |
enable_semantic_kernel_telemetry(config)
¶
Enable Semantic Kernel's native OpenTelemetry instrumentation.
Sets environment variables that Semantic Kernel reads to enable telemetry. SK provides comprehensive GenAI semantic convention support, automatically capturing attributes like:
- gen_ai.operation.name (e.g., "chat.completions")
- gen_ai.system (e.g., "openai")
- gen_ai.request.model (e.g., "gpt-4o")
- gen_ai.response.id, gen_ai.response.finish_reason
- gen_ai.usage.prompt_tokens, gen_ai.usage.completion_tokens
When sensitive diagnostics is enabled, SK also captures: - gen_ai.content.prompt (via span events) - gen_ai.content.completion (via span events)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ObservabilityConfig
|
ObservabilityConfig with traces settings |
required |
Note
This function must be called BEFORE any Semantic Kernel operations. SK reads these environment variables at initialization time.
Example
from holodeck.models.observability import ObservabilityConfig config = ObservabilityConfig(enabled=True) enable_semantic_kernel_telemetry(config)
SK will now emit GenAI semantic convention spans¶
Source code in src/holodeck/lib/observability/instrumentation.py
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 | |
Providers (providers)¶
Core provider setup and lifecycle management. Creates the OpenTelemetry
TracerProvider, MeterProvider, and LoggerProvider, and exposes helper
accessors.
ObservabilityContext(tracer_provider, meter_provider, logger_provider, exporters=list(), resource=Resource.create())
dataclass
¶
Container for initialized observability components.
Holds references to all telemetry providers and tracks which exporters are active. Used for lifecycle management and provider access.
Attributes:
| Name | Type | Description |
|---|---|---|
tracer_provider |
TracerProvider | None
|
OpenTelemetry TracerProvider instance |
meter_provider |
MeterProvider | None
|
OpenTelemetry MeterProvider instance |
logger_provider |
Any
|
OpenTelemetry LoggerProvider instance |
exporters |
list[str]
|
List of enabled exporter names (e.g., ["console", "otlp"]) |
resource |
Resource
|
Shared OpenTelemetry Resource |
get_resource()
¶
Get the shared OpenTelemetry resource.
Returns:
| Type | Description |
|---|---|
Resource
|
The Resource instance shared by all providers. |
Source code in src/holodeck/lib/observability/providers.py
72 73 74 75 76 77 78 | |
is_enabled()
¶
Check if observability is active.
Returns:
| Type | Description |
|---|---|
bool
|
True if all providers are initialized, False otherwise. |
Source code in src/holodeck/lib/observability/providers.py
60 61 62 63 64 65 66 67 68 69 70 | |
create_resource(config, agent_name)
¶
Create OpenTelemetry resource with service name and attributes.
Service name resolution order: 1. config.service_name (if provided) 2. f"holodeck-{agent_name}" (default)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ObservabilityConfig
|
Observability configuration from agent.yaml |
required |
agent_name
|
str
|
Agent name from agent.yaml (used for default service name) |
required |
Returns:
| Type | Description |
|---|---|
Resource
|
OpenTelemetry Resource with service name and custom attributes |
Example
config = ObservabilityConfig(enabled=True) resource = create_resource(config, agent_name="customer-support")
Service name is "holodeck-customer-support"¶
Source code in src/holodeck/lib/observability/providers.py
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 | |
set_up_logging(config, resource, log_exporters, verbose=False, quiet=False)
¶
Set up OpenTelemetry LoggerProvider and bridge Python logging.
Must be called FIRST before tracing and metrics per OTel Python docs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ObservabilityConfig
|
Observability configuration |
required |
resource
|
Resource
|
Shared OpenTelemetry Resource |
required |
log_exporters
|
list[Any]
|
List of log exporters to add |
required |
verbose
|
bool
|
If True, set log level to DEBUG |
False
|
quiet
|
bool
|
If True, set log level to WARNING (overrides verbose) |
False
|
Returns:
| Type | Description |
|---|---|
Any
|
Configured LoggerProvider instance |
Source code in src/holodeck/lib/observability/providers.py
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 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
set_up_tracing(config, resource, span_exporters)
¶
Set up OpenTelemetry TracerProvider with span exporters.
Creates a TracerProvider with the resource and registers it globally. If a TracerProvider was already set by another library, we use that existing provider and add our span processors to it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ObservabilityConfig
|
Observability configuration |
required |
resource
|
Resource
|
Shared OpenTelemetry Resource |
required |
span_exporters
|
list[Any]
|
List of span exporters to add |
required |
Returns:
| Type | Description |
|---|---|
TracerProvider
|
Configured TracerProvider instance |
Note
This must be called before any code that creates spans. The SEMANTICKERNEL_EXPERIMENTAL_GENAI_ENABLE_OTEL_DIAGNOSTICS env var should be set in main.py before any SK imports.
Source code in src/holodeck/lib/observability/providers.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
set_up_metrics(config, resource, metric_readers)
¶
Set up OpenTelemetry MeterProvider with metric readers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ObservabilityConfig
|
Observability configuration |
required |
resource
|
Resource
|
Shared OpenTelemetry Resource |
required |
metric_readers
|
list[Any]
|
List of metric readers to add |
required |
Returns:
| Type | Description |
|---|---|
MeterProvider
|
Configured MeterProvider instance |
Source code in src/holodeck/lib/observability/providers.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | |
initialize_observability(config, agent_name, verbose=False, quiet=False)
¶
Initialize all telemetry providers based on configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ObservabilityConfig
|
Observability configuration from agent.yaml |
required |
agent_name
|
str
|
Agent name from agent.yaml (used for default service name) |
required |
verbose
|
bool
|
If True, set log level to DEBUG |
False
|
quiet
|
bool
|
If True, set log level to WARNING (overrides verbose) |
False
|
Returns:
| Type | Description |
|---|---|
ObservabilityContext
|
ObservabilityContext with initialized providers |
Raises:
| Type | Description |
|---|---|
ObservabilityConfigError
|
If configuration is invalid |
Note
Initialization order is critical: 1. Configure logging first (prevents double logging) 2. Set up logging provider 3. Set up tracing provider 4. Set up metrics provider
Example
from holodeck.lib.observability import initialize_observability from holodeck.models.observability import ObservabilityConfig
config = ObservabilityConfig(enabled=True) context = initialize_observability(config, agent_name="my-agent")
Source code in src/holodeck/lib/observability/providers.py
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | |
shutdown_observability(context)
¶
Flush pending telemetry and shutdown providers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
ObservabilityContext
|
ObservabilityContext from initialize_observability |
required |
Note
Should be called during application shutdown. Blocks until all pending spans/metrics are flushed.
Source code in src/holodeck/lib/observability/providers.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | |
get_tracer(name)
¶
Get an OpenTelemetry tracer instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Tracer name (typically name) |
required |
Returns:
| Type | Description |
|---|---|
Tracer
|
OpenTelemetry Tracer instance |
Example
tracer = get_tracer(name) with tracer.start_as_current_span("my-operation"): ... # do work
Source code in src/holodeck/lib/observability/providers.py
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | |
get_meter(name)
¶
Get an OpenTelemetry meter instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Meter name (typically name) |
required |
Returns:
| Type | Description |
|---|---|
Meter
|
OpenTelemetry Meter instance |
Example
meter = get_meter(name) counter = meter.create_counter("requests") counter.add(1)
Source code in src/holodeck/lib/observability/providers.py
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | |
get_observability_context()
¶
Return the current ObservabilityContext, or None if not initialized.
Thread-safety note: This accessor reads module-level state that is set
by initialize_observability() in the CLI layer's main thread, before
asyncio.run() is called. All async tasks (including
ClaudeBackend.initialize()) run in the same thread, so no
synchronization is needed. If future code introduces background task
spawning that accesses this state, thread synchronization will be
required.
Source code in src/holodeck/lib/observability/providers.py
396 397 398 399 400 401 402 403 404 405 406 407 | |
Configuration (config)¶
Exporter configuration and logging coordination. Prevents double logging when the console exporter is active, and builds the exporter lists consumed by the provider setup functions.
is_console_exporter_active(config)
¶
Check if console exporter is active.
Console exporter is active when: - Explicitly enabled in configuration, OR - No other exporters are enabled (console is the default fallback)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ObservabilityConfig
|
Observability configuration |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if console exporter is active, False otherwise. |
Source code in src/holodeck/lib/observability/config.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
configure_logging(config)
¶
Configure logging to prevent duplicates with console exporter.
When console exporter is active, removes default StreamHandlers from the holodeck logger to prevent duplicate output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ObservabilityConfig
|
Observability configuration |
required |
Note
Called automatically by initialize_observability().
Source code in src/holodeck/lib/observability/config.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
configure_exporters(config)
¶
Configure all explicitly enabled exporters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ObservabilityConfig
|
Observability configuration |
required |
Returns:
| Type | Description |
|---|---|
tuple[list[Any], list[Any], list[Any], list[str]]
|
Tuple of (span_exporters, metric_readers, log_exporters, exporter_names) |
Note
Only exporters that are explicitly enabled in configuration are added. The serve command enables console exporter by default for server logging.
Source code in src/holodeck/lib/observability/config.py
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 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 143 144 145 146 147 148 | |
Instrumentation (instrumentation)¶
Semantic Kernel telemetry integration. Sets the environment variables that Semantic Kernel reads at startup to emit GenAI semantic convention spans.
enable_semantic_kernel_telemetry(config)
¶
Enable Semantic Kernel's native OpenTelemetry instrumentation.
Sets environment variables that Semantic Kernel reads to enable telemetry. SK provides comprehensive GenAI semantic convention support, automatically capturing attributes like:
- gen_ai.operation.name (e.g., "chat.completions")
- gen_ai.system (e.g., "openai")
- gen_ai.request.model (e.g., "gpt-4o")
- gen_ai.response.id, gen_ai.response.finish_reason
- gen_ai.usage.prompt_tokens, gen_ai.usage.completion_tokens
When sensitive diagnostics is enabled, SK also captures: - gen_ai.content.prompt (via span events) - gen_ai.content.completion (via span events)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ObservabilityConfig
|
ObservabilityConfig with traces settings |
required |
Note
This function must be called BEFORE any Semantic Kernel operations. SK reads these environment variables at initialization time.
Example
from holodeck.models.observability import ObservabilityConfig config = ObservabilityConfig(enabled=True) enable_semantic_kernel_telemetry(config)
SK will now emit GenAI semantic convention spans¶
Source code in src/holodeck/lib/observability/instrumentation.py
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 | |
SK_OTEL_DIAGNOSTICS_ENV = 'SEMANTICKERNEL_EXPERIMENTAL_GENAI_ENABLE_OTEL_DIAGNOSTICS'
module-attribute
¶
SK_OTEL_SENSITIVE_ENV = 'SEMANTICKERNEL_EXPERIMENTAL_GENAI_ENABLE_OTEL_DIAGNOSTICS_SENSITIVE'
module-attribute
¶
Errors (errors)¶
Custom exception hierarchy for observability failures.
ObservabilityError(message)
¶
Bases: HoloDeckError
Base exception for all observability-related errors.
All observability-specific exceptions inherit from this class, enabling centralized exception handling for telemetry operations.
Attributes:
| Name | Type | Description |
|---|---|---|
message |
Human-readable error message |
Initialize ObservabilityError with message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Descriptive error message |
required |
Source code in src/holodeck/lib/observability/errors.py
21 22 23 24 25 26 27 28 | |
ObservabilityConfigError(field, message)
¶
Bases: ObservabilityError
Exception raised for observability configuration errors.
Raised when observability configuration is invalid or incomplete, such as missing required fields or invalid exporter settings.
Attributes:
| Name | Type | Description |
|---|---|---|
field |
The configuration field that caused the error |
|
message |
Human-readable error message |
Initialize ObservabilityConfigError with field and message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Configuration field name where error occurred |
required |
message
|
str
|
Descriptive error message |
required |
Source code in src/holodeck/lib/observability/errors.py
42 43 44 45 46 47 48 49 50 51 | |
Exporters¶
Console exporter (exporters.console)¶
Development/debugging exporter that writes telemetry to stdout. Used as the default fallback when no other exporters are configured.
create_console_exporters(config)
¶
Create all console exporters (spans, metrics, logs).
Factory function that creates all three exporter types for the console exporter configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ConsoleExporterConfig
|
Console exporter configuration |
required |
Returns:
| Type | Description |
|---|---|
tuple[ConsoleSpanExporter, PeriodicExportingMetricReader, ConsoleLogRecordExporter]
|
Tuple of (span_exporter, metric_reader, log_exporter) |
Example
from holodeck.models.observability import ConsoleExporterConfig config = ConsoleExporterConfig() span_exp, metric_reader, log_exp = create_console_exporters(config)
Source code in src/holodeck/lib/observability/exporters/console.py
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 | |
create_console_span_exporter(config)
¶
Create a console span exporter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ConsoleExporterConfig
|
Console exporter configuration |
required |
Returns:
| Type | Description |
|---|---|
ConsoleSpanExporter
|
Configured ConsoleSpanExporter instance |
Source code in src/holodeck/lib/observability/exporters/console.py
28 29 30 31 32 33 34 35 36 37 | |
create_console_metric_reader(config)
¶
Create a console metric reader.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ConsoleExporterConfig
|
Console exporter configuration |
required |
Returns:
| Type | Description |
|---|---|
PeriodicExportingMetricReader
|
PeriodicExportingMetricReader with ConsoleMetricExporter |
Source code in src/holodeck/lib/observability/exporters/console.py
40 41 42 43 44 45 46 47 48 49 50 51 52 | |
create_console_log_exporter(config)
¶
Create a console log exporter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ConsoleExporterConfig
|
Console exporter configuration |
required |
Returns:
| Type | Description |
|---|---|
ConsoleLogRecordExporter
|
Configured ConsoleLogRecordExporter instance |
Source code in src/holodeck/lib/observability/exporters/console.py
55 56 57 58 59 60 61 62 63 64 65 66 | |
OTLP exporter (exporters.otlp)¶
Exports telemetry via OTLP (gRPC or HTTP) to any compatible collector such as Jaeger, Honeycomb, or Datadog.
create_otlp_exporters(config)
¶
Create all OTLP exporters (spans, metrics, logs).
Factory function that creates all three exporter types for the OTLP exporter configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
OTLPExporterConfig
|
OTLP exporter configuration |
required |
Returns:
| Type | Description |
|---|---|
tuple[Any, PeriodicExportingMetricReader, Any]
|
Tuple of (span_exporter, metric_reader, log_exporter) |
Example
from holodeck.models.observability import OTLPExporterConfig config = OTLPExporterConfig(endpoint="http://localhost:4317") span_exp, metric_reader, log_exp = create_otlp_exporters(config)
Source code in src/holodeck/lib/observability/exporters/otlp.py
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
create_otlp_span_exporter(config)
¶
Create OTLP span exporter based on protocol.
Dispatches to gRPC or HTTP implementation based on config.protocol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
OTLPExporterConfig
|
OTLP exporter configuration |
required |
Returns:
| Type | Description |
|---|---|
Any
|
OTLPSpanExporter instance (gRPC or HTTP) |
Source code in src/holodeck/lib/observability/exporters/otlp.py
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
create_otlp_span_exporter_grpc(config)
¶
Create OTLP span exporter using gRPC protocol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
OTLPExporterConfig
|
OTLP exporter configuration |
required |
Returns:
| Type | Description |
|---|---|
OTLPSpanExporter
|
OTLPSpanExporter (gRPC) instance |
Source code in src/holodeck/lib/observability/exporters/otlp.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
create_otlp_span_exporter_http(config)
¶
Create OTLP span exporter using HTTP protocol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
OTLPExporterConfig
|
OTLP exporter configuration |
required |
Returns:
| Type | Description |
|---|---|
OTLPSpanExporter
|
OTLPSpanExporter (HTTP) instance |
Source code in src/holodeck/lib/observability/exporters/otlp.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | |
create_otlp_metric_reader(config)
¶
Create OTLP metric reader (wraps exporter in PeriodicExportingMetricReader).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
OTLPExporterConfig
|
OTLP exporter configuration |
required |
Returns:
| Type | Description |
|---|---|
PeriodicExportingMetricReader
|
PeriodicExportingMetricReader with OTLP exporter |
Source code in src/holodeck/lib/observability/exporters/otlp.py
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | |
create_otlp_metric_exporter_grpc(config)
¶
Create OTLP metric exporter using gRPC protocol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
OTLPExporterConfig
|
OTLP exporter configuration |
required |
Returns:
| Type | Description |
|---|---|
OTLPMetricExporter
|
OTLPMetricExporter (gRPC) instance |
Source code in src/holodeck/lib/observability/exporters/otlp.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
create_otlp_metric_exporter_http(config)
¶
Create OTLP metric exporter using HTTP protocol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
OTLPExporterConfig
|
OTLP exporter configuration |
required |
Returns:
| Type | Description |
|---|---|
OTLPMetricExporter
|
OTLPMetricExporter (HTTP) instance |
Source code in src/holodeck/lib/observability/exporters/otlp.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
create_otlp_log_exporter(config)
¶
Create OTLP log exporter based on protocol.
Dispatches to gRPC or HTTP implementation based on config.protocol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
OTLPExporterConfig
|
OTLP exporter configuration |
required |
Returns:
| Type | Description |
|---|---|
Any
|
OTLPLogExporter instance (gRPC or HTTP) |
Source code in src/holodeck/lib/observability/exporters/otlp.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | |
create_otlp_log_exporter_grpc(config)
¶
Create OTLP log exporter using gRPC protocol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
OTLPExporterConfig
|
OTLP exporter configuration |
required |
Returns:
| Type | Description |
|---|---|
OTLPLogExporter
|
OTLPLogExporter (gRPC) instance |
Source code in src/holodeck/lib/observability/exporters/otlp.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | |
create_otlp_log_exporter_http(config)
¶
Create OTLP log exporter using HTTP protocol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
OTLPExporterConfig
|
OTLP exporter configuration |
required |
Returns:
| Type | Description |
|---|---|
OTLPLogExporter
|
OTLPLogExporter (HTTP) instance |
Source code in src/holodeck/lib/observability/exporters/otlp.py
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | |
resolve_headers(headers)
¶
Resolve environment variable references in header values.
Substitutes ${VAR_NAME} patterns with environment variable values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
headers
|
dict[str, str]
|
Dictionary of header names to values (may contain ${VAR} refs) |
required |
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
Dictionary with all environment variables resolved |
Raises:
| Type | Description |
|---|---|
ConfigError
|
If a referenced environment variable does not exist |
Example
import os os.environ["API_KEY"] = "secret123" resolve_headers({"Authorization": "Bearer ${API_KEY}"}) {'Authorization': 'Bearer secret123'}
Source code in src/holodeck/lib/observability/exporters/otlp.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
adjust_endpoint_for_protocol(endpoint, protocol)
¶
Adjust endpoint port based on protocol if using default localhost.
OTLP conventions: - gRPC default port: 4317 - HTTP default port: 4318
Only adjusts ports for localhost/127.0.0.1 when using standard OTLP ports.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
Original endpoint URL |
required |
protocol
|
OTLPProtocol
|
OTLP protocol (grpc or http) |
required |
Returns:
| Type | Description |
|---|---|
str
|
Endpoint with adjusted port if needed |
Source code in src/holodeck/lib/observability/exporters/otlp.py
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 143 144 145 146 147 148 149 150 151 | |
get_compression_grpc(compression)
¶
Convert compression string to gRPC Compression enum.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
compression
|
str | None
|
Compression algorithm name ("gzip", "deflate", None) |
required |
Returns:
| Type | Description |
|---|---|
Compression | None
|
grpc.Compression enum value or None |
Source code in src/holodeck/lib/observability/exporters/otlp.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
get_compression_http(compression)
¶
Convert compression string to HTTP Compression enum.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
compression
|
str | None
|
Compression algorithm name ("gzip", "deflate", None) |
required |
Returns:
| Type | Description |
|---|---|
Compression | None
|
opentelemetry Compression enum value or None |
Source code in src/holodeck/lib/observability/exporters/otlp.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |