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

fix(plugin-ioredis): end span on response from the server and set span status according to response #239

Merged
merged 22 commits into from
Jan 28, 2021

Conversation

blumamir
Copy link
Member

@blumamir blumamir commented Nov 2, 2020

Which problem is this PR solving?

  • fix: end span on response from server, so duration accurately include the server processing and networking time. Currently, the span is ended after sending the command to the server.
  • fix: set span status to error if server response with error. Currently, span status is always set is OK, even if the server replied with an error.

Short description of the changes

patch command resolve and reject functions. Only when the response arrives from the server - close the span (so the duration is accurate), and set status code to error if the server responds with error.

- fix: end span on response from server, so duration accurately include the server processing
    and networking time
- fix: set span status to error if server response with error
- feat: add responseHook to plugin config so user can register hook to add custom attributes to
    span when successful response arrive from server
@blumamir blumamir requested a review from a team November 2, 2020 17:19
@codecov
Copy link

codecov bot commented Nov 2, 2020

Codecov Report

Merging #239 (dcfcd54) into main (234c42f) will increase coverage by 0.02%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #239      +/-   ##
==========================================
+ Coverage   95.41%   95.44%   +0.02%     
==========================================
  Files         115      115              
  Lines        6090     6126      +36     
  Branches      590      597       +7     
==========================================
+ Hits         5811     5847      +36     
  Misses        279      279              
Impacted Files Coverage Δ
.../opentelemetry-plugin-ioredis/test/ioredis.test.ts 94.56% <0.00%> (+0.17%) ⬆️
node/opentelemetry-plugin-ioredis/src/utils.ts 89.36% <0.00%> (+4.74%) ⬆️

@dyladan
Copy link
Member

dyladan commented Nov 2, 2020

  • feat: add responseHook to plugin config so user can register hook to add custom attributes to
    span when successful response arrive from server

I would prefer if this was in a separate PR so it can be tracked in the changelog as a feature

@blumamir blumamir changed the title feat(plugin-ioredis): enhance response handling fix(plugin-ioredis): end span on response from the server and set status to error on reject Nov 3, 2020
@blumamir blumamir changed the title fix(plugin-ioredis): end span on response from the server and set status to error on reject fix(plugin-ioredis): end span on response from the server and set span status according to response Nov 3, 2020
@blumamir
Copy link
Member Author

blumamir commented Nov 3, 2020

I would prefer if this was in a separate PR so it can be tracked in the changelog as a feature

@dyladan @vmarchaud Done.
Will appreciate your review so I can create the next PR soon when this one is merged to master

@blumamir
Copy link
Member Author

blumamir commented Nov 3, 2020

Thanks @vmarchaud
Does this PR need to have a bug label so it shows up in the changelog?
What is the policy of merging PRs when they are approved?

@dyladan
Copy link
Member

dyladan commented Nov 5, 2020

In contrib:

  • 3 reviews required
  • 1 review should be from a maintainer
  • If the PR is opened by a maintainer, only 2 reviews are required
  • No unresolved comments/conversations
  • No changes requested
  • Tests/lint pass

@dyladan dyladan added the bug Something isn't working label Nov 5, 2020
@dyladan
Copy link
Member

dyladan commented Nov 5, 2020

Yes the bug label makes this show up in the changelog.

Copy link
Member

@naseemkullah naseemkullah left a comment

Choose a reason for hiding this comment

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

lgtm

plugins/node/opentelemetry-plugin-ioredis/src/utils.ts Outdated Show resolved Hide resolved
@obecny
Copy link
Member

obecny commented Dec 14, 2020

@blumamir pls fix the lint so I can merge it, thx

@blumamir
Copy link
Member Author

The lint error is not related to my changes:
ESLint couldn't find the config "./node_modules/gts" to extend from. Please check that the name of the config is correct.

When running locally on ioredis package I get no lint errors, but when running on the entire repo, it fails due to @opentelemetry/instrumentation-graphql:

lerna ERR! npm run lint exited 1 in '@opentelemetry/instrumentation-graphql'
lerna ERR! npm run lint stdout:

> @opentelemetry/[email protected] lint /Users/amirblum/repos/opentelemetry-js-contrib/plugins/node/opentelemetry-instrumentation-graphql
> eslint . --ext .ts


