Skip to content

Commit 28f42b7

Browse files
authored
docs: documentation restructure (#1428) (#1443)
1 parent 2370e2e commit 28f42b7

21 files changed

+453
-777
lines changed

docs/agent-api.asciidoc

+6-1
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,11 @@ apm.clearPatches(['timers'])
789789

790790
[small]#Added in: v2.17.0#
791791

792-
Produces an object containing `trace.id` and either `transaction.id` or `span.id` when a current transaction or span is available.
792+
// This content is reused in log-correlation.asciidoc
793+
// Ensure any updates here also make sense there
794+
// tag::currentTraceIds[]
795+
796+
`apm.currentTraceIds` produces an object containing `trace.id` and either `transaction.id` or `span.id` when a current transaction or span is available.
793797
When no transaction or span is available it will return an empty object.
794798
This enables log correlation to APM traces with structured loggers.
795799

@@ -817,3 +821,4 @@ This enables log correlation to APM traces with text-only loggers.
817821
// or ...
818822
"trace.id=abc123 span.id=abc123"
819823
----
824+
// end::currentTraceIds[]

docs/configuration.asciidoc

+4-3
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ The environment name is automatically logged along with all errors and transacti
105105
If you want to overwrite this,
106106
use this option.
107107

108-
Environments allow you to easily filter data on a global level in the APM UI.
108+
Environments allow you to easily filter data on a global level in the APM app.
109109
It's important to be consistent when naming environments across agents.
110-
See {kibana-ref}/filters.html#environment-selector[environment selector] in the Kibana UI for more information.
110+
See {kibana-ref}/filters.html#environment-selector[environment selector] in the APM app for more information.
111111

112-
NOTE: This feature is fully supported in the APM UI in Kibana versions >= 7.2.
112+
NOTE: This feature is fully supported in the APM app in Kibana versions >= 7.2.
113113
You must use the query bar to filter for a specific environment in versions prior to 7.2.
114114

115115
[[instrument]]
@@ -134,6 +134,7 @@ Activate APM Agent Configuration via Kibana.
134134
If set to `true`, the client will poll the APM Server regularly for new agent configuration.
135135

136136
NOTE: This feature requires APM Server v7.3 or later and that the APM Server is configured with `kibana.enabled: true`.
137+
More information is available in {kibana-ref}/agent-configuration.html[APM Agent configuration].
137138

138139
[[async-hooks]]
139140
==== `asyncHooks`

docs/custom-spans.asciidoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ NOTE: For the best reading experience,
55
please view this documentation at https://www.elastic.co/guide/en/apm/agent/nodejs/current/custom-spans.html[elastic.co]
66
endif::[]
77

8-
== Custom Spans
8+
=== Custom spans
99

1010
This is an example of how to use custom spans.
1111
For general information about the Elastic APM Node.js Span API,

docs/custom-stack.asciidoc

+27-116
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,24 @@
1+
:framework: custom Node.js
2+
13
[[custom-stack]]
24

35
ifdef::env-github[]
46
NOTE: For the best reading experience,
57
please view this documentation at https://www.elastic.co/guide/en/apm/agent/nodejs/current/custom-stack.html[elastic.co]
68
endif::[]
79

8-
== Get started with a custom Node.js stack
10+
=== Get started with a custom Node.js stack
911

10-
Getting Elastic APM set up for your Node.js app is easy,
11-
and there are various ways you can tweak it to fit your needs.
12+
include::./shared-set-up.asciidoc[tag=introduction]
1213

13-
If you are using either Express, hapi, Koa, Restify, Fastify, or AWS Lambda
14+
If you are using Express, hapi, Koa, Restify, Fastify, or AWS Lambda,
1415
we recommend that you read these articles instead:
1516

16-
* <<express,Get started with Express>>
17-
* <<hapi,Get started with hapi>>
18-
* <<koa,Get started with Koa>>
19-
* <<restify,Get started with Restify>>
20-
* <<fastify,Get started with Fastify>>
21-
* <<lambda,Get started with Lambda>>
22-
23-
For a custom Node.js app, follow the guide below to get started.
24-
For more advanced topics, check out the <<api,API Reference>>.
17+
include::set-up.asciidoc[tag=web-frameworks-list]
2518

2619
[float]
2720
[[custom-stack-installation]]
28-
=== Installation
21+
==== Installation
2922

3023
Add the `elastic-apm-node` module as a dependency to your application:
3124

@@ -36,7 +29,7 @@ npm install elastic-apm-node --save
3629

3730
[float]
3831
[[custom-stack-initialization]]
39-
=== Initialization
32+
==== Initialization
4033

4134
It's important that the agent is started before you require *any* other modules in your Node.js application - i.e. before `http` and before your router etc.
4235

@@ -64,59 +57,26 @@ The agent will now monitor the performance of your application and record any un
6457

6558
[float]
6659
[[custom-stack-advanced-configuration]]
67-
==== Advanced configuration
68-
69-
In the above example we initialize the agent by calling the <<apm-start,`start()`>> function.
70-
This function takes an optional options object used to configure the agent.
71-
Any option not supplied via the options object can instead be configured using environment variables.
72-
So if you prefer, you can set the same configuration options using environment variables:
73-
74-
[source,bash]
75-
----
76-
ELASTIC_APM_SERVICE_NAME=<service name>
77-
ELASTIC_APM_SECRET_TOKEN=<token>
78-
ELASTIC_APM_SERVER_URL=<server url>
79-
----
80-
81-
And then just start the agent like so:
82-
83-
[source,js]
84-
----
85-
// Start the agent before any thing else in your app
86-
var apm = require('elastic-apm-node').start()
87-
----
60+
===== Advanced configuration
8861

89-
See all possible ways to configure the agent <<configuring-the-agent,in the API documentation>>.
62+
include::./shared-set-up.asciidoc[tag=advanced-configuration]
9063

9164
[float]
9265
[[custom-stack-full-documentation]]
93-
==== Full documentation
66+
===== Full documentation
9467

9568
* <<advanced-setup,Setup and Configuration>>
9669
* <<api,API Reference>>
9770

9871
[float]
9972
[[custom-stack-performance-monitoring]]
100-
=== Performance monitoring
73+
==== Performance monitoring
10174

102-
Elastic APM automatically measures the performance of your application.
103-
It records spans for database queries,
104-
external HTTP requests,
105-
and other slow operations that happen during requests to your app.
106-
107-
By default, the agent will instrument <<supported-technologies,the most common modules>>.
108-
To instrument other events,
109-
you can use custom spans.
110-
For information about custom spans,
111-
see the <<custom-spans,Custom Spans section>>.
112-
113-
Spans are grouped in transactions - by default one for each incoming HTTP request.
114-
But it's possible to create custom transactions not associated with an HTTP request.
115-
See the <<custom-transactions,Custom Transactions section>> for details.
75+
include::./shared-set-up.asciidoc[tag=performance-monitoring]
11676

11777
[float]
11878
[[custom-stack-route-naming]]
119-
==== Route naming
79+
===== Route naming
12080

12181
The Node.js agent tracks incoming HTTP requests to your application in what are called "transactions".
12282
All transactions with the same name are grouped together automatically.
@@ -169,46 +129,19 @@ http.createServer(function (req, res) {
169129

170130
[float]
171131
[[custom-stack-unknown-routes]]
172-
==== Unknown routes
132+
===== Unknown routes
173133

174-
When viewing the performance metrics of your application in Elastic APM,
175-
you might see some transactions named "unknown route".
176-
This indicates that the Elastic APM Node.js agent detected an incoming HTTP request to your application,
177-
but didn't know what to name it.
178-
179-
This might simply be 404 requests,
180-
which by definition don't match any route,
181-
or it might be a symptom that the agent wasn't installed correctly.
182-
Make sure we either support your router or that you <<custom-stack-route-naming,manually name your routes>>.
183-
If you still can't get any meaningful metrics to show up,
184-
please follow the <<troubleshooting,Troubleshooting Guide>>.
134+
include::./shared-set-up.asciidoc[tag=unknown-roots]
185135

186136
[float]
187137
[[custom-stack-error-logging]]
188-
=== Error logging
138+
==== Error logging
189139

190-
By default the Node.js agent will watch for uncaught exceptions and send them to Elastic APM automatically.
191-
But in most cases errors are not thrown but returned via a callback,
192-
caught by a promise,
193-
or simply manually created.
194-
Those errors will not automatically be sent to Elastic APM.
195-
To manually send an error to Elastic APM,
196-
simply call `apm.captureError()` with the error:
197-
198-
[source,js]
199-
----
200-
var err = new Error('Ups, something broke!')
201-
202-
apm.captureError(err)
203-
----
204-
205-
For advanced logging of errors,
206-
including adding extra metadata to the error,
207-
see <<apm-capture-error,the API documentation>>.
140+
include::./shared-set-up.asciidoc[tag=error-logging]
208141

209142
[float]
210143
[[custom-stack-middleware-error-handler]]
211-
==== Middleware error handler
144+
===== Middleware error handler
212145

213146
If you use the https://www.npmjs.com/package/connect[connect] module and an error is either thrown synchronously inside one of the middleware functions or is passed as the first argument to the middleware `next()` function,
214147
it will be passed to the https://www.npmjs.com/package/connect#error-middleware[Connect error handler].
@@ -240,46 +173,24 @@ app.use(function (err, req, res, next) {
240173

241174
[float]
242175
[[custom-stack-filter-sensitive-information]]
243-
=== Filter sensitive information
244-
245-
By default, the Node.js agent will filter common sensitive information before sending errors and metrics to the Elastic APM server.
176+
==== Filter sensitive information
246177

247-
It's possible for you to tweak these defaults or remove any information you don't want to send to Elastic APM:
248-
249-
* By default the Node.js agent will not log the body of HTTP requests.
250-
To enable this,
251-
use the <<capture-body,`captureBody`>> config option
252-
* By default the Node.js agent will filter certain HTTP headers known to contain sensitive information.
253-
To disable this,
254-
use the <<filter-http-headers,`filterHttpHeaders`>> config option
255-
* To apply custom filters,
256-
use one of the <<apm-add-filter,filtering>> functions
178+
include::./shared-set-up.asciidoc[tag=filter-sensitive-info]
257179

258180
[float]
259181
[[custom-stack-add-your-own-data]]
260-
=== Add your own data
261-
262-
The Node.js agent will keep track of the active HTTP request and will link it to errors and recorded transaction metrics when they are sent to the Elastic APM server.
263-
This allows you to see details about which request resulted in a particular error or which requests cause a certain HTTP endpoint to be slow.
264-
265-
But in many cases,
266-
information about the HTTP request itself isn't enough.
267-
To add even more metadata to errors and transactions,
268-
use one of the functions below:
182+
==== Add your own data
269183

270-
* <<apm-set-user-context,`apm.setUserContext()`>> - Call this to enrich collected performance data and errors with information about the user/client
271-
* <<apm-set-custom-context,`apm.setCustomContext()`>> - Call this to enrich collected performance data and errors with any information that you think will help you debug performance issues and errors (this data is only stored, but not indexed in Elasticsearch)
272-
* <<apm-set-label,`apm.setLabel()`>> - Call this to enrich collected performance data and errors with simple key/value strings that you think will help you debug performance issues and errors (labels are indexed in Elasticsearch)
184+
include::./shared-set-up.asciidoc[tag=add-your-own-data]
273185

274186
[float]
275187
[[custom-stack-compatibility]]
276-
=== Compatibility
188+
==== Compatibility
277189

278-
See the <<supported-technologies,Supported technologies section>> for details.
190+
include::./shared-set-up.asciidoc[tag=compatibility-link]
279191

280192
[float]
281193
[[custom-stack-troubleshooting]]
282-
=== Troubleshooting
194+
==== Troubleshooting
283195

284-
If you can't get the Node.js agent to work as expected,
285-
please follow the <<troubleshooting,Troubleshooting Guide>>.
196+
include::./shared-set-up.asciidoc[tag=troubleshooting-link]

docs/custom-transactions.asciidoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ NOTE: For the best reading experience,
55
please view this documentation at https://www.elastic.co/guide/en/apm/agent/nodejs/current/custom-transactions.html[elastic.co]
66
endif::[]
77

8-
== Custom Transactions
8+
=== Custom transactions
99

1010
This is an example of how to use custom transactions.
1111
For general information about the Elastic APM Node.js Transaction API,

0 commit comments

Comments
 (0)