Naar hoofdinhoud gaan
Configuratie. Belangrijk, want zonder configuratie weet het AppSignal Elixir-pakket niet welke applicatie het instrumenteert of in welke omgeving. In dit onderwerp leggen we uit hoe u AppSignal configureert, wat er in het Elixir-pakket kan worden geconfigureerd en wat de minimaal benodigde configuratie is.

Minimaal vereiste configuratie

De minimaal vereiste configuratie voor AppSignal voor Elixir bestaat uit de volgende items. Als deze niet aanwezig zijn, zal AppSignal geen data naar AppSignal.com sturen.
  • Een geldige Push API-sleutel
  • De OTP-naam van de applicatie
  • Een applicatienaam
  • Een applicatieomgeving (dev / prod / test)
  • De applicatieomgeving moet ingesteld zijn op active: true
# Example minimal config file
# config/config.exs
config :appsignal, :config,
  otp_app: :appsignal_phoenix_example,
  name: "AppsignalPhoenixExample",
  push_api_key: "your-push-api-key",
  env: Mix.env,
  active: true
Alternatief kunt u de agent configureren met systeemomgevingsvariabelen. AppSignal wordt automatisch actief als de APPSIGNAL_PUSH_API_KEY-omgevingsvariabele is ingesteld.
export APPSIGNAL_OTP_APP="appsignal_phoenix_example"
export APPSIGNAL_PUSH_API_KEY="your-push-api-key"
export APPSIGNAL_APP_NAME="AppsignalPhoenixExample"
export APPSIGNAL_APP_ENV="prod"

Configuratieopties

Lees over alle configuratieopties op de optiespagina.

Applicatieomgevingen

Een applicatie kan meerdere omgevingen hebben, zoals “development”/“dev”, “test”, “staging” en “production”. Om de fouten en performanceproblemen die in de “development”-omgeving optreden te scheiden van die in “production”, kunt u met de configuratieoptie env instellen in welke omgeving de applicatie draait. Een typisch configuratiebestand voor een omgeving bevat het volgende.
# config/prod.exs
config :appsignal, :config,
  active: true,
  env: :prod
Het bovenstaande voorbeeld van een configuratiebestand is ook wat door de AppSignal-installer per omgeving wordt gegenereerd. Als u AppSignal per omgeving activeert met active: true in het bestand config/{env}.exs, dan is de optie active niet vereist in het hoofdbestand config/config.exs.

AppSignal uitschakelen voor tests

Als u uw volledige AppSignal-configuratie in config/config.exs plaatst in plaats van in config/prod.exs (bijvoorbeeld om AppSignal ingeschakeld te hebben tijdens ontwikkeling), zorg er dan voor dat u active: false in uw testconfiguratie plaatst, tenzij u al uw testresultaten wilt indienen.
# config/test.exs
config :appsignal, :config,
  active: false

Voorbeeldconfiguratie

# config/config.exs
config :appsignal, :config,
  otp_app: :appsignal_phoenix_example,
  name: "AppsignalPhoenixExample",
  push_api_key: "your-push-api-key",
  env: Mix.env,
# config/test.exs
config :appsignal, :config,
  active: false