bw-essentials-core 0.2.0__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/PKG-INFO +1 -1
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/gunicorn.py +79 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/logging.py +32 -8
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials_core.egg-info/PKG-INFO +1 -1
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/setup.py +1 -1
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/README.md +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/EventNotification/EventBridgePublisher.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/EventNotification/NotificationType.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/EventNotification/__init__.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/EventNotification/models/__init__.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/EventNotification/models/notification_type.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/__init__.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/constants/__init__.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/constants/services.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/data_loch/__init__.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/data_loch/data_loch.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/email_client/__init__.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/email_client/email_client.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/logging/__init__.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/logging/_config.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/logging/_context.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/logging/_correlation.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/logging/_processors.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/logging/_redaction.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/middlewares/__init__.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/middlewares/fastapi/__init__.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/middlewares/fastapi/exception.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/middlewares/fastapi/request.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/notifications/__init__.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/notifications/fcm/__init__.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/notifications/fcm/client.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/notifications/fcm/exceptions.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/notifications/fcm/payload_builder.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/notifications/fcm/response.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/notifications/fcm/settings.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/notifications/teams_notification_schemas.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/notifications/teams_notifications.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/__init__.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/_body.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/_core/__init__.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/_core/celery.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/_core/client_hooks.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/_core/config.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/_core/deps.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/_core/exceptions.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/_core/lifecycle.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/_core/log_processor.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/_core/logging_bridge.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/_core/metric_export.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/_core/propagation.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/_core/provider.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/_core/span_export.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/_core/span_policies.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/_core/state.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/boundaries.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/context.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/django/__init__.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/django/errors.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/django/middleware.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/django/otel.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/fastapi/__init__.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/fastapi/body.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/fastapi/otel.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/services.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/py.typed +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/redaction/__init__.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/redaction/cap.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/redaction/engine.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/redaction/keys.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/redaction/lexer.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/redaction/patterns.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/s3_utils/__init__.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/s3_utils/s3_utils.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/__init__.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/api_client.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/broker.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/compliance.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/job_scheduler.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/market_pricer.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/master_data.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/model_portfolio_reporting.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/notification.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/notification_finn.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/payment.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/portfolio_business.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/portfolio_catalogue.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/portfolio_content.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/portfolio_product.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/rebalancing_business.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/trade_placement.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/user_app.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/user_portfolio.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/user_portfolio_business.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/user_portfolio_reporting.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/user_referrals.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/tools/__init__.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/tools/manifest_lint.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/tools/secret_grep.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials_core.egg-info/SOURCES.txt +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials_core.egg-info/dependency_links.txt +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials_core.egg-info/entry_points.txt +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials_core.egg-info/requires.txt +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials_core.egg-info/top_level.txt +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/setup.cfg +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/tests/test_api_client_errors.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/tests/test_api_client_logging.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/tests/test_api_client_retries.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/tests/test_broker_reconciliation.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/tests/test_client_body_logging.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/tests/test_compliance.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/tests/test_django_observability.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/tests/test_event_bridge_publisher.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/tests/test_fcm_platform_config.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/tests/test_master_data_trading_calendar.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/tests/test_notification_finn.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/tests/test_notification_service.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/tests/test_observability_import.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/tests/test_payment.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/tests/test_pii_response_log_redaction.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/tests/test_portfolio_business.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/tests/test_portfolio_business_service_contracts.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/tests/test_portfolio_catalogue.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/tests/test_portfolio_product.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/tests/test_rebalancing_business.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/tests/test_user_app.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/tests/test_user_portfolio.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/tests/test_user_portfolio_business.py +0 -0
- {bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/tests/test_user_portfolio_reporting.py +0 -0
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/gunicorn.py
RENAMED
|
@@ -41,6 +41,7 @@ def _post_worker_init(worker: Any) -> None:
|
|
|
41
41
|
from bw_essentials.observability.django.otel import init_otel
|
|
42
42
|
|
|
43
43
|
init_otel()
|
|
44
|
+
_reload_django_middleware(worker)
|
|
44
45
|
return
|
|
45
46
|
|
|
46
47
|
if _fastapi_loaded():
|
|
@@ -140,6 +141,84 @@ def _fastapi_loaded() -> bool:
|
|
|
140
141
|
return "fastapi" in sys.modules
|
|
141
142
|
|
|
142
143
|
|
|
144
|
+
def _reload_django_middleware(worker: Any) -> None:
|
|
145
|
+
"""Add late OTel instrumentation to Gunicorn's already-loaded handler."""
|
|
146
|
+
from django.conf import settings
|
|
147
|
+
from django.core.handlers.base import BaseHandler
|
|
148
|
+
from opentelemetry.instrumentation.django import DjangoInstrumentor
|
|
149
|
+
from opentelemetry.instrumentation.django.middleware.otel_middleware import (
|
|
150
|
+
_DjangoMiddleware,
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
middleware_path = DjangoInstrumentor._opentelemetry_middleware
|
|
154
|
+
if middleware_path not in getattr(settings, "MIDDLEWARE", ()):
|
|
155
|
+
return
|
|
156
|
+
|
|
157
|
+
handler = _find_django_handler(worker, BaseHandler)
|
|
158
|
+
if handler is None:
|
|
159
|
+
_warn_once(
|
|
160
|
+
"OpenTelemetry instrumented Django after its WSGI handler was loaded, "
|
|
161
|
+
"but the Gunicorn worker does not expose that handler; call init_otel() "
|
|
162
|
+
"before get_wsgi_application()"
|
|
163
|
+
)
|
|
164
|
+
return
|
|
165
|
+
|
|
166
|
+
if _callable_contains_instance(handler._middleware_chain, _DjangoMiddleware):
|
|
167
|
+
return
|
|
168
|
+
handler.load_middleware()
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def _find_django_handler(worker: Any, handler_type: type) -> Any | None:
|
|
172
|
+
candidates = (
|
|
173
|
+
getattr(worker, "wsgi", None),
|
|
174
|
+
getattr(getattr(worker, "app", None), "callable", None),
|
|
175
|
+
)
|
|
176
|
+
for candidate in candidates:
|
|
177
|
+
current = candidate
|
|
178
|
+
seen: set[int] = set()
|
|
179
|
+
for _ in range(5):
|
|
180
|
+
if isinstance(current, handler_type):
|
|
181
|
+
return current
|
|
182
|
+
if current is None or id(current) in seen:
|
|
183
|
+
break
|
|
184
|
+
seen.add(id(current))
|
|
185
|
+
current = next(
|
|
186
|
+
(
|
|
187
|
+
nested
|
|
188
|
+
for attribute in ("application", "app", "wsgi_application")
|
|
189
|
+
if (nested := getattr(current, attribute, None)) is not None
|
|
190
|
+
and nested is not current
|
|
191
|
+
),
|
|
192
|
+
None,
|
|
193
|
+
)
|
|
194
|
+
return None
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def _callable_contains_instance(root: Any, instance_type: type) -> bool:
|
|
198
|
+
"""Inspect Django's closure-based middleware chain without invoking it."""
|
|
199
|
+
pending = [root]
|
|
200
|
+
seen: set[int] = set()
|
|
201
|
+
while pending:
|
|
202
|
+
current = pending.pop()
|
|
203
|
+
if current is None or id(current) in seen:
|
|
204
|
+
continue
|
|
205
|
+
seen.add(id(current))
|
|
206
|
+
if isinstance(current, instance_type):
|
|
207
|
+
return True
|
|
208
|
+
bound_to = getattr(current, "__self__", None)
|
|
209
|
+
if bound_to is not None:
|
|
210
|
+
pending.append(bound_to)
|
|
211
|
+
nested_response = getattr(current, "get_response", None)
|
|
212
|
+
if nested_response is not None:
|
|
213
|
+
pending.append(nested_response)
|
|
214
|
+
for cell in getattr(current, "__closure__", ()) or ():
|
|
215
|
+
try:
|
|
216
|
+
pending.append(cell.cell_contents)
|
|
217
|
+
except ValueError:
|
|
218
|
+
pass
|
|
219
|
+
return False
|
|
220
|
+
|
|
221
|
+
|
|
143
222
|
def _warn_once(message: str) -> None:
|
|
144
223
|
pid = os.getpid()
|
|
145
224
|
if pid in _WARNED_PIDS:
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/logging.py
RENAMED
|
@@ -80,11 +80,6 @@ class SafeFormatter(logging.Formatter):
|
|
|
80
80
|
self._delegate.format(safe_record)
|
|
81
81
|
)
|
|
82
82
|
|
|
83
|
-
# Render interpolation exactly once, on the copy. Redacting msg
|
|
84
|
-
# before this step would break both tuple and mapping %-arguments.
|
|
85
|
-
rendered = safe_record.getMessage()
|
|
86
|
-
safe_record.msg = redact(rendered)
|
|
87
|
-
safe_record.args = None
|
|
88
83
|
# Logger names are caller-controlled (for example dynamic tenant or
|
|
89
84
|
# integration names) and are rendered by most console/file formats.
|
|
90
85
|
safe_record.name = _redact_text(safe_record.name)
|
|
@@ -100,11 +95,28 @@ class SafeFormatter(logging.Formatter):
|
|
|
100
95
|
safe_record.stack_info = _redact_text(safe_record.stack_info)
|
|
101
96
|
|
|
102
97
|
_redact_extras(safe_record)
|
|
103
|
-
|
|
98
|
+
|
|
99
|
+
# Render interpolation exactly once, on a copy. Redacting msg
|
|
100
|
+
# before this step would break both tuple and mapping %-arguments.
|
|
101
|
+
rendered_record = copy.copy(safe_record)
|
|
102
|
+
rendered_record.msg = redact(rendered_record.getMessage())
|
|
103
|
+
rendered_record.args = None
|
|
104
|
+
if self._delegate is None:
|
|
105
|
+
return _redact_rendered_output(super().format(rendered_record))
|
|
106
|
+
try:
|
|
104
107
|
return _redact_rendered_output(
|
|
105
|
-
self._delegate.format(
|
|
108
|
+
self._delegate.format(rendered_record)
|
|
106
109
|
)
|
|
107
|
-
|
|
110
|
+
except Exception: # noqa: BLE001 - retried below, then fail closed.
|
|
111
|
+
if not safe_record.args:
|
|
112
|
+
raise
|
|
113
|
+
# Some delegates read record.args themselves: uvicorn's
|
|
114
|
+
# AccessFormatter unpacks (client, method, path, version, status)
|
|
115
|
+
# and fails once args are collapsed into msg. Give such a delegate
|
|
116
|
+
# each argument redacted on its own, with its type kept, and redact
|
|
117
|
+
# the complete line it renders as well.
|
|
118
|
+
safe_record.args = _redact_args(safe_record.args)
|
|
119
|
+
return _redact_rendered_output(self._delegate.format(safe_record))
|
|
108
120
|
except Exception: # noqa: BLE001 - logging must fail closed, never escape.
|
|
109
121
|
return REDACTED_ERROR
|
|
110
122
|
|
|
@@ -133,6 +145,18 @@ def _redact_rendered_output(value: Any) -> str:
|
|
|
133
145
|
return _redact_text(value)
|
|
134
146
|
|
|
135
147
|
|
|
148
|
+
def _redact_args(args: Any) -> Any:
|
|
149
|
+
"""Redact %-arguments one by one, keeping a tuple a tuple and a mapping a mapping."""
|
|
150
|
+
if isinstance(args, Mapping):
|
|
151
|
+
sanitized = redact(dict(args))
|
|
152
|
+
if not isinstance(sanitized, Mapping):
|
|
153
|
+
raise ValueError("redacted mapping arguments lost their shape")
|
|
154
|
+
return sanitized
|
|
155
|
+
if isinstance(args, tuple):
|
|
156
|
+
return tuple(redact(value) for value in args)
|
|
157
|
+
raise ValueError(f"unsupported log arguments: {type(args).__name__}")
|
|
158
|
+
|
|
159
|
+
|
|
136
160
|
def _is_processor_formatter(formatter: logging.Formatter) -> bool:
|
|
137
161
|
"""Recognize structlog's formatter without making it a hard dependency."""
|
|
138
162
|
try:
|
|
@@ -29,7 +29,7 @@ OBSERVABILITY_REQUIRES = [
|
|
|
29
29
|
|
|
30
30
|
setup(
|
|
31
31
|
name="bw-essentials-core",
|
|
32
|
-
version="0.2.
|
|
32
|
+
version="0.2.2",
|
|
33
33
|
author="InvestorAI",
|
|
34
34
|
author_email="support+tech@investorai.in",
|
|
35
35
|
description="Reusable utilities for S3, email, Data Loch, Microsoft Teams Notifications and more.",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/EventNotification/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/email_client/__init__.py
RENAMED
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/email_client/email_client.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/middlewares/fastapi/__init__.py
RENAMED
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/middlewares/fastapi/exception.py
RENAMED
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/middlewares/fastapi/request.py
RENAMED
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/notifications/__init__.py
RENAMED
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/notifications/fcm/__init__.py
RENAMED
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/notifications/fcm/client.py
RENAMED
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/notifications/fcm/exceptions.py
RENAMED
|
File without changes
|
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/notifications/fcm/response.py
RENAMED
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/notifications/fcm/settings.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/_core/__init__.py
RENAMED
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/_core/celery.py
RENAMED
|
File without changes
|
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/_core/config.py
RENAMED
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/_core/deps.py
RENAMED
|
File without changes
|
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/_core/lifecycle.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/_core/provider.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/_core/state.py
RENAMED
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/boundaries.py
RENAMED
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/context.py
RENAMED
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/django/__init__.py
RENAMED
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/django/errors.py
RENAMED
|
File without changes
|
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/django/otel.py
RENAMED
|
File without changes
|
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/fastapi/body.py
RENAMED
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/fastapi/otel.py
RENAMED
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/observability/services.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/job_scheduler.py
RENAMED
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/market_pricer.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/notification.py
RENAMED
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/notification_finn.py
RENAMED
|
File without changes
|
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/portfolio_business.py
RENAMED
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/portfolio_catalogue.py
RENAMED
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/portfolio_content.py
RENAMED
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/portfolio_product.py
RENAMED
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/rebalancing_business.py
RENAMED
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/trade_placement.py
RENAMED
|
File without changes
|
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/user_portfolio.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials/services/user_referrals.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials_core.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials_core.egg-info/entry_points.txt
RENAMED
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials_core.egg-info/requires.txt
RENAMED
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/bw_essentials_core.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/tests/test_master_data_trading_calendar.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/tests/test_pii_response_log_redaction.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{bw_essentials_core-0.2.0 → bw_essentials_core-0.2.2}/tests/test_user_portfolio_reporting.py
RENAMED
|
File without changes
|