dataenginex.middleware
Middleware — logging, metrics, and domain-level Prometheus counters.
Public API::
from dataenginex.middleware import configure_logging, get_logger
from dataenginex.middleware import get_metrics
from dataenginex.middleware.domain_metrics import pipeline_runs_total, ai_tokens_total
configure_logging(log_level='INFO', json_logs=True)
Configure structlog for the application.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_level
|
str
|
Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL) |
'INFO'
|
json_logs
|
bool
|
If True, output JSON logs; otherwise use coloured console |
True
|
Source code in src/dataenginex/middleware/logging_config.py
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 114 115 116 117 118 119 | |
get_logger(name)
Get a configured structlog logger instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Logger name (typically |
required |
Returns:
| Type | Description |
|---|---|
BoundLogger
|
Configured structlog logger |
Source code in src/dataenginex/middleware/logging_config.py
122 123 124 125 126 127 128 129 130 131 | |
get_metrics()
Generate Prometheus metrics in text format.
Returns:
| Type | Description |
|---|---|
tuple[bytes, str]
|
Tuple of (metrics_data, content_type) |
Source code in src/dataenginex/middleware/metrics.py
62 63 64 65 66 67 68 69 | |