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-http): correct handling of WHATWG urls #589

Merged

Conversation

Flarna
Copy link
Member

@Flarna Flarna commented Dec 5, 2019

Which problem is this PR solving?

fixes #583

Short description of the changes

Add parsing and conversion of WHATWG URL objects for client http
requests to ensure semantics of HTTP request are not modifed and
tracestate header is correctly added.

@codecov-io
Copy link

codecov-io commented Dec 5, 2019

Codecov Report

Merging #589 into master will increase coverage by 1.94%.
The diff coverage is 97.26%.

@@            Coverage Diff             @@
##           master     #589      +/-   ##
==========================================
+ Coverage   89.93%   91.88%   +1.94%     
==========================================
  Files         168      169       +1     
  Lines        8230     8215      -15     
  Branches      739      729      -10     
==========================================
+ Hits         7402     7548     +146     
+ Misses        828      667     -161
Impacted Files Coverage Δ
packages/opentelemetry-plugin-http/src/http.ts 96.8% <100%> (-0.52%) ⬇️
...pentelemetry-plugin-http/test/utils/httpRequest.ts 95% <100%> (+4.09%) ⬆️
...lemetry-plugin-http/test/functionals/utils.test.ts 99.35% <100%> (ø) ⬆️
...y-plugin-http/test/functionals/http-enable.test.ts 96.1% <100%> (+0.01%) ⬆️
...-plugin-http/test/integrations/http-enable.test.ts 94.16% <100%> (+1.23%) ⬆️
packages/opentelemetry-plugin-http/src/utils.ts 98.43% <90.47%> (-1.57%) ⬇️
...telemetry-node/src/instrumentation/PluginLoader.ts 92.72% <0%> (ø) ⬆️
packages/opentelemetry-node/src/NodeTracer.ts 100% <0%> (ø) ⬆️
...es/opentelemetry-node/src/instrumentation/utils.ts 90.47% <0%> (-9.53%) ⬇️
.../opentelemetry-plugin-redis/test/assertionUtils.ts 95.83% <0%> (-4.17%) ⬇️
... and 60 more

Add parsing and conversion of WHATWG URL objects for client http
requests to ensure semantics of HTTP request are not modifed and
tracestate header is correctly added.
Copy link
Member

@OlivierAlbertini OlivierAlbertini left a comment

Choose a reason for hiding this comment

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

Good work! Nice addition.

@OlivierAlbertini
Copy link
Member

Feel free to do #590 otherwise I will do it.

@OlivierAlbertini OlivierAlbertini added the bug Something isn't working label Dec 5, 2019
@OlivierAlbertini OlivierAlbertini self-assigned this Dec 5, 2019
@Flarna
Copy link
Member Author

Flarna commented Dec 5, 2019

Do you mean as part of this PR or as followup?

@OlivierAlbertini
Copy link
Member

Do you mean as part of this PR or as followup?

as followup

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, I added few comments, thx

packages/opentelemetry-plugin-http/src/utils.ts Outdated Show resolved Hide resolved
packages/opentelemetry-plugin-http/src/utils.ts Outdated Show resolved Hide resolved
Copy link
Member

@dyladan dyladan left a comment

Choose a reason for hiding this comment

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

LGTM

@dyladan
Copy link
Member

dyladan commented Dec 5, 2019

@Flarna you just need to lerna run fix to fix the linting issues.

@mayurkale22 I wonder if there would be any value to adding lerna run check as a pre-commit hook using husky?

@mayurkale22
Copy link
Member

@mayurkale22 I wonder if there would be any value to adding lerna run check as a pre-commit hook using husky?

It is possible to do that, but lerna run check takes around 20-30 secs to run. Also, no need to run check on all the packages every time, usually we touch 1-2 packages in the PR. WDYT?

@dyladan
Copy link
Member

dyladan commented Dec 5, 2019

@mayurkale22 easy to fix :)

# only check packages changed in the PR
lerna run check --parallel --since master --exclude-dependents

# only check packages changed since last commit
lerna run check --parallel --since HEAD --exclude-dependents

@Flarna
Copy link
Member Author

Flarna commented Dec 5, 2019

I was assuming that yarn run check only runs prettier as I reported only formatting stuff. I think the tslint rules should be stricter.
Looking into the code it seems they were stricter in the past as I can use any now without a tslint telling me that I should not (see https://github.com/open-telemetry/opentelemetry-js/pull/589/files#diff-033023ec74fe6fbd45196f184ba9aa10R47)

@Flarna
Copy link
Member Author

Flarna commented Dec 5, 2019

I wonder if there would be any value to adding lerna run check as a pre-commit hook using husky?

Honestly speaking I would prefer to remove husky hooks and replace such checks by a CI/build task triggered on demand (e.g. like in node repo). During development I tent to do a log commits locally. At this time I think not that much about wording as I squash anyway before I create a the PR and go for a good wording. I know I can use --no-verify to bypass but it's cumbersome.

Usually the tslint plugin in VsCode or something similar gives faster and better feedback.

@dyladan
Copy link
Member

dyladan commented Dec 5, 2019

Usually the tslint plugin in VsCode or something similar gives faster and better feedback.

This is my experience as well. For some reason though I haven't been able go get this project to work correctly with the vscode tslint plugin. I suspect it's either because of the lerna monorepo pattern or the fact that we're actually using gts which is the google specific typescript style checker.

@Flarna
Copy link
Member Author

Flarna commented Dec 5, 2019

It works fine for me, at least if I open only a package. But it seems with current rule set it's difficult to get lint to complain; adding e.g. no-any immediately results in complains.

@dyladan
Copy link
Member

dyladan commented Dec 5, 2019

I think the gts tool applies rules on top of the configured tslint configuration, so the tslint editor integration doesn't understand the gts specific rules.

@mayurkale22 mayurkale22 added Merge:LGTM This PR is ready to be merged by a Maintainer (has enough valid approvals, successful build, etc.) and removed The CircleCI build failed labels Dec 5, 2019
@mayurkale22 mayurkale22 merged commit 811d7a6 into open-telemetry:master Dec 6, 2019
@Flarna Flarna deleted the http-url-tagging branch December 6, 2019 18:18
pichlermarc pushed a commit to dynatrace-oss-contrib/opentelemetry-js that referenced this pull request Dec 15, 2023
…tions (open-telemetry#589)

* fix(hapi-instrumentation): close spans on errors in instrumented functions

* refactor(hapi-instrumentation): removed uneeded assignment

* refactor(hapi-instrumentation): simplified the use of context.with

* refactor(hapi-instrumentation): changed context with  to avoid closure

* style(hapi-instrumentation): lint

Co-authored-by: Daniel Dyla <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Merge:LGTM This PR is ready to be merged by a Maintainer (has enough valid approvals, successful build, etc.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[http-plugin] Missing traceparent header if WHATWG URL is used
6 participants