# Sentry Middleware
Source: https://www.inngest.com/docs/features/middleware/sentry-middleware

Using the Sentry middleware is useful to:
- Capture exceptions for reporting
- Add tracing to each function run
- Include useful context for each exception and trace like function ID and event names

## Installation

<GuideSelector
  options={[
    { key: "typescript", title: "TypeScript (v3.0.0+)" },
    { key: "python", title: "Python (v0.3.0+)" }
  ]}>

  <GuideSection show="python">

    The `SentryMiddleware` is shipped as part of the `inngest` package:

    ```py
    import inngest
    from inngest.experimental.sentry_middleware import SentryMiddleware

    import sentry_sdk

    # Initialize Sentry as usual wherever is appropriate
    sentry_sdk.init(
        traces_sample_rate=1.0,
        profiles_sample_rate=1.0,
    )

    inngest_client = inngest.Inngest(
        app_id="my-app",
        middleware=[SentryMiddleware],
    )
    ```

  </GuideSection>

  <GuideSection show="typescript">

    Install the [`@inngest/middleware-sentry` package](https://www.npmjs.com/package/@inngest/middleware-sentry) and configure it as follows:

    ```ts
    // Initialize Sentry as usual wherever is appropriate
    Sentry.init(...);

    new Inngest({
      id: "my-app",
      middleware: [sentryMiddleware()],
    });
    ```

  <Callout>
    Requires inngest@>=3.0.0 and @sentry/*@>=8.0.0`.
  </Callout>

  </GuideSection>

</GuideSelector>