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 pymssql instrumentation #394

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

guillaumep
Copy link

@guillaumep guillaumep commented Apr 1, 2021

Description

This pull request implements instrumentation for the pymssql library (https://pypi.org/project/pymssql/).
It is basically a copy of the pymysql instrumentation.

Still a work-in-progress.

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

  • Ran tox tests
  • Tested manually in a python program - verified that traces are properly sent

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated [PARTIAL] -> I can complete that once the PR is opened and I have an issue number
  • Unit tests have been added
  • Documentation has been updated

@guillaumep guillaumep requested review from a team, owais and lzchen and removed request for a team April 1, 2021 19:03
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Apr 1, 2021

CLA Signed

The committers are authorized under a signed CLA.

@guillaumep guillaumep marked this pull request as draft April 1, 2021 19:28
@guillaumep
Copy link
Author

It seems from the CI logs that pymssql does not build for pypy3.

Would it be acceptable to disable pypy3 support in the tests for this instrumentation?

@guillaumep
Copy link
Author

guillaumep commented Apr 1, 2021

Also, the docs fails to build because of this error:

sphinx.errors.SphinxWarning: autodoc: failed to import module 'pymssql' from module 'opentelemetry.instrumentation'; the following exception was raised:
No module named 'pymssql'

I'm trying to figure out my error, can someone experienced with the repo help?

@guillaumep guillaumep force-pushed the instrument_pymssql branch from 0860e38 to 92d7340 Compare April 7, 2021 04:03
@guillaumep
Copy link
Author

I had to subclass DatabaseApiIntegration to obtain pymssql's connection attributes, as the attributes are not kept by the library in the Connection object. You need to get them from the connect function parameter.

def wrapped_connection(
self,
connect_method: typing.Callable[..., typing.Any],
args: typing.Tuple[typing.Any, typing.Any],
Copy link
Author

Choose a reason for hiding this comment

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

The typing is wrong here, need a variable number of arguments in the tuple.

@guillaumep guillaumep force-pushed the instrument_pymssql branch from 92d7340 to faeea0a Compare July 22, 2021 17:48
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jul 22, 2021

CLA Signed

The committers are authorized under a signed CLA.

@guillaumep guillaumep force-pushed the instrument_pymssql branch 3 times, most recently from 0e2df03 to b93ad00 Compare July 22, 2021 18:57
@lzchen
Copy link
Contributor

lzchen commented Feb 2, 2022

@guillaumep
Are you still working on this?

@guillaumep
Copy link
Author

guillaumep commented Feb 2, 2022

@lzchen I was expecting help with the issues I mentioned in the comments above, but since I never got any replies up to now I had put this work aside.

pymssql instrumention is still a feature we want at work (outbox.com), so if I can have proper support regarding my questions I'll be glad to finish this PR.

Let me rebase the PR this week and post back here with the current issues I will have.

@lzchen
Copy link
Contributor

lzchen commented Feb 3, 2022

@guillaumep
Apologies for that. Usually PRs are not reviewed unless if marked as review (changed to an actual PR). If you would like help with your build issues, feel free to rebase and we can get you the assistance you need.

@guillaumep guillaumep force-pushed the instrument_pymssql branch 2 times, most recently from 17d054f to 0333424 Compare August 26, 2022 15:03
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Aug 26, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

@guillaumep guillaumep force-pushed the instrument_pymssql branch 4 times, most recently from 96980a5 to 4cc4753 Compare August 26, 2022 22:06
@@ -119,6 +119,10 @@ envlist =
py3{7,8,9,10}-test-instrumentation-pymongo
pypy3-test-instrumentation-pymongo

; opentelemetry-instrumentation-pymssql
py3{7,8,9,10}-test-instrumentation-pymssql
; instrumentation-pymssql intentionally excluded from pypy3
Copy link
Author

Choose a reason for hiding this comment

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

pymssql has no pypy support:

pymssql/pymssql#517

Copy link
Contributor

Choose a reason for hiding this comment

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

If you could add that link in the file as a comment that'd be good.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please link this in the tox file.

@guillaumep guillaumep marked this pull request as ready for review August 26, 2022 22:55
@guillaumep guillaumep changed the title [WIP] Add pymssql instrumentation Add pymssql instrumentation Aug 26, 2022
@guillaumep
Copy link
Author

@lzchen now ready for review!

@lzchen
Copy link
Contributor

lzchen commented Aug 30, 2022

@guillaumep
Thanks for the contribution. Would you be willing to add yourself as an owner for this component under here?

@lzchen
Copy link
Contributor

lzchen commented Aug 30, 2022

Please add an entry to the README

cnx.close()

API
---
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a section for configuration like here

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this done? tracer_provider can still be configured.

https://github.com/pymssql/pymssql/
"""
tracer_provider = kwargs.get("tracer_provider")

Copy link
Contributor

Choose a reason for hiding this comment

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

Are request_hook and response_hook going to be supported?

Copy link
Author

Choose a reason for hiding this comment

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

I based my code on pymysql which does not support these hooks. Can we consider this an improvement request that could be done in a future PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

That's fine. Could you create a new issue to track this to be done?

@guillaumep
Copy link
Author

@lzchen currently working on the comments. Would you prefer I rebase, modify my current commit and force push on my branche, or would you rather like to have a new commit that addresses the comments?

@guillaumep guillaumep force-pushed the instrument_pymssql branch 2 times, most recently from 4a114eb to 9d87d8e Compare September 2, 2022 19:19
@guillaumep
Copy link
Author

@lzchen All comments addressed.

@lzchen
Copy link
Contributor

lzchen commented Sep 8, 2022

Changes look good. Just a couple of outstanding comments. Also please fix the builds :)

@srikanthccv
Copy link
Member

@guillaumep we are almost near to getting this merged. Please fix the tests and address the outstanding comments.

OpenTelemetry pymssql Instrumentation
=====================================

.. automodule:: opentelemetry.instrumentation.pymssql
Copy link
Member

Choose a reason for hiding this comment

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

Pls add the relevant needed pymssql version to docs-requirements.txt - This can be verified using tox -e docs

@@ -68,6 +68,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `opentelemetry-instrumentation-confluent-kafka` Add support for the latest versions of the library.
([#1468](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1468))

### Added
Copy link
Member

Choose a reason for hiding this comment

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

Please move this to the Unreleased section

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants