You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 31, 2024. It is now read-only.
description: Instrument your NestJS application using Aspecto
3
+
---
4
+
5
+
# NestJS
6
+
7
+
## Auto Instrument
8
+
9
+
Nest applications are commonly started in one of 2 ways:
10
+
11
+
* Nest cli (`nest start`)
12
+
* Directly with the `node` executable (for example: `node dist/main`)
13
+
14
+
It is recommended to use ["Auto Instrument" technique](./#auto-instrument) with node's "preload" command line option, to ensure instrumentation is initialized before Nest framework.
15
+
16
+
### Using Nest Cli
17
+
18
+
To instrument your Nest application when started with Nest cli, add the ["-e" ("--exec")](https://docs.nestjs.com/cli/usages#nest-start) option to `nest start` like this:
This should be added everywhere `nest start` is invoked (`package.json`, scripts, terminal, etc).
25
+
26
+
### Using Node Executable
27
+
28
+
To instrument you Nest application when started with node executable, add the ["-r" ("--require")](https://nodejs.org/api/cli.html#-r---require-module) to `node` execution like this:
When instrumenting an application with "Auto Instrument", configuration is supplied via environment variables or `aspecto.json` file. 
37
+
38
+
{% hint style="info" %}
39
+
`ASPECTO_AUTH`**must be provided.**[Other configuration options](customize-defaults/advanced.md) are optional.
40
+
{% endhint %}
41
+
42
+
### .env File
43
+
44
+
This part is relevant if you are using `@nestjs/config` package to load environment variables from `.env` file (or if you are loading the file yourself).
45
+
46
+
If you store Aspecto's SDK config options in `.env` file, it needs to be preloaded before `@aspecto/opentelemetry`, e.g.
0 commit comments