Install the Node.js Library
The Node.js Library is distributed as the npm package solarwinds-apm
. Install the package, require it in your application, and automatically get visibility into the frameworks and components used by your application.
Before you start
Verify the following to ensure the library can collect and transmit data:
-
The platform where your APM library will be installed is supported.
-
Your application components are supported by the library.
-
Your firewall configuration permits TCP/HTTPS/TLS outbound connections to
apm.collector.xx-yy.cloud.solarwinds.com
(wherexx-yy
is determined by the URL you use to access SolarWinds Observability SaaS, described in Data centers and endpoint URIs) using port443
. See Firewall or access control requirements.If your firewall or access control requirements do not allow such connections, configure the library to send data through a proxy.
Do not run other APM libraries alongside the SolarWinds Observability Node.js Library. Remove other APM libraries from your Node.js application before using the SolarWinds Observability Node.js Library.
Install the library
The library requires a C++ addon package called @solarwinds-apm/bindings
.
Our C++ addon currently supports Linux only. The library can be installed on other platforms such as OS X but will run in "no-op" mode where it does not emit trace data or metrics.
The C++ addon is compiled into a binary with system and Node.js version dependencies, so the installed library package on one platform cannot just be copied to a different platform. Instead, the library must be installed specifically on each different platform.
Installation steps
The library can be installed via the standard npm
command, for example:
npm install --save 'solarwinds-apm' '@opentelemetry/api@^1.3.0'
Install the library using your package manager, and then follow the configuration guide.
Enable the library
The library requires a service key to connect to your account, and it must be required into your application code.
Service key
The library requires a service key to connect to your account. This is set via the SW_APM_SERVICE_KEY
environment variable or the serviceKey
config file property. When using the environment variable, make sure it is available in the environment where your application is running:
export SW_APM_SERVICE_KEY="api-token-here:your-service-name"
A service key is composed of an API token with write permissions and the name of the service you're installing on. Our onboarding flow provides the full service key, or check the API Tokens page to grab a token and fill the service name yourself.
Load the library
Once installed, the library can be initialized either from the command line or the environment. Depending on the Node version, the --loader solarwinds-apm/loader
(<20.8.0
) or --import solarwinds-apm
(>=20.8.0
) flag should be used.
# <20.8.0
node --loader solarwinds-apm/loader script.js
# >=20.8.0
node --import solarwinds-apm script.js
# <20.8.0
export NODE_OPTIONS="--loader solarwinds-apm/loader"
# >=20.8.0
export NODE_OPTIONS="--import solarwinds-apm"
npm start
It is also still possible to use the -r/--require
flag, but this will only work for CommonJS projects (which is still the default with Node).
Remove the library
Make sure your application entry point file no longer requires solarwinds-apm, and then uninstall it with:
npm uninstall --save solarwinds-apm
Azure App Service
Deploying applications with the SolarWinds Observability Node.js Library to Azure App Service on Linux has been tested using the vscode's Azure App Service extension, the azure CLI client "az", and the local git repository method. No special processing is required, but make sure that you don't change the default which is that the build is done by the deployment engine.
The scripts are not supported under any SolarWinds support program or service. The scripts are provided AS IS without warranty of any kind. SolarWinds further disclaims all warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The risk arising out of the use or performance of the scripts and documentation stays with you. In no event shall SolarWinds or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the scripts or documentation.