---
title: "Modules"
description: "Integration for attaching loaded libraries and their versions to events, populating the event modules field."
url: https://develop.sentry.dev/sdk/foundations/client/integrations/modules/
---

# Modules

This document uses key words such as "MUST", "SHOULD", and "MAY" as defined in

<!-- -->

[RFC 2119](https://www.ietf.org/rfc/rfc2119.txt) to indicate requirement levels.

Statusstable

Version`1.0.0`[(changelog)](https://develop.sentry.dev/sdk/foundations/client/integrations/modules.md#changelog)

## [Overview](https://develop.sentry.dev/sdk/foundations/client/integrations/modules.md#overview)

The Modules integration attaches a list of loaded libraries (packages, modules) and their versions to events. This populates the [`modules` field](https://develop.sentry.dev/sdk/foundations/transport/event-payloads.md#optional-attributes) on the event payload, which Sentry displays in the event detail view to help users identify dependency-related issues.

This integration **SHOULD** be a default integration.

***

## [Behavior](https://develop.sentry.dev/sdk/foundations/client/integrations/modules.md#behavior)

### [Event Enrichment](https://develop.sentry.dev/sdk/foundations/client/integrations/modules.md#event-enrichment)

Stablespecified since

<!-- -->

1.0.0

The integration **MUST** use the `processEvent` lifecycle hook to attach module information to events.

The integration **MUST** populate `event.modules` as a map of module name to version string:

```json
{
  "modules": {
    "flask": "2.3.1",
    "requests": "2.31.0",
    "sqlalchemy": "2.0.19"
  }
}
```

The integration **SHOULD** cache the module list, since installed packages rarely change during a process lifetime.

### [Module Sources](https://develop.sentry.dev/sdk/foundations/client/integrations/modules.md#module-sources)

Stablespecified since

<!-- -->

1.0.0

How modules are discovered is platform-specific. SDKs **SHOULD** use the most reliable mechanism available on their platform. Common strategies include:

* **Package manager metadata** — reading installed package registries (e.g., `pkg_resources` or `importlib.metadata` in Python, `package.json` dependencies in Node.js)
* **Runtime module cache** — inspecting loaded modules from the runtime (e.g., `require.cache` in Node.js CJS)
* **Build-time injection** — embedding module information at build time when runtime discovery is unavailable or incomplete (e.g., bundled environments)

SDKs **MAY** combine multiple sources to produce the most complete list. When the same module appears in multiple sources, the more specific version (e.g., from a lockfile or runtime cache) **SHOULD** take precedence.

### [Event Type Filtering](https://develop.sentry.dev/sdk/foundations/client/integrations/modules.md#event-type-filtering)

Stablespecified since

<!-- -->

1.0.0

SDKs **MAY** skip attaching modules to certain event types (e.g., transactions) where the information is less useful, to reduce payload size.

***

## [Examples](https://develop.sentry.dev/sdk/foundations/client/integrations/modules.md#examples)

### [JavaScript (Node.js)](https://develop.sentry.dev/sdk/foundations/client/integrations/modules.md#javascript-nodejs)

```javascript
// modulesIntegration is a default integration in @sentry/node
Sentry.init({
  dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
});

// Modules are automatically attached to error events.
// The integration reads from package.json and require.cache (CJS).
```

### [Python](https://develop.sentry.dev/sdk/foundations/client/integrations/modules.md#python)

```python
import sentry_sdk

# ModulesIntegration is a default integration
sentry_sdk.init(dsn="https://examplePublicKey@o0.ingest.sentry.io/0")

# Modules are automatically attached to error events.
# The integration reads from importlib.metadata / pkg_resources.
```

***

## [Changelog](https://develop.sentry.dev/sdk/foundations/client/integrations/modules.md#changelog)

| Version | Date       | Summary                                        |
| ------- | ---------- | ---------------------------------------------- |
| `1.0.0` | 2026-03-04 | Initial spec, extracted from expected features |
