-
Notifications
You must be signed in to change notification settings - Fork 533
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
chore: moves express examples into its package to establish pattern #939
chore: moves express examples into its package to establish pattern #939
Conversation
plugins/node/opentelemetry-instrumentation-express/examples/package.json
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I support moving examples under respective packages and happy to see someone is getting the ball rolling.
How do you think converting the examples to Typescript will affect the benefit non-TS users will get from them?
A previous discussion on this: #552
plugins/node/opentelemetry-instrumentation-express/examples/README.md
Outdated
Show resolved
Hide resolved
plugins/node/opentelemetry-instrumentation-express/examples/src/tracer.ts
Outdated
Show resolved
Hide resolved
I think the benefit of having the examples type-checked and therefore easier to notice when they are outdated will outweigh the disadvantage of presenting typescript to a non-typescript user. |
A bit of topic regarding this specific PR. But what about adding an |
I wonder how hard it would be to do that in a way where the example isn't unnecessarily complex for new users who are just trying to figure out how to use the instrumentation? |
Shouldn't the tests already verify that anyway ? |
As far as I know the samples are not executed at all in CI. The tests of e.g. express instrumentation verify that the instrumentation works but not that the example works. |
I added instructions for migrating examples in the examples/README file. I also created an example of what an issue would look like for a given package that needs converted. See the example issue for koa instrumentation here. |
I believe this PR is ready to go now 👍 |
Sorry, I merged another PR that caused conflicts here. |
Codecov Report
@@ Coverage Diff @@
## main #939 +/- ##
==========================================
+ Coverage 95.91% 96.50% +0.58%
==========================================
Files 13 19 +6
Lines 856 1086 +230
Branches 178 230 +52
==========================================
+ Hits 821 1048 +227
- Misses 35 38 +3
|
lint also fails on the markdown lint check |
plugins/node/opentelemetry-instrumentation-express/examples/package.json
Outdated
Show resolved
Hide resolved
plugins/node/opentelemetry-instrumentation-express/examples/package.json
Outdated
Show resolved
Hide resolved
…ckage.json Co-authored-by: Gerhard Stöbich <[email protected]>
…ckage.json Co-authored-by: Gerhard Stöbich <[email protected]>
Ok, lint should be resolved and latest changes from main merged. |
Why eslint-ignore the examples? |
plugins/node/opentelemetry-instrumentation-express/examples/tsconfig.json
Outdated
Show resolved
Hide resolved
plugins/node/opentelemetry-instrumentation-express/examples/src/tracer.ts
Outdated
Show resolved
Hide resolved
plugins/node/opentelemetry-instrumentation-express/examples/package.json
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks @andyfleming for doing this
The CI currently fails due to unrelated issues. After they are fixed, I suggest taking a quick look to verify that the "compile:examples" is run as expected in CI before merging.
friendly ping @andyfleming if you find the time to wrap this one :) |
I'm having trouble reproducing the CI error locally. Here's the CI error. It doesn't look like an error directly in the example files. Any hunch on what's going wrong?
|
most likely caused by a mixmax of installed |
Will open-telemetry/opentelemetry-js#2892 help with that issue? Alternatively, is there a recommended workaround? I imagine I could switch to an older version of the API that matches the one getting installed in CI. |
Yes I think so. |
Once we have a release I think the CI will be much easier. |
@andyfleming thank you for your patience. Release PR is prepared and should merge/release today I hope |
Thanks for following up on this @rauno56 ! 🙂 |
Sorry for this taking so long! Thanks and congrats for your first contribution! |
Problem this solves
Examples get out of date quickly since they are at the top-level of this repository. There's no validation that they work correctly with the latest version of instrumentation packages.
Changes in this PR
Testing approach
For validation of the instrumentation example code, I propose we leverage TypeScript compilation. It's not as exhaustive as some sort of functional tests, but I think that would be too costly at this point.
I've implemented that via the
npm run --if-present compile:examples
command in CI.We could later establish a pattern for CI to check for a "test:examples" script in the package.json of each instrumentation package to run (if present) in addition to the basic TypeScript compilation.
Additional Notes
It was discussed that we could keep the top-level examples directory for 2 reasons:
Checklist
npm run test-all-versions
for the edited package(s) on the latest commit if applicable.