-
-
Notifications
You must be signed in to change notification settings - Fork 15
Make README example less pseudo-y #69
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
base: main
Are you sure you want to change the base?
Conversation
The one open question I ran into was, do you also need to hook the |
This is what the node-sdk recommends: // You can also use the shutdown method to gracefully shut down the SDK before process shutdown
// or on some operating system signal.
const process = require("process");
process.on("SIGTERM", () => {
sdk
.shutdown()
.then(
() => console.log("SDK shut down successfully"),
(err) => console.log("Error shutting down SDK", err)
)
.finally(() => process.exit(0));
}); |
Reading through the code, this plugin does NOT automatically close down the SDK on server stop. We should add the best way to do this. I'm guessing in the otel.js file as the example shows. |
Noup it currently does not; you'd like to open a PR for that? We can extend the documentation there as well. The best is to hop into the |
README.md
Outdated
|
||
const app = fastify(); | ||
If `registerOnInitialization=true`, use a loader to load your otel.js before everything else. |
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'd set this up as an alternative; often instrumentation is just imported manually first thing when booting up a service
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.
The reason why the the loader flags are appropriate as the default suggestion is because fastify-cli. Rather than directly launching some entry point with node where you control load order, many fastify apps will just have an app.js that fastify-cli loads. In order to guarantee the otel instruments are the first thing that loads, you must load them in with the loader/reqiuire flag otherwise the fastify-cli might load in a module before the otel instruments can intercept it.
Additionally the otel tutorials and docs recommend the loader flag approach. I found that working through those docs, and then hopping over to this module and seeing two different approaches super confusing.
https://opentelemetry.io/docs/languages/js/getting-started/nodejs/
https://github.com/open-telemetry/opentelemetry-js/blob/main/doc/esm-support.md
(Speaking of loader flags, I need to add the experimental loader note for esm)
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.
Fair enough; I'd just add a note that import
is also an alternative
|
||
Example: | ||
## Example |
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.
all this code could be moved to an example.js
file instead of the readme?
it seems too much here to me (and we can't test it too)
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 agree. Will add in a runnable example in.
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 reduced the scope of the example in the README. I will still set up an external example folder.
b9201a2
to
65defc3
Compare
A few more updates:
Next steps I will set up a runnable example folder or two, and narrow down the README example more. |
Still WIP (see the one question), but I took a stab at improving the README example.
Checklist
npm run test
andnpm run benchmark
and the Code of conduct