> ## Documentation Index
> Fetch the complete documentation index at: https://docs.appsignal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# AppSignal Ruby-configuratie

export const Compatibility = ({versions = [], label = "Available in"}) => {
  if (!Array.isArray(versions) || versions.length === 0) {
    return null;
  }
  const defaultPillStyle = {
    borderColor: "#d4d4d8",
    background: "#f4f4f5",
    color: "#3f3f46"
  };
  const pillStyles = {
    "AppSignal for Elixir": {
      background: "#f3e8ff",
      borderColor: "#d8b4fe",
      color: "#6b21a8"
    },
    "AppSignal for Front-end": {
      background: "#fef9c3",
      borderColor: "#fde047",
      color: "#854d0e"
    },
    "AppSignal for Go": {
      background: "#ccfbf1",
      borderColor: "#5eead4",
      color: "#115e59"
    },
    "AppSignal for JavaScript": {
      background: "#fef9c3",
      borderColor: "#fde047",
      color: "#854d0e"
    },
    "AppSignal for Node.js": {
      background: "#dcfce7",
      borderColor: "#86efac",
      color: "#166534"
    },
    "AppSignal for Python": {
      background: "#dbeafe",
      borderColor: "#93c5fd",
      color: "#1e40af"
    },
    "AppSignal for Ruby": {
      background: "#fee2e2",
      borderColor: "#fca5a5",
      color: "#991b1b"
    },
    "AppSignal for Rust": {
      background: "#ffedd5",
      borderColor: "#fdba74",
      color: "#9a3412"
    }
  };
  const getPillStyle = name => ({
    ...defaultPillStyle,
    ...pillStyles[name] || ({})
  });
  return <div className="not-prose my-4 rounded-lg border border-zinc-200 bg-zinc-50 px-4 py-3 text-sm dark:border-white/10 dark:bg-white/5">
      <div className="flex flex-wrap items-center gap-x-2 gap-y-1">
        <span className="font-semibold text-zinc-700 dark:text-zinc-200">
          {label}:
        </span>
        {versions.map((v, i) => <span key={`${v.name}-${v.version}-${i}`} className="inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs font-medium" style={getPillStyle(v.name)}>
            <span>{v.name}</span>
            <span className="opacity-70">
              {v.version}
              {v.exact ? "" : "+"}
            </span>
          </span>)}
      </div>
    </div>;
};

Configuratie. Belangrijk, want zonder weet de AppSignal Ruby gem niet
welke applicatie hij instrumenteert of in welke omgeving.

In dit onderwerp leggen we uit hoe u AppSignal configureert, wat er in de
Ruby gem geconfigureerd kan worden, wat de minimaal benodigde configuratie is en hoe de
configuratie wordt geladen.

## Minimaal benodigde configuratie

Om applicaties data naar AppSignal te laten rapporteren is de volgende configuratie vereist. Alle andere configuratie is optioneel.

