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

document: fix express example #413

Merged
merged 4 commits into from
Apr 7, 2021

Conversation

rauno56
Copy link
Member

@rauno56 rauno56 commented Apr 6, 2021

Which problem is this PR solving?

The express example was erroring and used soon-to-be-deprecated API. I'm bringing that up to date.


Short description of the changes

Mainly just removing the usage of the old plugins API and replacing that with registerInstrumentations. I also added logger configuration because especially for the newcomers it will definitely be helpful to see those messages and know how to configure the logger. Other than that it's functionally the same.


A question for the original express instrumentation developer(@vmarchaud, I believe): Is it expected that if HTTP layer is not instrumented, express instrumentation is a no-op? Should we document that? Error? Somehow make HTTP instrumentation a dependency for express?

If that looks alright, I could work on others as well.

Fixes #376

The function didn't use any async calls so it wasn't required.
* Move `cross-env` to dependencies, since it's used runtime.
* Add diagnostics logging to be more informative
@rauno56 rauno56 requested a review from a team April 6, 2021 09:03
@codecov
Copy link

codecov bot commented Apr 6, 2021

Codecov Report

Merging #413 (57d39f1) into main (a2de775) will not change coverage.
The diff coverage is n/a.

❗ Current head 57d39f1 differs from pull request most recent head 2444d21. Consider uploading reports for the commit 2444d21 to get more accurate results

@@           Coverage Diff           @@
##             main     #413   +/-   ##
=======================================
  Coverage   94.21%   94.21%           
=======================================
  Files          12       12           
  Lines         432      432           
  Branches       48       48           
=======================================
  Hits          407      407           
  Misses         25       25           

@dyladan dyladan added the documentation Improvements or additions to documentation label Apr 6, 2021
@vmarchaud
Copy link
Member

A question for the original express instrumentation developer(@vmarchaud, I believe): Is it expected that if HTTP layer is not instrumented, express instrumentation is a no-op? Should we document that? Error?

I indeed wrote the instrumentation and its expected that without the http instrumentation, the instrumentation does nothing. I don't think this is a problem right now (either in term of documentation or behavior) but maybe i don't see it, why do you think it should be documented ?

[...] Somehow make HTTP instrumentation a dependency for express?

Thats not really possible, instrumentation should not depend on each user, specially because you need to be able to configure them. If the express instrumentation load its http instrumentation itself, the user can't control its config.

@rauno56
Copy link
Member Author

rauno56 commented Apr 7, 2021

[...] why do you think it should be documented ?

Because the alternative - registering express instrumentation (without HTTP inst) and not seeing anything - is worse and will definitely frustrate people who expect at least something to show up in their tracing UI when they enable their first instrumentation. As a very fundamental use-case, it will disproportionally affect people less experienced with OTel, which is something we want to especially avoid as a relatively young effort.

Thats not really possible, instrumentation should not depend on each user, specially because you need to be able to configure them. If the express instrumentation load its http instrumentation itself, the user can't control its config.

The way to do that might be unprecedented or unobvious, but I'm sure we can figure something out! :) OR if this really is the case (for now) it should at least be documented IMHO. Do we have any other takes on that?

I'll write something up regardless, but leave the behaviour as it is for now. Please hold the merge until the commit has been added.

@Flarna
Copy link
Member

Flarna commented Apr 7, 2021

I indeed wrote the instrumentation and its expected that without the http instrumentation, the instrumentation does nothing.

That's not really true. The express instrumentation creates only spans if there is a current active span but there is no check that this span was created by http instrumentation. It will create a child on whatever parent is present.

@rauno56
Copy link
Member Author

rauno56 commented Apr 7, 2021

That's not really true. The express instrumentation creates only spans if there is a current active span but there is no check that this span was created by http instrumentation. It will create a child on whatever parent is present.

True, good point! What could be the other possible expected sources for that parent span? Might there also exist a case where the spans created by express instrumentation are attached to an unexpected parent span if the HTTP instrumentation is not there?

Please hold the merge until the commit has been added.

I'm now done proposing the changes to the docs!

@dyladan dyladan changed the title fix: fix express example document: fix express example Apr 7, 2021
@dyladan dyladan merged commit f9511fd into open-telemetry:main Apr 7, 2021
@rauno56 rauno56 deleted the fix/express-example branch April 7, 2021 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Express example doesn't work as expected
5 participants