Observability Module API Reference¶
This section documents the internals of the observability
module in Bijux CLI.
bijux_cli.contracts.observability ¶
Defines the contract for the structured logging and observability service.
This module specifies the ObservabilityProtocol
, a formal interface that any service providing structured logging capabilities must implement. It ensures a consistent API for configuring loggers, binding contextual data, and emitting log messages throughout the application.
ObservabilityProtocol ¶
Bases: Protocol
Defines the contract for a structured logging facade.
This interface specifies methods for configuring logging, binding contextual data, and emitting log messages in a structured format.
bind ¶
Binds context key-value pairs to the logger for future log entries.
Parameters:
-
**_kv
(Any
, default:{}
) –Key-value pairs to bind to the logging context.
Returns:
-
Self
(Self
) –The service instance, allowing for method chaining.
Source code in src/bijux_cli/contracts/observability.py
close ¶
get_logger ¶
Returns the underlying logger instance.
Returns:
-
FilteringBoundLogger | None
–FilteringBoundLogger | None: The logger instance (e.g., from
structlog
) or None if it has not been configured.
Source code in src/bijux_cli/contracts/observability.py
log ¶
Logs a message with the specified level and context.
Parameters:
-
level
(str
) –The log level (e.g., 'debug', 'info', 'error').
-
msg
(str
) –The message to log.
-
extra
(dict[str, Any] | None
, default:None
) –An optional dictionary of additional context to include in the log entry.
Returns:
-
Self
(Self
) –The service instance, allowing for method chaining.
Source code in src/bijux_cli/contracts/observability.py
set_telemetry ¶
set_telemetry(telemetry: TelemetryProtocol) -> Self
Sets the telemetry service instance for integration.
Parameters:
-
telemetry
(TelemetryProtocol
) –An instance of the telemetry service.
Returns:
-
Self
(Self
) –The service instance, allowing for method chaining.
Source code in src/bijux_cli/contracts/observability.py
setup classmethod
¶
Creates and configures a new instance of the observability service.
Parameters:
-
debug
(bool
, default:False
) –If True, configures the logger for debug-level output.
Returns:
-
Self
(Self
) –A new, configured instance of the service.