> ## 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.

# Envoi d'événements de moniteur de processus à l'aide des intégrations AppSignal

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>;
};

Les intégrations AppSignal pour [Ruby](/ruby), [Elixir](/elixir), [Node.js](/nodejs) et [Python](/python) offrent des méthodes et fonctions d'assistance qui vous permettent d'envoyer facilement des événements de moniteur de processus à AppSignal.

<Note>
  Les assistants d'intégration utilisent toujours `CheckIn`, `checkIn` et `check_in` dans le code
  pour la compatibilité avec les applications existantes.
</Note>

## Événements de moniteur de processus cron

<Compatibility
  versions={[
{ name: "AppSignal pour Ruby", version: "3.13.0" },
{ name: "AppSignal pour Elixir", version: "2.12.2" },
{ name: "AppSignal pour Node.js", version: "3.4.9" },
{ name: "AppSignal pour Python", version: "1.3.8" },
]}
/>

Pour notifier AppSignal qu'une tâche cron s'est terminée avec succès, utilisez la fonction d'assistance `cron`, en passant le nom du moniteur de processus cron en argument.

<CodeGroup>
  ```ruby Ruby theme={null}
  def send_invoices
    # ... your code here ...
    Appsignal::CheckIn.cron("send_invoices")
  end
  ```

  ```elixir Elixir theme={null}
  def send_invoices do
    # ... your code here ...
    Appsignal.CheckIn.cron("send_invoices")
  end
  ```

  ```javascript Node.js theme={null}
  import { checkIn } from "@appsignal/nodejs";

  function sendInvoices() {
    // ... your code here ...
    checkIn.cron("send_invoices");
  }
  ```

  ```python Python theme={null}
  from appsignal.check_in import cron

  def send_invoices():
    # ... your code here ...
    cron("send_invoices")
  ```
</CodeGroup>

Il est sûr d'appeler la fonction d'assistance `cron` plusieurs fois sur une courte période, car l'assistant n'enverra un événement de fin à AppSignal qu'au plus une fois toutes les dix secondes.

### Surveillance de la durée de la tâche

Pour surveiller la durée d'une tâche cron, vous pouvez utiliser la fonction d'assistance `cron` avec un bloc ou une fonction contenant le code que vous souhaitez surveiller. Cela enverra des événements à AppSignal à la fois quand la tâche démarre et quand elle se termine.

<CodeGroup>
  ```ruby Ruby theme={null}
  def send_invoices()
    Appsignal::CheckIn.cron("send_invoices") do
      # ... your code here ...
    end
  end
  ```

  ```elixir Elixir theme={null}
  def send_invoices do
    Appsignal.CheckIn.cron("send_invoices", fn ->
      # ... your code here ...
    end)
  end
  ```

  ```javascript Node.js theme={null}
  import { checkIn } from "@appsignal/nodejs";

  function sendInvoices() {
    checkIn.cron("send_invoices", () => {
      // ... your code here ...
    });
  }

  // If the function passed to `cron` returns a promise, the finish event
  // will be reported to AppSignal if the promise resolves, allowing you
  // to track the duration of async functions:
  async function sendInvoices() {
    await checkIn.cron("send_invoices", async () => {
      // ... your async code here ...
    });
  }

  // If the promise is rejected, or if it never resolves, the finish event
  // will not be reported to AppSignal.
  ```

  ```python Python theme={null}
  from appsignal.check_in import Cron

  def send_invoices():
    with Cron("send_invoices"):
      # ... your code here ...
  ```
</CodeGroup>

Si une exception est levée dans la fonction ou méthode surveillée, l'événement de fin ne sera pas rapporté à AppSignal, déclenchant une notification de moniteur de processus manqué. L'exception sera relancée.

Si le contexte dans lequel l'exception est levée est un contexte surveillé par AppSignal, alors l'exception sera rapportée à AppSignal. Sinon, si vous souhaitez rapporter l'exception à AppSignal, vous pouvez utiliser nos assistants de gestion d'exceptions pour [Ruby](/ruby/instrumentation/exception-handling#appsignalreport_error), [Elixir](/elixir/instrumentation/exception-handling#appsignalsend_error3), [Node.js](/nodejs/3.x/instrumentation/exception-handling#send-error) ou [Python](/python/instrumentation/exception-handling#send_error).

## Événements de moniteur de processus heartbeat

<Compatibility
  versions={[
{ name: "AppSignal pour Ruby", version: "4.1.0" },
{ name: "AppSignal pour Elixir", version: "2.13.0" },
{ name: "AppSignal pour Node.js", version: "3.5.0" },
{ name: "AppSignal pour Python", version: "1.4.0" },
]}
/>

Pour envoyer un événement de moniteur de processus heartbeat à AppSignal, utilisez la fonction d'assistance `heartbeat`, en passant le nom du moniteur de processus heartbeat en argument.

Il est sûr d'appeler `heartbeat` plusieurs fois, car l'assistant n'enverra un événement heartbeat à AppSignal qu'au plus toutes les dix secondes.

<CodeGroup>
  ```ruby Ruby theme={null}
  loop do
    Appsignal::CheckIn.heartbeat("job_processor")
    # ... your code here ...
  end
  ```

  ```elixir Elixir theme={null}
  def job_processing_loop do
    Appsignal.CheckIn.heartbeat("job_processor")
    # ... your code here ...
    job_processing_loop()
  end
  ```

  ```javascript Node.js theme={null}
  import { checkIn } from "@appsignal/nodejs";

  while (true) {
    checkIn.heartbeat("job_processor");
    // ... your code here ...
  }
  ```

  ```python Python theme={null}
  from appsignal.check_in import heartbeat

  while True:
    heartbeat("job_processor")
    # ... your code here ...
  ```
</CodeGroup>

### Envoi de heartbeats en continu

Pour envoyer des moniteurs de processus heartbeat en continu, vous pouvez passer l'option `{ continuous: true }` à la fonction d'assistance `heartbeat`. Ceci est utile pour surveiller la durée de vie du processus lui-même. L'assistant enverra un événement heartbeat à AppSignal toutes les trente secondes.

<CodeGroup>
  ```ruby Ruby theme={null}
  Appsignal::CheckIn.heartbeat("job_processor", continuous: true)
  ```

  ```elixir Elixir theme={null}
  # This call spawns a new Elixir process, linked to the current process.
  # If the current process exits, the heartbeat process will also exit.
  Appsignal.CheckIn.heartbeat("job_processor", continuous: true)

  # It is also possible to add a continuous heartbeat sending process
  # to a supervision tree. This will ensure that the process is restarted
  # alongside the rest of the supervised children.
  Supervisor.start_link([
    {Appsignal.CheckIn.Heartbeat, "job_processor"},
    # ... other children processes ...
  ], strategy: :one_for_one)
  ```

  ```javascript Node.js theme={null}
  import { checkIn } from "@appsignal/nodejs";

  checkIn.heartbeat("job_processor", { continuous: true });
  ```

  ```python Python theme={null}
  from appsignal.check_in import heartbeat

  heartbeat("my_app", continuous=True)
  ```
</CodeGroup>

## Revue des occurrences de moniteurs de processus dans AppSignal

Une fois configuré, AppSignal commencera à afficher des informations sur les occurrences pour vos moniteurs de processus.

Vous pouvez en savoir plus sur les occurrences dans notre [documentation sur les occurrences de moniteurs de processus](/check-ins/occurrences).
