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(http-plugin): ensure exceptions are handled #273

Conversation

OlivierAlbertini
Copy link
Member

Which problem is this PR solving?

Ensure exceptions are properly handled.

Short description of the changes

  • refactor(test): remove unnecessary code
  • add tests

Copy link
Member

@markwolff markwolff left a comment

Choose a reason for hiding this comment

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

LGTM. Side question: I think this is out of the scope of this PR but do we also need to handle 'error' and 'aborted' events for this plugin's event listener? I see only 'response' is listened to currently, or am I missing something?

@OlivierAlbertini
Copy link
Member Author

OlivierAlbertini commented Sep 17, 2019

LGTM. Side question: I think this is out of the scope of this PR but do we also need to handle 'error' and 'aborted' events for this plugin's event listener? I see only 'response' is listened to currently, or am I missing something?

we use error as well on resp and req.

Utils.setSpanOnError(span, response);
Also you can see related tests.

aborted is not used because of #225
Perhaps we could discuss about this in the next SIG meeting ? /cc @mayurkale22 (I have no expertise on how we could do it without using events... If someone can refer me to an implementation... I would be curious)

@danielkhan
Copy link
Contributor

I pinged @Flarna to have a look as well

@codecov-io
Copy link

codecov-io commented Sep 17, 2019

Codecov Report

Merging #273 into master will increase coverage by 0.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master     #273      +/-   ##
==========================================
+ Coverage   98.86%   98.87%   +0.01%     
==========================================
  Files          69       70       +1     
  Lines        2732     2856     +124     
  Branches      193      194       +1     
==========================================
+ Hits         2701     2824     +123     
- Misses         31       32       +1
Impacted Files Coverage Δ
...pentelemetry-node-sdk/src/instrumentation/utils.ts 96% <0%> (-4%) ⬇️
...node-sdk/test/instrumentation/PluginLoader.test.ts 100% <0%> (ø) ⬆️
...pe-async-hooks/test/AsyncHooksScopeManager.test.ts 100% <0%> (ø) ⬆️
packages/opentelemetry-node-sdk/src/config.ts 100% <0%> (ø)

@Flarna
Copy link
Member

Flarna commented Sep 18, 2019

I think a try/catch around const request: ClientRequest = original.apply(this, [options, ...args]); is needed to end the span created just before in case the original throws.

Similar const returned = response.end.apply(this, arguments as any); in wrapped response.end.

@OlivierAlbertini
Copy link
Member Author

const request: ClientRequest = original.apply(this, [options, ...args]);

Do you have a use case / exemple ? Right now, I don't see how I could reproduce the behaviour you mention. We check options and tests show that behaviour is respected. base on NodeJS spec, if options is ok, it will fire events. If I missed something let me know.

Thanks in advance.

@Flarna
Copy link
Member

Flarna commented Sep 18, 2019

Do you have a use case / exemple ?

http.request({protocol: "telnet"}).

The plugin does not verify all data finally used by node http, it just checks the part needed by the plugin and the type of the object.
And I don't think the plugin should add more validation here as this would just mean we duplicate code from node and there will be always some gap left.

@OlivierAlbertini
Copy link
Member Author

Do you have a use case / exemple ?

http.request({protocol: "telnet"}).

The plugin does not verify all data finally used by node http, it just checks the part needed by the plugin and the type of the object.
And I don't think the plugin should add more validation here as this would just mean we duplicate code from node and there will be always some gap left.

If you have other use cases please let me know.

@OlivierAlbertini OlivierAlbertini force-pushed the feature/exceptions-http branch 2 times, most recently from d574612 to 56624e3 Compare September 20, 2019 17:37
refactor(test): remove unnecessary code
add tests
closes open-telemetry#222

Signed-off-by: Olivier Albertini <olivier.albertini@montreal.ca>
Signed-off-by: Olivier Albertini <olivier.albertini@montreal.ca>
Signed-off-by: Olivier Albertini <olivier.albertini@montreal.ca>
@OlivierAlbertini OlivierAlbertini merged commit ce2bc95 into open-telemetry:master Sep 20, 2019
@OlivierAlbertini OlivierAlbertini deleted the feature/exceptions-http branch September 20, 2019 18:13
pichlermarc pushed a commit to dynatrace-oss-contrib/opentelemetry-js that referenced this pull request Dec 15, 2023
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.

Ensure exceptions are properly handled and propagated
8 participants