Skip to content

Please add Ray framework integration for sentry/apm. #2400

Closed

Description

@dPeS

Problem Statement

https://www.ray.io/

I want to annotate that kind of code with spans:

import ray
import os
import time
import sentry_sdk
import random
import asyncio
from sentry_sdk.integrations.asyncio import AsyncioIntegration

logging.basicConfig(level=logging.DEBUG)

def step1():
    with sentry_sdk.start_span(description="step1"):
        time.sleep(random.randint(200,500)/1000.)
def step2():
    with sentry_sdk.start_span(description="step2"):
        time.sleep(random.randint(200,500)/1000.)
def step3():
    with sentry_sdk.start_span(description="step3"):
        time.sleep(random.randint(200,500)/1000.)

@ray.remote
def retrieve_task(item):
    step1()
    step2()
    step3()
    return 1

async def main():
    sentry_sdk.init(
        dsn=os.getenv('SENTRY_DSN'),
        traces_sample_rate=1.0,
        integrations=[
            AsyncioIntegration(),
        ],
    )
    #---
    ray.init()
    with sentry_sdk.start_transaction(op="task", name="example ray task transaction"):
        object_references = [
            retrieve_task.remote(item) for item in range(8)
        ]
        data = ray.get(object_references)
        print(data)

if __name__ ==  '__main__':
    asyncio.run(main())

But I only see one big transaction trace without those 3 spans.

Solution Brainstorm

I think new integration needs to be done.

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀on Sep 29, 2023
  2. antonpirker commented on Oct 2, 2023

    @antonpirker
    Contributor

    Hey @dPeS !

    Thanks for bringing this up!

    I guess the problem is that the step*() functions are run in another process or something like this (don't know how Ray works) And that the tracing data are not propagated to the other process thus the spans can not be attached to the transaction you create...

  3. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀on Oct 2, 2023
  4. antonpirker commented on Oct 2, 2023

    @antonpirker
    Contributor

    Lets test how much demand there is:

    If you want to see us support Ray, please "Thumb up" this issue!

  5. added
    New Integration
    on Oct 3, 2023
  6. dPeS commented on Oct 4, 2023

    @dPeS
    Author

    I guess the problem is that the step*() functions are run in another process or something like this (don't know how Ray works) And that the tracing data are not propagated to the other process thus the spans can not be attached to the transaction you create...

    @antonpirker not the only problem - in those "remote" ray workers sentry isn't initialized - that's for starter.

  7. moved this to Waiting for: Product Owner in GitHub Issues with 👀on Oct 4, 2023
  8. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀on Oct 5, 2023
  9. 11 remaining items

  10. szokeasaurusrex commented on May 6, 2024

    @szokeasaurusrex
    Member

    @leokster Thanks for reaching out, I will try to look into this later this week

  11. removed their assignment
    on May 13, 2024
  12. added
    Triaged
    on Jul 1, 2024
  13. self-assigned this
    on Aug 7, 2024
  14. antonpirker commented on Aug 13, 2024

    @antonpirker
    Contributor

    @dPeS the Ray integration has been released in Sentry SDK version 2.13.0:
    https://github.com/getsentry/sentry-python/releases/tag/2.13.0

    Thanks again for the great work! 🥇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

New IntegrationTriaged

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions