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

docs: improve docs around bundlers/transpilers, methods of starting the agent #2837

Merged
merged 26 commits into from Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ab89fce
ensure 'npm run test:babel' fails if not using 'elastic-apm-node/start'
trentm Jul 8, 2022
d441fae
Merge branch 'main' into trentm/docs-bundlers-ts-etc
trentm Jul 8, 2022
e7a3ee7
update supported tech doc page: latest node release schedule image; a…
trentm Jul 8, 2022
9f741a5
Add "exports" so pure ESM can `import 'elastic-apm-node/start'` without.
trentm Jul 8, 2022
2b0f892
a start at improved 'Starting the agent' docs; I still have to write …
trentm Jul 8, 2022
412e404
a section on Bundlers gotchas, incl 'externals' config info for webpa…
trentm Jul 20, 2022
9023c1e
esbuild externals usage docs and example
trentm Jul 20, 2022
b1ac9a1
more tweaks
trentm Jul 20, 2022
bb4587a
tweaks, not sure about 'exports' addition for this PR
trentm Jul 21, 2022
ad0cf5c
drop the "exports", it can be problematic
trentm Jul 21, 2022
87b2157
fix 'make check'
trentm Jul 21, 2022
de96baf
replace es-modules.html page with a new 'Get started with TypeScript'…
trentm Jul 26, 2022
ebbdbd4
update ESM section
trentm Jul 26, 2022
e49f497
tweak
trentm Jul 26, 2022
855df00
tweaks and asciidoc syntax fixes
trentm Jul 26, 2022
78d8fde
grammar
trentm Jul 28, 2022
1a371c7
consistently code-format `node`
trentm Jul 28, 2022
d67d660
capitalization
trentm Jul 28, 2022
60bb3a7
capitalization
trentm Jul 28, 2022
4f12d50
emdash FTW
trentm Jul 28, 2022
5a7360e
caps
trentm Jul 28, 2022
515709d
phrasing
trentm Jul 28, 2022
c9fb5c3
improvements mostly as Brandon suggested
trentm Jul 29, 2022
e76ab76
I put my thang down, flip it and reverse it
trentm Jul 29, 2022
d410b09
.start() consistency
trentm Jul 29, 2022
0e305c1
s/function/method/ for consistency
trentm Jul 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintrc.json
Expand Up @@ -14,6 +14,8 @@
"/.nyc_output",
"/build",
"node_modules",
"/examples/esbuild/dist",
"/examples/typescript/dist",
"/lib/opentelemetry-bridge/opentelemetry-core-mini",
"/test/babel/out.js",
"/test/lambda/fixtures/esbuild-bundled-handler/hello.js",
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -13,3 +13,4 @@
node_modules
/test/benchmarks/.tmp
/tmp
/examples/*/dist
26 changes: 3 additions & 23 deletions docs/agent-api.asciidoc
Expand Up @@ -7,22 +7,7 @@ endif::[]

=== `Agent` API

NOTE: This is the API documentation for the Elastic APM Node.js Agent.
For getting started,
we recommend that you take a look at our framework specific documentation for either <<express,Express>>,
<<hapi,hapi>>,
<<koa,Koa>>,
<<restify,Restify>>,
<<fastify,Fastify>>,
or <<custom-stack,custom frameworks>>.

The Elastic APM agent for Node.js is a singleton.
You get the agent instance by either requiring `elastic-apm-node` or `elastic-apm-node/start`.
For details on the two approaches,
see the <<advanced-setup,Setup and Configuration>> guide.

The agent is also returned by the `start()` function,
which allows you to require and start the agent on the same line:
The Elastic APM Node.js agent is a singleton. You get the agent instance by requiring either `elastic-apm-node` or `elastic-apm-node/start`. The agent is also returned by the <<apm-start,`.start()`>> method, which allows you to require and start the agent on the same line:

[source,js]
----
Expand All @@ -33,20 +18,15 @@ If you need to access the `Agent` in any part of your codebase,
you can simply require `elastic-apm-node` to access the already started singleton.
You therefore don't need to manage or pass around the started `Agent` yourself.


[[apm-start]]
==== `apm.start([options])`

Starts the Elastic APM agent for Node.js and returns itself.

[IMPORTANT]
====
Put the call to this function at the very top of your main app file - before requiring any other modules.

If you are using Babel calling this function will not have the desired effect.
See the <<es-modules,Babel / ES Modules support documentation>> for details.

If you are using Typescript the import statement may be removed if it is not used.
It is recommended to use `-r elastic-apm-node/start` when starting the app to avoid this.
For the APM agent to automatically instrument Node.js modules, it must be started before those modules are loaded. See <<starting-the-agent>> for details and possible surprises with compilers/transpilers/bundlers.
====

See the <<configuration,Configuration documentation>> for available options.
Expand Down
1 change: 0 additions & 1 deletion docs/configuration.asciidoc
Expand Up @@ -33,7 +33,6 @@ will be normalized to the allowed characters. If the name cannot be inferred
from package.json, then a fallback value of "unknown-nodejs-service" is used.


[float]
[[service-node-name]]
trentm marked this conversation as resolved.
Show resolved Hide resolved
==== `serviceNodeName`

Expand Down
185 changes: 1 addition & 184 deletions docs/images/node_release_schedule.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion docs/redirects.asciidoc
Expand Up @@ -41,4 +41,12 @@ This endpoint has moved. Please see <<transaction-add-labels>>.
[role="exclude",id="get-started"]
Copy link
Contributor

Choose a reason for hiding this comment

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

TIL: we have a deleted pages page.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah! They're perfect for this use case.

=== Get started

This page has moved. Please see <<set-up>>.
This page has moved. Please see <<set-up>>.

[role="exclude",id="es-modules"]
=== ES Modules support

This page has moved.

- For details on ES Modules (ESM) support, see <<compatibility-esm>>.
- For information on using the APM agent with TypeScript, see <<typescript>>.