/Users/amirblum/repos/opentelemetry-js-contrib/plugins/node/opentelemetry-instrumentation-graphql/src/graphql.ts
   96:23  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  156:48  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  156:53  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  386:16  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  387:19  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  388:44  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  390:60  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  390:65  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  391:58  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  391:63  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

/Users/amirblum/repos/opentelemetry-js-contrib/plugins/node/opentelemetry-instrumentation-graphql/src/types.ts
   66:59  error    Replace `GraphQLInstrumentationConfig` with `⏎··GraphQLInstrumentationConfig⏎`  prettier/prettier
   76:3   warning  Unexpected any. Specify a different type                                        @typescript-eslint/no-explicit-any
   77:3   warning  Unexpected any. Specify a different type                                        @typescript-eslint/no-explicit-any
   78:26  warning  Unexpected any. Specify a different type                                        @typescript-eslint/no-explicit-any
   80:43  warning  Unexpected any. Specify a different type                                        @typescript-eslint/no-explicit-any
   80:48  warning  Unexpected any. Specify a different type                                        @typescript-eslint/no-explicit-any
   81:42  warning  Unexpected any. Specify a different type                                        @typescript-eslint/no-explicit-any
   81:47  warning  Unexpected any. Specify a different type                                        @typescript-eslint/no-explicit-any
   87:15  warning  Unexpected any. Specify a different type                                        @typescript-eslint/no-explicit-any
   88:18  warning  Unexpected any. Specify a different type                                        @typescript-eslint/no-explicit-any
   89:43  warning  Unexpected any. Specify a different type                                        @typescript-eslint/no-explicit-any
   91:59  warning  Unexpected any. Specify a different type                                        @typescript-eslint/no-explicit-any
   91:64  warning  Unexpected any. Specify a different type                                        @typescript-eslint/no-explicit-any
   92:57  warning  Unexpected any. Specify a different type                                        @typescript-eslint/no-explicit-any
   92:62  warning  Unexpected any. Specify a different type                                        @typescript-eslint/no-explicit-any
   98:15  warning  Unexpected any. Specify a different type                                        @typescript-eslint/no-explicit-any
   99:18  warning  Unexpected any. Specify a different type                                        @typescript-eslint/no-explicit-any
  100:43  warning  Unexpected any. Specify a different type                                        @typescript-eslint/no-explicit-any
  102:46  warning  Unexpected any. Specify a different type                                        @typescript-eslint/no-explicit-any
  102:51  warning  Unexpected any. Specify a different type                                        @typescript-eslint/no-explicit-any
  103:44  warning  Unexpected any. Specify a different type                                        @typescript-eslint/no-explicit-any
  103:49  warning  Unexpected any. Specify a different type                                        @typescript-eslint/no-explicit-any
  128:12  warning  Unexpected any. Specify a different type                                        @typescript-eslint/no-explicit-any

/Users/amirblum/repos/opentelemetry-js-contrib/plugins/node/opentelemetry-instrumentation-graphql/src/utils.ts
   54:17  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
   58:10  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
   91:17  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  156:33  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  162:33  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  166:39  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  299:26  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  309:45  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  309:61  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  309:74  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  339:38  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  341:16  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

✖ 45 problems (1 error, 44 warnings)
  1 error and 0 warnings potentially fixable with the `--fix` option.


lerna ERR! npm run lint stderr:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @opentelemetry/[email protected] lint: `eslint . --ext .ts`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @opentelemetry/[email protected] lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

How can I make it pass?

@blumamir
Copy link
Member Author

blumamir commented Dec 14, 2020

The branch passed until I merged master into this branch here

@obecny
Copy link
Member

obecny commented Dec 14, 2020

@blumamir just run npm run lint:fix but make sure you have up to date all npm packages, obviously some small change in lint rules recently and it is failing on white space

@obecny
Copy link
Member

obecny commented Dec 14, 2020

@blumamir weird, I can just suggest to do a full cleanup (when many packages changes, you have old package with lock etc. somethimes npm dosent update packages correctly). The easiest way is to remove all node_modules, then app package-lock.json, and all build folders, if you are on mac I have handy gist here to do it in one command you can just copy and paste in main package.json then run "npm run clean:all" and after this run "npm i"

https://gist.github.com/obecny/d4358fce87a862b6b3f6ba54398ac30e/e37abf6a171f33ae20684cff2ab4e1c3e513493a

