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

feat(instrumentation-ioredis): add response hook for custom attributes #343

Merged
merged 9 commits into from
Feb 25, 2021

Conversation

blumamir
Copy link
Member

@blumamir blumamir commented Feb 10, 2021

This feature was originally sent in this PR, and I was asked to split it into a different PR. Now that the original PR is merged, I am able to send it once again.

Which problem is this PR solving?

  • feat: add responseHook to instrumentation library config so user can register hook to add custom attributes to span when successful response arrives from the server.
    This is similar to the hooks functions in instrumentation-http, and to the plugins in this repo (which I maintain).
    Possible usage: add a custom attribute to span which tells if the command is a key HIT or key MISS.

Short description of the changes

  • added the optional function to the IORedisInstrumentationConfig, and call the function when the command is successfully resolved.
  • Added unit tests for the new feature which test both success and failure.

@blumamir blumamir requested a review from a team February 10, 2021 15:23
@codecov
Copy link

codecov bot commented Feb 10, 2021

Codecov Report

Merging #343 (28c1aea) into main (93b4bcc) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #343   +/-   ##
=======================================
  Coverage   93.88%   93.88%           
=======================================
  Files          12       12           
  Lines         409      409           
  Branches       45       45           
=======================================
  Hits          384      384           
  Misses         25       25           

}
safeExecuteInTheMiddle(
() => config?.responseHook?.(span, cmd.name, cmd.args, result),
() => {},
Copy link
Member

Choose a reason for hiding this comment

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

Sorry i didn't catch this before but i think it could be better if we could log an error so the user know that its hook is failing

Copy link
Member Author

Choose a reason for hiding this comment

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

makes sense. added logging on error :)

@vmarchaud vmarchaud requested review from obecny and dyladan February 20, 2021 09:10
@obecny obecny added the enhancement New feature or request label Feb 25, 2021
@obecny obecny merged commit a30b8aa into open-telemetry:main Feb 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants