Naar hoofdinhoud gaan
In dit hoofdstuk leggen we uit hoe u AppSignal configureert, wat u in het Node.js-pakket kunt configureren en wat de minimaal benodigde configuratie is.

Minimaal vereiste configuratie

De minimaal vereiste configuratie die AppSignal voor Node.js nodig heeft, bestaat uit de volgende items. Als deze niet aanwezig zijn, stuurt AppSignal geen gegevens naar AppSignal.com.
  • Een geldige Push API-sleutel
  • Een applicatienaam
  • Een applicatieomgeving (development/production/test door NODE_ENV in te stellen)
  • De instelling active: true
De integratie ondersteunt het laden van zijn configuratie via opties die aan de Appsignal-constructor worden doorgegeven. We raden aan een appsignal.cjs-bestand te maken om AppSignal te requiren en te initialiseren.
// appsignal.cjs
const { Appsignal } = require("@appsignal/nodejs");

new Appsignal({
  active: true,
  name: "<YOUR APPLICATION NAME>",
  pushApiKey: "<YOUR API KEY>",
});
U kunt de agent ook configureren via systeemomgevingsvariabelen. AppSignal wordt automatisch actief als de omgevingsvariabele APPSIGNAL_PUSH_API_KEY is ingesteld.
export APPSIGNAL_PUSH_API_KEY="<YOUR API KEY>"
export APPSIGNAL_APP_NAME="<YOUR APPLICATION NAME>"
export APPSIGNAL_APP_ENV="production"

Configuratie-opties

Lees over alle configuratie-opties op de opties-pagina.

Applicatieomgevingen

Een applicatie kan meerdere omgevingen hebben, zoals “development”, “test”, “staging” en “production”. Om de fouten en prestatieproblemen die in de “development”-omgeving optreden te scheiden van die in “production”, is het mogelijk om de omgeving waarin de applicatie draait in te stellen met de omgevingsvariabele NODE_ENV. Als u AppSignal per omgeving activeert, kunt u de eigenschap active van de opties die u aan de constructor doorgeeft, conditioneel instellen:
// appsignal.cjs
const { Appsignal } = require("@appsignal/nodejs");

new Appsignal({
  active: process.env.NODE_ENV !== "development",
  name: "<YOUR APPLICATION NAME>",
  pushApiKey: "<YOUR API KEY>",
});
Dit zal AppSignal ook uitschakelen wanneer u uw tests uitvoert.