Skip to content

Commit

Permalink
feedback: pass in tracer_provider directly rather than kwargs
Browse files Browse the repository at this point in the history
  • Loading branch information
jfmyers9 committed Oct 12, 2021
1 parent d99eeaf commit ddb2894
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,20 @@ def _instrument(self, **kwargs):
Returns:
An instrumented engine if passed in as an argument, None otherwise.
"""
_w("sqlalchemy", "create_engine", _wrap_create_engine(kwargs))
_w("sqlalchemy.engine", "create_engine", _wrap_create_engine(kwargs))
tracer_provider = kwargs.get("tracer_provider")
_w("sqlalchemy", "create_engine", _wrap_create_engine(tracer_provider))
_w("sqlalchemy.engine", "create_engine", _wrap_create_engine(tracer_provider))
if parse_version(sqlalchemy.__version__).release >= (1, 4):
_w(
"sqlalchemy.ext.asyncio",
"create_async_engine",
_wrap_create_async_engine(kwargs),
_wrap_create_async_engine(tracer_provider),
)

if kwargs.get("engine") is not None:
return EngineTracer(
_get_tracer(
kwargs.get("engine"), kwargs.get("tracer_provider")
kwargs.get("engine"), tracer_provider
),
kwargs.get("engine"),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ def _get_tracer(engine, tracer_provider=None):


# pylint: disable=unused-argument
def _wrap_create_async_engine(kwargs):
tracer_provider = kwargs.get("tracer_provider")

def _wrap_create_async_engine(tracer_provider=None):
def _wrap_create_async_engine_internal(func, module, args, kwargs):
"""Trace the SQLAlchemy engine, creating an `EngineTracer`
object that will listen to SQLAlchemy events.
Expand All @@ -58,9 +56,7 @@ def _wrap_create_async_engine_internal(func, module, args, kwargs):


# pylint: disable=unused-argument
def _wrap_create_engine(kwargs):
tracer_provider = kwargs.get("tracer_provider")

def _wrap_create_engine(tracer_provider=None):
def _wrap_create_engine_internal(func, module, args, kwargs):
"""Trace the SQLAlchemy engine, creating an `EngineTracer`
object that will listen to SQLAlchemy events.
Expand Down

0 comments on commit ddb2894

Please sign in to comment.