haive.core.utils.debugkit.configΒΆ

Development utilities configuration system.

This module provides centralized configuration for all development utilities including debugging, logging, profiling, and static analysis tools.

ClassesΒΆ

DevConfig

Centralized configuration for all development utilities.

Environment

Supported runtime environments.

LogLevel

Logging levels for development utilities.

StorageBackend

Storage backends for analysis data.

Module ContentsΒΆ

class haive.core.utils.debugkit.config.DevConfig[source]ΒΆ

Centralized configuration for all development utilities.

This class provides comprehensive configuration options for debugging, logging, profiling, tracing, and static analysis tools. It automatically adjusts settings based on the runtime environment.

enabledΒΆ

Whether development utilities are enabled globally

environmentΒΆ

Current runtime environment

debug_enabledΒΆ

Enable debug utilities (icecream, pdb, etc.)

log_enabledΒΆ

Enable logging utilities

trace_enabledΒΆ

Enable execution tracing

profile_enabledΒΆ

Enable performance profiling

benchmark_enabledΒΆ

Enable benchmarking utilities

static_analysis_enabledΒΆ

Enable static analysis tools

production_safeΒΆ

Automatically reduce overhead in production

trace_sampling_rateΒΆ

Percentage of traces to capture (0.0-1.0)

profile_overhead_limitΒΆ

Maximum acceptable performance overhead

storage_enabledΒΆ

Enable persistent storage of analysis data

storage_backendΒΆ

Backend for storing analysis data

storage_pathΒΆ

Path for file-based storage

storage_configΒΆ

Additional storage configuration

use_richΒΆ

Enable rich terminal formatting

color_enabledΒΆ

Enable colored output

verboseΒΆ

Enable verbose output

log_levelΒΆ

Minimum logging level

auto_analyzeΒΆ

Automatically analyze instrumented functions

runtime_type_checkΒΆ

Enable runtime type checking

correlation_enabledΒΆ

Enable correlation ID tracking

dashboard_enabledΒΆ

Enable web dashboard

dashboard_portΒΆ

Port for web dashboard

max_file_sizeΒΆ

Maximum size for analysis files (bytes)

retention_daysΒΆ

Days to retain analysis data

excluded_pathsΒΆ

Paths to exclude from analysis

included_toolsΒΆ

Static analysis tools to include

excluded_toolsΒΆ

Static analysis tools to exclude

Examples

Basic usage with defaults:

config = DevConfig()
print(f"Environment: {config.environment}")
print(f"Debug enabled: {config.debug_enabled}")

Custom configuration:

config = DevConfig(
    environment=Environment.PRODUCTION,
    trace_sampling_rate=0.01,
    storage_backend=StorageBackend.POSTGRESQL
)

Environment-based configuration:

config = DevConfig.from_env()
config.configure_for_testing()
classmethod from_env()[source]ΒΆ

Create configuration from environment variables.

Reads configuration from environment variables with HAIVE_ prefix. Provides a convenient way to configure the system through environment variables in containerized or CI/CD environments.

Returns:

Configuration instance populated from environment

Return type:

DevConfig

Environment Variables:

HAIVE_ENV: Runtime environment (development/testing/staging/production) HAIVE_DEV_ENABLED: Enable development utilities (true/false) HAIVE_DEBUG_ENABLED: Enable debug utilities (true/false) HAIVE_LOG_ENABLED: Enable logging utilities (true/false) HAIVE_TRACE_ENABLED: Enable tracing utilities (true/false) HAIVE_PROFILE_ENABLED: Enable profiling utilities (true/false) HAIVE_BENCHMARK_ENABLED: Enable benchmarking utilities (true/false) HAIVE_STATIC_ANALYSIS_ENABLED: Enable static analysis (true/false) HAIVE_TRACE_SAMPLING_RATE: Trace sampling rate (0.0-1.0) HAIVE_STORAGE_BACKEND: Storage backend (none/memory/sqlite/postgresql/file) HAIVE_STORAGE_PATH: Path for file-based storage HAIVE_LOG_LEVEL: Minimum logging level (TRACE/DEBUG/INFO/WARNING/ERROR) HAIVE_DASHBOARD_ENABLED: Enable web dashboard (true/false) HAIVE_DASHBOARD_PORT: Port for web dashboard (integer) HAIVE_VERBOSE: Enable verbose output (true/false)

