opentelemetry-python-contrib icon indicating copy to clipboard operation
opentelemetry-python-contrib copied to clipboard

Add redis client only instrumentation

Open OlegZv opened this issue 11 months ago • 9 comments

Description

This PR allows instrumenting only a specific Redis client instead of the whole class (and all clients). Changes:

  • Ability to instrument a specific Redis client with instrument_client (supports any of the existing clients such as async/cluster)
  • Added more typing for instrument and the newly added instrument_client methods (still allows **kwargs). It makes the docs easier to read/understand.
  • Moved some version "if" condition checks to global "defines" to make the code more readable.
  • Added a Redis sphinx reference so the docs can correctly link up with Redis clients.
  • Updated the docs for a more consistent structure (add specific sections). image

Please delete options that are not relevant.

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

How Has This Been Tested?

Ran the already included tests with python3.12 and python3.11 and redis 5.0.1. Added more tests to ensure that only the client we instrumented produces spans. I ran tox tests, ruff, linting, formatting, etc. (everything in the contributing guide).

Tested documentation changes with tox -e docs to ensure everything builds correctly and looks good. Also, I ran tests with coverage: original coverage was 77%. Now it's 80%: image Note: I plan to add another PR for the FT-related commands later. (there's currently a bug in some span param parsing functions)

Does This PR Require a Core Repo Change?

  • [X] No.

Checklist:

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

  • [X] Followed the style guidelines of this project
  • [X] Changelogs have been updated (will update after opening this PR)
  • [X] Unit tests have been added
  • [X] Documentation has been updated

OlegZv avatar Dec 22 '24 05:12 OlegZv

CLA Signed

The committers listed above are authorized under a signed CLA.

  • :white_check_mark: login: xrmx / name: Riccardo Magliocchetti (9032990e7df9b20b5ae8c422b7f1a488b091adf8, 5734cd0f3b61efb26546ca455c3bdc387d240af7)
  • :white_check_mark: login: OlegZv / name: Oleg (06eb8c542afd7aced6d2d98c34d38cb7255d0f02, 1f9950730c023faba82dc06228fab5daa0bdfa08, 3f8ca64ba3465d3f447d87d6d2f2a523d1c34862, 86c34cd7695343f2ed2f355c6fcc3009da2f4b74, 586a87a6e0992d94526052aea602e5d909ddc029, de415e20824bc84557def1530f4d851d9d12f7af, 3a9f1d1d0de1ff4c7a0d935b62319998258b1201, c33f2b548237750e29ed5aadb50717c55681d493, 2c291bf4b1690b7dcbd26454634c7566d234b767, edca781fb2c4ed8ca91d56565df4df8f44c2097e, 74395a803fa076c73eb40d607374724a76362f24, 04adec42e34d59a929212e730266d01e3b51beac, 0fa915b1ea1cef792addf1fa56c68db0e8b652b4, a94d8eccdb8cfd270e9b049cd2240af8b74d6374, 4c1d7e3c8a1ae8a243807aa67cc3315245a59a16, d2c4fb7a469e130933f7d4d61d6f00736ec0de33, be3ca10460855646955ba2c9c11ab7e07d4fc06b, cf8833107ef26e960051576a5a4aa4ca9f964ed1, c169b85bfeaa7aa0459be18e20ce3af190b96836, cf134eae920ce38c651541dd5faf0ca4e65bfb2b, 20b9bc8547966947776d4cef0a589eab3bdac120, 9b779980c6193dfc491dd14808d63620cda9b51f, 1ababf2cbf4c8428123aed3c76be079000e16fed, 31a8b4bb0badc36385542c1bcc9f0eb4af748eec, 0918232e345ea96d0af81906721322d4d0b5b654, 2d901c9176da76cd9db0b1613c14a99b70af9498, 69ca5cf795f218151b7c5807f30e459933273517, 0abbaee88e4ad7d2d218fc9084e4b4b74fd2b43c, 533b8a19effc26ff87fd26f9c1af0b5aca8934b5, 843e708232b95ff5ad3c03f2c16d078c99cff482)
  • :white_check_mark: login: emdneto / name: Emídio Neto (0ee8358bafceea939d1d32e674948e4c20caf7e9)

@OlegZv we can only accept contributions covered by the CLA, please sign it.

xrmx avatar Dec 23 '24 09:12 xrmx

@OlegZv we can only accept contributions covered by the CLA, please sign it.

Of course! I have already received a pre-approval for this contribution. Pending is the CLA review. Hopefully, I'll get a response soon. Can we still proceed to review these changes so I can work on any comments/change requests in the meantime?

OlegZv avatar Dec 23 '24 17:12 OlegZv

@xrmx, the CLA is finally good to go!

OlegZv avatar Feb 04 '25 19:02 OlegZv

Looking for another round of tests and approval, please! @xrmx @emdneto @lzchen

OlegZv avatar Feb 27 '25 23:02 OlegZv

Yay! Thank you! How does one get an approval for the PR? Is there something this PR is missing?

OlegZv avatar Feb 28 '25 00:02 OlegZv

I think I'll wait for the approval before doing "Update branch".

OlegZv avatar Mar 04 '25 03:03 OlegZv

Hello @xrmx! Thanks again for the review. Are my responses satisfactory or do you want me to address anything else?

OlegZv avatar Mar 05 '25 17:03 OlegZv

Hello all! Is this PR missing anything needed for approval?

OlegZv avatar Mar 12 '25 23:03 OlegZv

Could someone please review and approve? @emdneto @jeremydvoss @owais @pmcollins @sanketmehta28 @srikanthccv @tammy-baylis-swi (@open-telemetry/python-approvers)

OlegZv avatar Mar 31 '25 14:03 OlegZv

@emdneto Thank you for the review. I implemented the changes you mentioned. Tested the resulting library with tox and regenerated the docs locally. The tests passed, and the docs look as before. The only thing left, I think, is the question about the RequestHook type (private vs. not)

OlegZv avatar May 02 '25 15:05 OlegZv

@OlegZv please fix CI

xrmx avatar May 08 '25 10:05 xrmx

@OlegZv please fix CI

Fixed! Sorry for the delay.

OlegZv avatar May 08 '25 15:05 OlegZv