Fix instrumentation of SQLAlchemy when using sqlalchemy.engine_from_config#2816
Conversation
sqlalchemy.engine_from_config directly calls create_engine imported from that path; if we don't wrap that copy of the `create_engine` call then engines created via engine_from_config are not instrumented.
|
|
Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
emdneto
left a comment
There was a problem hiding this comment.
oh wait, there's a pypy test failing 😓
|
Thanks for putting this in! Currently 5 of the unit tests are failing with |
Sorry for dropping the ball on this for a while, @tammy-baylis-swi. I've not contributed to otel before, and not used tox before either; would you be able to elaborate on what I need to do with the |
No worries @moredip ! Coincidentally, yesterday we merged 2 PRs to address some of what I mentioned:
I'm going to merge |
…/test_sqlalchemy.py Co-authored-by: Tammy Baylis <96076570+tammy-baylis-swi@users.noreply.github.com>
|
Getting closer! Please could you run a |
Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
tammy-baylis-swi
left a comment
There was a problem hiding this comment.
Looks good to me. Thank you 😺
Thanks so much for patiently shepherding me through! Very much appreciated 🙇 |
|
@tammy-baylis-swi @emdneto @xrmx is this OK to merge, or do I also need to wait on a 👍 from @shalevr |
…onfig (open-telemetry#2816) * wrap sqlalchemy.engine.create.create_engine sqlalchemy.engine_from_config directly calls create_engine imported from that path; if we don't wrap that copy of the `create_engine` call then engines created via engine_from_config are not instrumented. * add changelog entry * Update CHANGELOG.md Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com> * Update instrumentation/opentelemetry-instrumentation-sqlalchemy/tests/test_sqlalchemy.py Co-authored-by: Tammy Baylis <96076570+tammy-baylis-swi@users.noreply.github.com> * make some monkey-patching conditional on the version of SQLAlchemy * lint * fix changelog Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com> * Update CHANGELOG.md --------- Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com> Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com> Co-authored-by: Leighton Chen <lechen@microsoft.com> Co-authored-by: Shalev Roda <65566801+shalevr@users.noreply.github.com> Co-authored-by: Tammy Baylis <96076570+tammy-baylis-swi@users.noreply.github.com> Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
Description
Fixes a bug where SQLAlchemy engines created via
sqlalchemy.engine_from_config(...)are not instrumented bySQLAlchemyInstrumentor.sqlalchemy.engine_from_config(...)directly callscreate_engine(...)imported fromsqlalchemy.engine.create. If we don't wrap that copy of thecreate_enginemethod then engines created viaengine_from_configare notinstrumented.
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.