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

Porting sqlalchemy instrumentation from contrib repo #591

Merged
merged 47 commits into from
Apr 29, 2020

Conversation

codeboten
Copy link
Contributor

@codeboten codeboten commented Apr 16, 2020

Porting the existing sqlalchemy instrumentation from the contrib repo to using the OpenTelemetry API and the OpenTelemetry Auto-instrumentation Patcher interface.

This is replacing open-telemetry/opentelemetry-python-contrib#22

@codeboten codeboten marked this pull request as ready for review April 17, 2020 15:16
@codeboten codeboten requested a review from a team as a code owner April 17, 2020 15:16
@codeboten codeboten added the instrumentation Related to the instrumentation of third party libraries or frameworks label Apr 17, 2020
Copy link
Member

@mauriciovasquezbernal mauriciovasquezbernal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a first pass and it looks great. I compared to the DataDog implementation and I think the porting you did is just right.
Most of the comments are just nits, maybe we only important one is about updating the assert states to self.assert*...

I tested it with the autoinstrumentation command by running and example and it works without issues.

Should we add an entry in the documentation for it?

@@ -0,0 +1,13 @@
# Copyright The OpenTelemetry Authors

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this file could just be empty.

alrex and others added 4 commits April 17, 2020 16:25
@codeboten codeboten added the needs reviewers PRs with this label are ready for review and needs people to review to move forward. label Apr 20, 2020
@mauriciovasquezbernal
Copy link
Member

Copy link
Member

@mauriciovasquezbernal mauriciovasquezbernal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM:

  • I clearly can see how it is based on DataDog donation
  • Documentation is present
  • Unit tests are present
  • Integration tests are implemented and working

Co-Authored-By: Mauricio Vásquez <mauricio@kinvolk.io>
.. |pypi| image:: https://badge.fury.io/py/opentelemetry-ext-sqlalchemy.svg
:target: https://pypi.org/project/opentelemetry-ext-sqlalchemy/

This library allows tracing requests made by the SQLAlchemy library.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it might be good to call out popular databases that we don't have integrations for that are supported by SQLAlchemy? Or include a link? I get some customers that are confused on which integrations to use for their databases, and we should have a consistent recommendation. I believe we should recommend the specific integrations if they exist (like for mysql), and to try to use SQLAlchemy otherwise (if supported).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a link to sqlalchemy to the reference section. Regarding recommendations, I wonder where the best place to put something like this is, seems like it could be part of the examples section 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can just verbally indicate in the README: "For MYSQL use the integration(link), for postgres use the integration(link). For all other databases that support SQLAlchemy, use this..."

import sqlalchemy

trace.set_tracer_provider(TracerProvider())
engine = create_engine("sqlite:///:memory:")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to import create_engine

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed! thanks

Copy link
Contributor

@lzchen lzchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Few non-blocking comments.

Copy link
Contributor

@ocelotl ocelotl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, probably just needs minor lint fixes to pass those tests again.

@c24t c24t merged commit e6a9d97 into open-telemetry:master Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
instrumentation Related to the instrumentation of third party libraries or frameworks needs reviewers PRs with this label are ready for review and needs people to review to move forward.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants