interfaces
azure_bootstrap.services.interfaces
¶
Service interfaces for Azure bootstrap library.
This module contains interface definitions for bootstrap services.
Modules:
| Name | Description |
|---|---|
application_bootstrap_interface |
Interface for application bootstrap orchestrator. |
bootstrap_logger_interface |
Interface for bootstrap logging configuration. |
telemetry_manager_interface |
Interface for telemetry management. |
Classes:
| Name | Description |
|---|---|
ApplicationBootstrapInterface |
Interface for application bootstrap orchestrator. |
BootstrapLoggerInterface |
Interface for bootstrap logging manager. |
TelemetryManagerInterface |
Interface for telemetry manager. |
ApplicationBootstrapInterface
¶
Bases: ABC
Interface for application bootstrap orchestrator.
Defines the contract for handling the complete application startup sequence with proper logging flow.
Methods:
| Name | Description |
|---|---|
initialize |
Execute the complete bootstrap sequence with proper logging flow. |
get_config_repository |
Get the configured repository after bootstrap. |
is_bootstrap_completed |
Check if bootstrap process has completed successfully. |
initialize
abstractmethod
¶
Execute the complete bootstrap sequence with proper logging flow.
This method orchestrates the entire application startup process following the correct sequence to avoid circular dependencies while ensuring working logging throughout.
Returns:
| Type | Description |
|---|---|
EnhancedConfigRepositoryInterface
|
Configured enhanced configuration repository with all configs loaded |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If bootstrap fails in an unrecoverable way |
Source code in azure_bootstrap/services/interfaces/application_bootstrap_interface.py
get_config_repository
abstractmethod
¶
get_config_repository() -> Optional[EnhancedConfigRepositoryInterface]
Get the configured repository after bootstrap.
Returns:
| Type | Description |
|---|---|
Optional[EnhancedConfigRepositoryInterface]
|
The enhanced configuration repository if bootstrap is complete, None otherwise |
Source code in azure_bootstrap/services/interfaces/application_bootstrap_interface.py
is_bootstrap_completed
abstractmethod
¶
is_bootstrap_completed() -> bool
Check if bootstrap process has completed successfully.
Returns:
| Type | Description |
|---|---|
bool
|
True if bootstrap completed successfully, False otherwise |
Source code in azure_bootstrap/services/interfaces/application_bootstrap_interface.py
BootstrapLoggerInterface
¶
Bases: ABC
Interface for bootstrap logging manager.
Defines the contract for providing safe logging before full configuration is loaded and App Insights is configured.
Methods:
| Name | Description |
|---|---|
configure_bootstrap_logging |
Configure basic logging that works before full configuration is loaded. |
is_bootstrap_configured |
Check if bootstrap logging is configured. |
create_logger |
Create a logger with bootstrap configuration if not already done. |
configure_bootstrap_logging
abstractmethod
classmethod
¶
configure_bootstrap_logging(level: str = 'INFO') -> None
Configure basic logging that works before full configuration is loaded.
This provides immediate, safe logging during application bootstrap. Later, telemetry_manager.configure() will enhance it with App Insights.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
str
|
Logging level (DEBUG, INFO, WARNING, ERROR) |
'INFO'
|
Source code in azure_bootstrap/services/interfaces/bootstrap_logger_interface.py
is_bootstrap_configured
abstractmethod
classmethod
¶
is_bootstrap_configured() -> bool
Check if bootstrap logging is configured.
Returns:
| Type | Description |
|---|---|
bool
|
True if bootstrap logging is configured, False otherwise |
Source code in azure_bootstrap/services/interfaces/bootstrap_logger_interface.py
create_logger
abstractmethod
classmethod
¶
Create a logger with bootstrap configuration if not already done.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Logger name (typically name) |
required |
Returns:
| Type | Description |
|---|---|
Logger
|
Configured logger ready for use |
Source code in azure_bootstrap/services/interfaces/bootstrap_logger_interface.py
TelemetryManagerInterface
¶
Bases: ABC
Interface for telemetry manager.
Defines the contract for managing Application Insights telemetry and structured logging throughout the application.
Methods:
| Name | Description |
|---|---|
configure |
Configure Application Insights telemetry with support for bootstrap flow reconfiguration. |
try_upgrade_from_config |
Attempt to upgrade from basic logging to App Insights after config is loaded. |
get_tracer |
Get the configured tracer. |
create_span |
Create a new trace span. |
log_email_processing_start |
Log email processing start with structured data. |
log_email_processing_success |
Log successful email processing. |
log_email_processing_error |
Log email processing error. |
log_queue_message_received |
Log queue message processing. |
log_storage_operation |
Log storage operations. |
configure
abstractmethod
¶
Configure Application Insights telemetry with support for bootstrap flow reconfiguration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
connection_string
|
str | None
|
App Insights connection string |
None
|
allow_reconfigure
|
bool
|
If True, allows reconfiguration even if already configured |
False
|
Returns:
| Type | Description |
|---|---|
bool
|
True if configuration succeeded, False otherwise |
Source code in azure_bootstrap/services/interfaces/telemetry_manager_interface.py
try_upgrade_from_config
abstractmethod
¶
try_upgrade_from_config(config_repository: EnhancedConfigRepositoryInterface) -> bool
Attempt to upgrade from basic logging to App Insights after config is loaded.
This method is called after configuration loading to check if an App Insights connection string is now available from App Config/Key Vault that wasn't available during initial bootstrap.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_repository
|
EnhancedConfigRepositoryInterface
|
Enhanced config repository to check for connection string |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if upgrade was attempted (success or failure), False if no upgrade needed |
Source code in azure_bootstrap/services/interfaces/telemetry_manager_interface.py
get_tracer
abstractmethod
¶
get_tracer() -> Any
Get the configured tracer.
Returns:
| Type | Description |
|---|---|
Any
|
The OpenTelemetry tracer instance if configured, None otherwise |
create_span
abstractmethod
¶
Create a new trace span.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the span |
required |
attributes
|
dict[str, Any] | None
|
Optional attributes to attach to the span |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
Span instance if telemetry is configured, None otherwise |
Source code in azure_bootstrap/services/interfaces/telemetry_manager_interface.py
log_email_processing_start
abstractmethod
¶
log_email_processing_success
abstractmethod
¶
Log successful email processing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message_id
|
str
|
Email message ID |
required |
user_email
|
str
|
User email address |
required |
processing_time_ms
|
int
|
Processing time in milliseconds |
required |
Source code in azure_bootstrap/services/interfaces/telemetry_manager_interface.py
log_email_processing_error
abstractmethod
¶
log_email_processing_error(error: str, message_id: str | None = None, user_email: str | None = None) -> None
Log email processing error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
error
|
str
|
Error message |
required |
message_id
|
str | None
|
Email message ID (if available) |
None
|
user_email
|
str | None
|
User email address (if available) |
None
|
Source code in azure_bootstrap/services/interfaces/telemetry_manager_interface.py
log_queue_message_received
abstractmethod
¶
log_storage_operation
abstractmethod
¶
Log storage operations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation
|
str
|
Type of storage operation |
required |
container
|
str
|
Storage container name |
required |
blob_name
|
str
|
Blob name |
required |
success
|
bool
|
Whether the operation succeeded |
required |