Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add span for connection phase #1134

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
886ce6a
Add span for connection phase
shahargl Jun 15, 2022
0d7c028
Fix the tests
shahargl Jun 16, 2022
3310698
Merge branch 'main' into feature/sqlalchemy-connect-span
shahargl Jun 16, 2022
cd588a8
Fix the multiple engine test
shahargl Jun 16, 2022
1d33583
Add engine connection instrumentation test
shahargl Jun 16, 2022
269fada
Merge branch 'main' into feature/sqlalchemy-connect-span
srikanthccv Jun 16, 2022
6141cb7
Support SQLAlchemy 1.1 too
shahargl Jun 19, 2022
d86faf4
Merge branch 'feature/sqlalchemy-connect-span' of github.com:shahargl…
shahargl Jun 19, 2022
3ca0778
Merge branch 'main' into feature/sqlalchemy-connect-span
srikanthccv Jun 21, 2022
3a22a4a
Update instrumentation/opentelemetry-instrumentation-sqlalchemy/src/o…
shahargl Jun 22, 2022
7b539c5
Merge branch 'main' into feature/sqlalchemy-connect-span
srikanthccv Jun 25, 2022
59f1e6d
Don't create tracer for each connect
shahargl Jun 26, 2022
4ade098
Merge from main
shahargl Jun 26, 2022
72c82cc
Update instrumentation/opentelemetry-instrumentation-sqlalchemy/src/o…
shahargl Jun 27, 2022
46f3bc1
Merge branch 'main' into feature/sqlalchemy-connect-span
srikanthccv Jun 27, 2022
467e614
Fix the tests
shahargl Jun 28, 2022
0d580a0
Merge branch 'main' into feature/sqlalchemy-connect-span
srikanthccv Jul 3, 2022
64c93a6
tox generate
shahargl Jul 11, 2022
f958a59
Merge branch 'feature/sqlalchemy-connect-span' of github.com:shahargl…
shahargl Jul 11, 2022
d2df489
Fix tests
shahargl Jul 11, 2022
24d4bcc
fix tests
shahargl Jul 12, 2022
95fe38a
Merge branch 'main' into feature/sqlalchemy-connect-span
srikanthccv Jul 12, 2022
2751862
.
shahargl Jul 12, 2022
cc4513a
Merge branch 'main' into feature/sqlalchemy-connect-span
shahargl Jul 17, 2022
91fb04d
fixing typos
shahargl Jul 17, 2022
43229e0
Merge branch 'feature/sqlalchemy-connect-span' of github.com:shahargl…
shahargl Jul 17, 2022
bb53566
Fixing test_instrument
shahargl Jul 17, 2022
64c0ad5
revert change
shahargl Jul 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
_get_tracer,
_wrap_create_async_engine,
_wrap_create_engine,
_wrap_connect,
)
from opentelemetry.instrumentation.sqlalchemy.package import _instruments
from opentelemetry.instrumentation.utils import unwrap
Expand Down Expand Up @@ -101,7 +102,11 @@ def _instrument(self, **kwargs):
"create_async_engine",
_wrap_create_async_engine(tracer_provider),
)

_w(
"sqlalchemy.engine.base",
"Engine.connect",
_wrap_connect(tracer_provider)
)
if kwargs.get("engine") is not None:
return EngineTracer(
_get_tracer(tracer_provider),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ def _wrap_create_engine_internal(func, module, args, kwargs):
return _wrap_create_engine_internal


def _wrap_connect(tracer_provider=None):
def _wrap_connect_internal(func, module, args, kwargs):
shahargl marked this conversation as resolved.
Show resolved Hide resolved
tracer = trace.get_tracer(
module.name,
__version__,
tracer_provider=tracer_provider,
)
srikanthccv marked this conversation as resolved.
Show resolved Hide resolved
with tracer.start_as_current_span("database-connect") as span:
return func(*args, **kwargs)
return _wrap_connect_internal

class EngineTracer:
def __init__(self, tracer, engine, enable_commenter=False):
self.tracer = tracer
Expand Down