-
Notifications
You must be signed in to change notification settings - Fork 4
Closed
Description
Currently, the bootstrap method initializes the application and allows instruments to modify it in the bootstrap_after phase:
for instrument in self.instrument_box.instruments:
if instrument.is_ready():
application = instrument.bootstrap_after(application)
return self.bootstrap_after(application)
However, there is no way to execute code just before this step, after the application instance is created but before instruments modify it. This limitation makes it difficult to introduce additional setup or modifications that should take place at this stage.
One particular use case for this hook is the need to set up dependency injection and initialize SQLAlchemy instrumentator with the engine. See:
_container = modern_di_fastapi.setup_di(application)
with _container as container:
engine = _engine.sync_resolve(container)
self.settings.opentelemetry_instrumentors.append(
OpenTelemetryInstrumentor(
SQLAlchemyInstrumentor(),
{
"enable_commenter": True,
"commenter_options": {},
"engine": engine
},
),
)
Metadata
Metadata
Assignees
Labels
No labels