* Applicatienaam - [name-optie](/ruby/configuration/options#option-name)
* Applicatieomgeving - [environment](/ruby/configuration/options#option-appsignal_app_env) (automatisch gedetecteerd of ingesteld met een omgevingsvariabele)
* Push API key van de applicatie - [push\_api\_key-optie](/ruby/configuration/options#option-push_api_key)
* AppSignal moet actief zijn - [active-optie](/ruby/configuration/options#option-active)

Voor Rails-apps hoeft u uw applicatienaam niet te configureren; AppSignal gebruikt standaard de naam van uw applicatie.

Als u een framework gebruikt dat omgevingen kent en [door de AppSignal gem ondersteund wordt](/ruby/integrations), wordt de omgeving automatisch gedetecteerd.

<CodeGroup>
  ```ruby Ruby theme={null}
  # config/appsignal.rb
  Appsignal.configure do |config|
    config.activate_if_environment(:development, :staging, :production)
    config.name = "My app"
    config.push_api_key = "1234-1234-1234"
  end
  ```

  ```bash Bash theme={null}
  # Environment variables
  export APPSIGNAL_APP_NAME="My app"
  export APPSIGNAL_APP_ENV="production"
  export APPSIGNAL_PUSH_API_KEY="1234-1234-1234"
  ```

  ```yaml YAML theme={null}
  # config/appsignal.yml
  # Legacy config method
  production:
    active: true
    name: "My app"
    push_api_key: "1234-1234-1234"
  ```
</CodeGroup>

## Configuratiemethoden

Er zijn verschillende configuratiemethoden beschikbaar in onze Ruby gem.
Om te zien in welke volgorde ze worden geladen en welke configuratiemethode waarden uit andere bronnen overschrijft, raadpleegt u onze pagina over de [laadvolgorde van configuratie](/ruby/configuration/load-order).

### Ruby configuratiebestand

<Compatibility versions={[{ name: "AppSignal for Ruby", version: "4.2.0" }]} />

De AppSignal Ruby gem kan worden geconfigureerd met behulp van een Ruby configuratiebestand. Als hiervoor gekozen wordt, maakt de installer automatisch een `config/appsignal.rb`-bestand aan. Dit bestand bevat standaardconfiguratie-instellingen die kunnen worden aangepast om aan de specifieke behoeften van uw applicatie te voldoen.

Dit configuratiebestand wordt gelezen wanneer `Appsignal.start` wordt aangeroepen, wat automatisch gebeurt voor de meeste van onze [integraties](/ruby/integrations). Lees de [instructies voor het integreren van AppSignal](/ruby/instrumentation/integrating-appsignal) als `Appsignal.start` niet automatisch wordt aangeroepen.

Het configuratiebestand configureert onze Ruby gem met behulp van [de `Appsignal.configure` helper](#appsignalconfigure-helper). Lees de sectie [de `Appsignal.configure` helper](#appsignalconfigure-helper) voor meer details over hoe u deze gebruikt.

Het [YAML-configuratiebestand](#yaml-configuration-file) wordt niet gelezen wanneer dit bestand aanwezig is.

<CodeGroup>
  ```ruby Ruby theme={null}
  Appsignal.configure do |config|
    # Enable AppSignal for the following environments
    config.activate_if_environment(:development, :staging, :production)

    # Ignore this action for all environments
    config.ignore_actions << "My global action"

    # Ignore this action for only the production environment
    if config.env?(:production)
      config.ignore_actions << "My production action"
    end

    # Ignore this action for only the staging environment
    if config.env?(:staging)
      config.ignore_actions << "My staging action"
    end
  end
  ```
</CodeGroup>

### `Appsignal.configure` helper

De `Appsignal.configure` helper kan worden gebruikt om AppSignal met Ruby-code te configureren. Het [Ruby configuratiebestand](#ruby-configuration-file) gebruikt deze helper en deze kan ook direct in uw applicatie worden gebruikt.

Als uw app `Appsignal.configure` gebruikt buiten het `config/appsignal.rb`-bestand, zoals in een Rails-initializer, lees dan [deze sectie over verschillen in gedrag](#using-the-appsignalconfigure-helper-in-your-application).

Stel configuratieopties in binnen het `Appsignal.configure`-blok door de writer-methoden op het `config`-object aan te roepen. [Configuratieopties](/ruby/configuration/options) kunnen worden ingesteld met de "Config file key" die wordt vermeld bij de configuratieopties. Bijvoorbeeld de [`send_params`-optie](/ruby/configuration/options#option-send_params) kan worden ingesteld met: `config.send_params = false`.

<CodeGroup>
  ```ruby Ruby theme={null}
  # Some examples on how to configure config options
  Appsignal.configure do |config|
    # Enable AppSignal for the following environments
    config.activate_if_environment(:development, :staging, :production)

    # Configure String config options
    config.name = "My app name"
    # Read a value from an environment variable
    config.hostname = ENV.fetch("HOSTNAME", "default hostname value")

    # Append values to Array config options
    config.ignore_actions += ["My ignored action", "My other ignored action"]
    config.request_headers << "MY_HTTP_HEADER"

    # Configure Boolean config options
    config.send_params = true
    config.enable_host_metrics = false
  end
  ```
</CodeGroup>

Lees de rest van deze sectie voor meer details over hoe de `Appsignal.configure` helper werkt en welke andere helpers deze heeft.

#### String-configuratieopties

Configuratieopties van het type String kunnen zowel met Strings als met Symbols worden ingesteld. Wanneer ingesteld, converteren we Symbols naar Strings.

<CodeGroup>
  ```ruby Ruby theme={null}
  Appsignal.configure do |config|
    config.activejob_report_errors = :discard

    config.activejob_report_errors
    # => "discard"
  end
  ```
</CodeGroup>

#### Array-configuratieopties

Configuratieopties van het type Array kunnen worden gewijzigd als een normale array:

* Gebruik een toewijzing om de standaardwaarden en eerder ingelezen waarden uit omgevingsvariabelen te overschrijven.
  * Bijvoorbeeld: `config.array_option = ["value 1", "value 2"]`
  * Optiewaarde: `["value 1", "value 2"]`
* Gebruik de *additieve toewijzingsoperator* `+=` om een nieuwe array van waarden samen te voegen met de standaardwaarden en eerder ingelezen waarden uit omgevingsvariabelen.
  * Bijvoorbeeld: `config.array_option += ["value 1", "value 2"]`
  * Optiewaarde: `["DUMMY default value", "value 1", "value 2"]`
* Gebruik de *append-operator* `<<` om een enkele waarde toe te voegen aan de lijst van standaardwaarden en eerder ingelezen waarden uit omgevingsvariabelen.
  * Bijvoorbeeld: `config.array_option << "value 1"`
  * Optiewaarde: `["DUMMY default value", "value 1"]`

#### Automatische omgevingsdetectie

De AppSignal Ruby gem detecteert automatisch de omgeving van de applicatie. We integreren met gems zoals Rails, Sinatra, Rack en anderen om te detecteren in welke omgeving de applicatie is gestart. Daarom zou het niet nodig moeten zijn om de omgeving handmatig te configureren.

Als u de applicatieomgeving toch handmatig wilt configureren, geef dan de naam van de omgeving als eerste argument aan de `Appsignal.configure` helper. Dit argument overschrijft de waarde van de [`APPSIGNAL_APP_ENV` omgevingsvariabele](/ruby/configuration/options#option-appsignal_app_env) en de automatische omgevingsdetectie.

<CodeGroup>
  ```ruby Ruby theme={null}
  # Configure the application environment explicitly to be "production"
  Appsignal.configure(:production) do |config|
    # Some config
  end
  ```
</CodeGroup>

#### `activate_if_environment` helper

De `Appsignal.configure` helper heeft een helper om te configureren welke omgevingen actief moeten zijn en data naar AppSignal.com moeten rapporteren.

Roep `activate_if_environment` aan met een lijst van omgevingen (Strings en/of Symbols).
AppSignal detecteert de omgeving wanneer de `Appsignal.configure` helper wordt aangeroepen zonder omgevingsargument. Vervolgens controleert het of de omgeving overeenkomt met een van de gegeven waarden, en zo ja, dan wordt de [active-configuratieoptie](/ruby/configuration/options#option-active) op `true` gezet.

<CodeGroup>
  ```ruby Ruby theme={null}
  Appsignal.configure do |config|
    # Enable AppSignal for the following environments
    config.activate_if_environment(:development, :staging, :production)
  end
  ```
</CodeGroup>

De `activate_if_environment` helper is een handige helper om te voorkomen dat applicaties hun eigen controles moeten toevoegen wanneer AppSignal actief moet zijn, zoals:

<CodeGroup>
  ```ruby Ruby theme={null}
  Appsignal.configure do |config|
    # Example of a manual check for which environments AppSignal should be active
    config.active = Rails.env.development? || Rails.env.staging? || Rails.env.production?
  end
  ```
</CodeGroup>

#### `env?` helper

De `Appsignal.configure` helper heeft een helper om te controleren welke omgeving AppSignal heeft gedetecteerd. Gebruik deze helper om te controleren welke omgeving actief is en zo de configuratieopties in te stellen die alleen op deze omgeving van toepassing zijn.

Roep de `env?` helper aan met een omgevingsnaam (String of Symbol), en deze retourneert `true` als de naam van de omgeving overeenkomt met de momenteel actieve omgeving.

<CodeGroup>
  ```ruby Ruby theme={null}
  Appsignal.configure do |config|
    # Add this configuration only for the staging environment
    if config.env?(:staging)
      config.ignore_actions << "My staging action"
    end
  end
  ```
</CodeGroup>

#### De `Appsignal.configure` helper in uw applicatie gebruiken

We raden aan om de AppSignal Ruby gem te configureren met het [Ruby configuratiebestand](#ruby-configuration-file) op `config/appsignal.rb`. Als een Rails-initializer of inline-configuratie de voorkeur heeft, lees dan deze sectie voor de veranderingen in gedrag die dit met zich meebrengt.

Als de `Appsignal.configure` helper wordt aangeroepen voordat het `config/appsignal.rb` Ruby-configuratiebestand wordt gelezen wanneer `Appsignal.start` wordt aangeroepen, zal het Ruby-configuratiebestand niet worden gelezen.

In Rails-apps, zorg ervoor dat u [de AppSignal gem zo configureert dat hij start nadat Rails is geïnitialiseerd](/ruby/integrations/rails#configure-appsignal-in-an-initializer), anders wordt de configuratie ingesteld met `Appsignal.configure` genegeerd wanneer deze in een Rails-initializer zoals `config/initializers/appsignal.rb` wordt aangeroepen.

<Warning>
  In Ruby gem versie 3.12 en nieuwer wordt, als een [YAML-configuratiebestand](#yaml-configuration-file) aanwezig is, dit gelezen wanneer `Appsignal.configure` wordt aangeroepen in een Rails-initializer of inline in een applicatie. Dit gedrag is verouderd. Verplaats alle configuratie naar de `Appsignal.configure` helper.

  We zullen dit gedrag in de volgende major-versie van de Ruby gem verwijderen.
</Warning>

Voorbeeld van een Rails-initializer:

<CodeGroup>
  ```ruby Ruby theme={null}
  # Example file: config/initializers/appsignal.rb

  # WARNING: In this example the `config/appsignal.rb` config file is not read!
  Appsignal.configure do |config|
    # Set some config
  end
  ```
</CodeGroup>

Voorbeeld van inline-configuratie:

<CodeGroup>
  ```ruby Ruby theme={null}
  # Example file: app.rb
  require "appsignal"
  require "web_framework"

  # WARNING: In this example the `config/appsignal.rb` config file is not read!
  Appsignal.configure do |config|
    # Set some config
  end
  Appsignal.start

  run WebFramework.app
  ```
</CodeGroup>

### Systeem-omgevingsvariabelen

AppSignal kan ook worden geconfigureerd met behulp van systeem-omgevingsvariabelen op de host waarop de applicatie die AppSignal monitort, draait. Dit is gebruikelijk op platforms zoals Heroku.

Zorg ervoor dat deze omgevingsvariabelen geconfigureerd zijn op een manier die compatibel is met uw besturingssysteem en dat de waarden worden geladen voordat uw app met AppSignal wordt gestart.

<CodeGroup>
  ```sh Shell theme={null}
  export APPSIGNAL_APP_NAME="My app"
  ```
</CodeGroup>

### YAML-configuratiebestand

<Tip>
  Deze configuratiemethode is een verouderde methode en wordt verwijderd in de volgende major-versie van de Ruby gem.

  Gebruik in plaats daarvan het [Ruby configuratiebestand](#ruby-configuration-file).
</Tip>

De AppSignal Ruby gem kan worden geconfigureerd met een YAML-configuratiebestand. Tijdens de installatie maakt de Ruby gem, indien geselecteerd, een `config/appsignal.yml`-bestand aan. In dit bestand wordt enige standaardconfiguratie aangeleverd die kan worden aangepast aan de behoeften van uw applicatie. Dit `config/appsignal.yml`-bestand ondersteunt ERB-tags zodat systeem-omgevingsvariabelen ook in dit bestand geladen kunnen worden.

De `config/appsignal.yml`-configuratievoorbeelden die voor configuratieopties getoond worden, gebruiken het `default` YAML-anker. De AppSignal-installer maakt standaard een `config/appsignal.yml`-bestand met dit anker aan. Als dit niet aanwezig is, zorg er dan voor dat u de configuratieoptie aan de juiste omgeving toevoegt.

<CodeGroup>
  ```yaml YAML theme={null}
  # config/appsignal.yml
  # Define the "defaults" anchor
  default: &defaults
    name: "My app"
    # Supports ERB
    push_api_key: "<%= ENV['APPSIGNAL_PUSH_API_KEY'] %>"

  production:
    # Loads the defaults in the production environment by referencing the anchor
    <<: *defaults
    # production environment specific configuration
    active: true
  ```
</CodeGroup>

#### Meerdere app-omgevingen

Meerdere app-omgevingen kunnen in dit bestand worden geconfigureerd via root-level sleutels.

<CodeGroup>
  ```yaml YAML theme={null}
  # Example: config/appsignal.yml
  development: # Development app environment
    active: true

  production: # Production app environment
    active: true

  test: # Testing app environment
    active: false # Disabled for test environment
  ```
</CodeGroup>

Om te voorkomen dat we de configuratie voor elke app-omgeving moeten herhalen, kunnen we YAML-ankers gebruiken om YAML-objecten uit te breiden.

<CodeGroup>
  ```yaml YAML theme={null}
  # Example: config/appsignal.yml
  default: &defaults
    active: true

  development: # Development app environment
    <<: *defaults

  production: # Production app environment
    <<: *defaults

  test: # Testing app environment
    <<: *defaults
    active: false # Overwrites the inherited active config option from "defaults"
  ```
</CodeGroup>

Het is niet mogelijk om alleen een `defaults`-anker te configureren en dat automatisch op alle omgevingen toe te passen. Elke omgeving moet in het YAML-bestand worden geconfigureerd met een root-level sleutel en dit `defaults`-anker uitbreiden.

#### Voorbeeld van YAML-configuratiebestand

Hier is een voorbeeld van een `appsignal.yml`-configuratiebestand. Het wordt aanbevolen
dat u alleen de configuratie die u nodig heeft aan uw configuratiebestand toevoegt.

Voor de volledige lijst met opties, zie de pagina met [configuratie-
opties](/ruby/configuration/options).

<CodeGroup>
  ```yaml YAML theme={null}
  # config/appsignal.yml
  default: &defaults
    # Your Push API Key, it is possible to set this dynamically using ERB. Required
    push_api_key: "<%= ENV['APPSIGNAL_PUSH_API_KEY'] %>"

    # Your app's name as reported on AppSignal.com. Required
    name: "My App"

    # Your server's hostname. Optional, auto detected
    hostname: "frontend1.myapp.com"

    # Add default instrumentation of net/http. Default: true
    instrument_net_http: true

    # Skip session data, if it contains private information. Default: false
    skip_session_data: true

    # Ignore these errors (Optional)
    ignore_errors:
      - SystemExit

    # Ignore these actions, used by our Loadbalancer. Optional
    ignore_actions:
      - IsUpController#index

    # Enable allocation tracking for memory metrics. Default: true
    enable_allocation_tracking: true

  # Configuration per environment, leave out an environment or set active
  # to false to not push metrics for that environment.
  development:
    <<: *defaults
    active: true
    # Set the severity level of AppSignal's internal logger. Optional
    # Supported values are error, warning, info, debug, trace
    log_level: debug

  staging:
    <<: *defaults
    # Configure AppSignal to be active for this environment. Required
    active: true

  production:
    <<: *defaults
    # Configure AppSignal to be active for this environment. Required
    active: true

    # Set different path for the log file. Optional, auto detected
    log_path: "/home/my_app/app/shared/log"

    # Set AppSignal working dir. Optional, auto detected
    working_directory_path: "/tmp/appsignal"

    # When it's not possible to connect to the outside world without a proxy.
    # Optional
    http_proxy: "proxy.mydomain.com:8080"
  ```
</CodeGroup>