Examples

Load from environment:

# Set environment variables
os.environ["HAIVE_ENV"] = "production"
os.environ["HAIVE_TRACE_SAMPLING_RATE"] = "0.01"

# Create config
config = DevConfig.from_env()
assert config.environment == Environment.PRODUCTION
assert config.trace_sampling_rate == 0.01
get_effective_log_level()[source]ΒΆ

Get the effective log level as string.

Returns:

Log level string compatible with logging libraries

Return type:

str

Examples

Configure logger:

import logging
logging.basicConfig(level=config.get_effective_log_level())
get_storage_config()[source]ΒΆ

Get complete storage configuration.

Returns:

Storage configuration dictionary

Return type:

Dict[str, Any]

Examples

Get storage settings:

storage_config = config.get_storage_config()
backend = storage_config["backend"]
path = storage_config["path"]
is_tool_enabled(tool_name)[source]ΒΆ

Check if a specific tool is enabled.

Parameters:

tool_name (str) – Name of the tool to check

Returns:

True if the tool is enabled, False otherwise

Return type:

bool

Examples

Check tool availability:

if config.is_tool_enabled("mypy"):
    # Run mypy analysis
    pass
should_sample_trace()[source]ΒΆ

Determine if current trace should be sampled.

Uses the configured sampling rate to decide whether to capture a trace. This helps reduce overhead in high-throughput environments.

Returns:

True if trace should be captured, False otherwise

Return type:

bool

Examples

Conditional tracing:

if config.should_sample_trace():
    # Capture detailed trace
    trace_function()
to_dict()[source]ΒΆ

Convert configuration to dictionary.

Returns:

Configuration as dictionary

Return type:

Dict[str, Any]

Examples

Serialize config:

config_dict = config.to_dict()
json.dump(config_dict, file)
update(**kwargs)[source]ΒΆ

Update configuration with new values.

Parameters:

**kwargs (Any) – Configuration values to update

Return type:

None

Examples

Update multiple values:

config.update(
    verbose=True,
    log_level=LogLevel.DEBUG,
    trace_sampling_rate=0.5
)
class haive.core.utils.debugkit.config.Environment[source]ΒΆ

Bases: str, enum.Enum

Supported runtime environments.

DEVELOPMENTΒΆ

Local development environment with full debugging

TESTINGΒΆ

Test environment with reduced overhead

STAGINGΒΆ

Staging environment with minimal debugging

PRODUCTIONΒΆ

Production environment with error logging only

Initialize self. See help(type(self)) for accurate signature.

class haive.core.utils.debugkit.config.LogLevel[source]ΒΆ

Bases: str, enum.Enum

Logging levels for development utilities.

TRACEΒΆ

Most verbose logging including execution traces

DEBUGΒΆ

Debug information for development

INFOΒΆ

General information messages

WARNINGΒΆ

Warning messages for potential issues

ERRORΒΆ

Error messages only

Initialize self. See help(type(self)) for accurate signature.

class haive.core.utils.debugkit.config.StorageBackend[source]ΒΆ

Bases: str, enum.Enum

Storage backends for analysis data.

NONEΒΆ

No persistent storage

MEMORYΒΆ

In-memory storage (lost on restart)

SQLITEΒΆ

SQLite database storage

POSTGRESQLΒΆ

PostgreSQL database storage

FILEΒΆ

File-based storage

Initialize self. See help(type(self)) for accurate signature.