diff --git a/docs/platforms/python/integrations/index.mdx b/docs/platforms/python/integrations/index.mdx index ed4b73db514b3..85993b1329a05 100644 --- a/docs/platforms/python/integrations/index.mdx +++ b/docs/platforms/python/integrations/index.mdx @@ -55,6 +55,7 @@ The Sentry SDK uses integrations to hook into the functionality of popular libra | | ✓ | | | ✓ | | | ✓ | +| | | ### Cloud Computing @@ -148,7 +149,6 @@ sentry_sdk.init( ) ``` - ### Disabling Integrations To disable an integration, use the [`disabled_integrations`](/platforms/python/configuration/options/#disabled-integrations) config option: @@ -167,11 +167,11 @@ sentry_sdk.init( It's also possible to disable all automatically-added integrations. There are two types: -* **Auto-enabled integrations** like `FlaskIntegration` are automatically added +- **Auto-enabled integrations** like `FlaskIntegration` are automatically added if the SDK detects that you have a corresponding package (like Flask) installed. This happens when the [`auto_enabling_integrations`](/platforms/python/configuration/options/#auto-enabling-integrations) option is set to `True` (default). -* **Default integrations** like `logging` or `excepthook` are always enabled, +- **Default integrations** like `logging` or `excepthook` are always enabled, regardless of what packages you have installed, as long as the [`default_integrations`](/platforms/python/configuration/options/#default-integrations) option is `True` (default). They provide essential SDK functionality like error deduplication or event flushing at interpreter diff --git a/docs/platforms/python/integrations/ray/index.mdx b/docs/platforms/python/integrations/ray/index.mdx new file mode 100644 index 0000000000000..75352b1f0d0c8 --- /dev/null +++ b/docs/platforms/python/integrations/ray/index.mdx @@ -0,0 +1,101 @@ +--- +title: Ray +description: "Learn how to import and use the Ray integration." +--- + +The Ray integration adds support for the [Ray](https://www.ray.io/) unified compute framework. + +## Install + +To get started, install `sentry-sdk` from PyPI. + +```bash +pip install --upgrade sentry-sdk +``` + +## Configure + +Add `RayIntegration()` to your `integrations` list: + + + +In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). You can also collect and analyze performance profiles from real users with [profiling](/product/explore/profiling/). + +Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below. + + + +```python {"onboardingOptions": {"performance": "9-11", "profiling": "12-15"}} +import ray + +import sentry_sdk +from sentry_sdk.integrations.ray import RayIntegration + +def init_sentry(): + sentry_sdk.init( + dsn="___PUBLIC_DSN___", + # Set traces_sample_rate to 1.0 to capture 100% + # of transactions for tracing. + traces_sample_rate=1.0, + # Set profiles_sample_rate to 1.0 to profile 100% + # of sampled transactions. + # We recommend adjusting this value in production. + profiles_sample_rate=1.0, + integrations=[ + RayIntegration(), + ], + ) + +init_sentry() + +ray.init( + runtime_env={"worker_process_setup_hook": init_sentry}, +) +``` + +Be sure to call `sentry_sdk.init()` before you call `ray.init()`. + +By setting the `worker_process_setup_hook` we make sure that `sentry_sdk.init()` is called inside Ray worker processes during startup. This allows Sentry to connect code running in the worker with the calling code. + +## Verify + +Trigger an error in your code to verify that the integration is sending events to Sentry. + +```python +def init_sentry(): + sentry_sdk.init(...) # same as above + +init_sentry() + +ray.init( + runtime_env={"worker_process_setup_hook": init_sentry}, +) + +@ray.remote +def divide(a, b): + return a/b + +with sentry_sdk.start_transaction(name="ray-test"): + futures = [ + divide.remote(10, 5), + divide.remote(10, 0), + ] + print(ray.get(futures)) +``` + +Running this will create an error event (`ZeroDivisionError`) that will be sent to [sentry.io](https://sentry.io). Additionally, trace information will be created in the Performance section of [sentry.io](https://sentry.io). + +## Behavior + +- All unhandled exceptions will be captured and can be seen on [sentry.io](https://sentry.io). +- Performance data will be captured and available in the Performance section of [sentry.io](https://sentry.io). +- Performance data from [Ray Tasks](https://docs.ray.io/en/latest/ray-core/tasks.html) will be captured and linked to the calling code. +- **Note**: Capturing performance data from [Ray Actors](https://docs.ray.io/en/latest/ray-core/actors.html) is currently **not supported**. (As always, [PRs are welcome](https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md)) + +## Supported Versions + +- Ray: 2.34+ +- Python: 3.8+ +