@obecny
Copy link
Member

obecny commented Dec 14, 2020

a wait

@obecny
Copy link
Member

obecny commented Dec 14, 2020

seems like it might be the github actions , checking ....

@obecny
Copy link
Member

obecny commented Dec 14, 2020

@blumamir just merged the latest to my PR https://github.com/open-telemetry/opentelemetry-js-contrib/pull/277 and it doesn't fail on lint. Also the modification you have in graphql is not needed. This might be some caching issue , not sure :/ @dyladan any idea if we can "reset" this PR to fresh start without getting cache ?

@vmarchaud
Copy link
Member

@blumamir Could you rebase from master, i believe the previous lint error should be fixed ?

@blumamir
Copy link
Member Author

@blumamir Could you rebase from master, i believe the previous lint error should be fixed ?

@vmarchaud I updated the PR following the recent changes in StatusCode, and change to the test 'should create a child span for lua' which validated the function call response (OK -> StatusCode.UNSET) instead of the redis server response (NOSCRIPT -> StatusCode.ERROR).
But I still get lint errors on graphql.
Running npm run lint on upstream\master fails as well on my setup.
Does it works for you? seems like an issue unrelated to my change.

BTW, I see there is a PR for porting ioredis to the instrumentation API. Is there any point in merging this PR into master? I assume the plugin package will be removed once the instrumentation package will be merged.

@Flarna
Copy link
Member

Flarna commented Jan 19, 2021

BTW, I see there is a PR for porting ioredis to the instrumentation API. Is there any point in merging this PR into master?

In case this PR gets merged first I will update that one for the instrumentation package. I don't know if there is a concrete timeline when to remove the plugin packages.

Regarding the lint error: I think you have to undo your change in graphql. I had a similar issue in the past and it was caused by different versions of installed npm packages lying around on my PC compared to that ones installed fresh in CI. Try to delete all package-lock.json files and node_modules folders and then do a fresh npm install in root folder of the project.

@blumamir
Copy link
Member Author

Regarding the lint error: I think you have to undo your change in graphql. I had a similar issue in the past and it was caused by different versions of installed npm packages lying around on my PC compared to that ones installed fresh in CI. Try to delete all package-lock.json files and node_modules folders and then do a fresh npm install in root folder of the project.

Thanks @Flarna , that fixed the lint error :)
@vmarchaud can this PR be merged?

@vmarchaud
Copy link
Member

In case this PR gets merged first I will update that one for the instrumentation package. I don't know if there is a concrete timeline when to remove the plugin packages.

We didn't discuss this i believe, however i think we aim for all core plugins to be ported (still grpc-js left but PR is open)

@vmarchaud can this PR be merged?

Just need one review from another maintainer /cc @obecny @dyladan

Base automatically changed from master to main January 27, 2021 22:21
Copy link
Member

@obecny obecny left a comment

Choose a reason for hiding this comment

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

lgtm, thx for changes

@obecny
Copy link
Member

obecny commented Jan 28, 2021

@blumamir looks like tests for ioredis is broken, once fixed this can be merged

@blumamir
Copy link
Member Author

@blumamir looks like tests for ioredis is broken, once fixed this can be merged

I'll fix it now, thanks

@blumamir
Copy link
Member Author

@blumamir looks like tests for ioredis is broken, once fixed this can be merged

@obecny
tests are fixed

BTW, I see there is a PR for porting ioredis to the instrumentation API. Is there any point in merging this PR into master?

In case this PR gets merged first I will update that one for the instrumentation package. I don't know if there is a concrete timeline when to remove the plugin packages.

@Flarna if I can assist somehow in merging this fix into the instrumentation PR, please let me know

@obecny
Copy link
Member

obecny commented Jan 28, 2021

will merge this one first. the plugins will still remain for some time until all is moved to instrumentation, then will have to make more changes in core and then they can be deprecated and then finally remove. It will not happen in few days for sure.

@obecny obecny merged commit 80d1049 into open-telemetry:main Jan 28, 2021
@Flarna
Copy link
Member

Flarna commented Jan 28, 2021

@blumamir I will copy over your changes into the instrumentation later today. In case I need some help I will ping you but it doesn't look that complicated.

Flarna added a commit to dynatrace-oss-contrib/opentelemetry-js-contrib that referenced this pull request Jan 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants