Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
dPeS opened this issue Sep 29, 2023 · 8 comments · Fixed by #2444
Closed

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

dPeS opened this issue Sep 29, 2023 · 8 comments · Fixed by #2444
Assignees
Labels
New Integration Integrating with a new framework or library Triaged Has been looked at recently during old issue triage

Comments

@dPeS
Copy link

dPeS commented Sep 29, 2023

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.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 Sep 29, 2023
@antonpirker
Copy link
Member

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

@antonpirker
Copy link
Member

Lets test how much demand there is:

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

@sentrivana sentrivana added the New Integration Integrating with a new framework or library label Oct 3, 2023
@dPeS
Copy link
Author

dPeS commented Oct 4, 2023

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.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 Oct 4, 2023
@getsantry getsantry bot removed the status in GitHub Issues with 👀 Oct 5, 2023
glowskir added a commit to glowskir/sentry-python that referenced this issue Oct 14, 2023
@glowskir
Copy link
Contributor

glowskir commented Oct 14, 2023

@szokeasaurusrex Hey I made PR with Ray integration, it handles tracing propagation to ray cluster, feedback is more than welcome! #2444

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 Oct 14, 2023
@antonpirker
Copy link
Member

Thanks @glowskir for the integration! We will have a look sometime soon. Can not promise any ETA yet.

@getsantry getsantry bot removed the status in GitHub Issues with 👀 Oct 16, 2023
glowskir added a commit to glowskir/sentry-python that referenced this issue Nov 10, 2023
@leokster
Copy link

leokster commented May 3, 2024

@antonpirker is it planned to merge this PR? ray is becoming more and more popular, would be great to use sentry with it.

@szokeasaurusrex
Copy link
Member

szokeasaurusrex commented May 6, 2024

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

szokeasaurusrex pushed a commit to glowskir/sentry-python that referenced this issue May 6, 2024
szokeasaurusrex pushed a commit to glowskir/sentry-python that referenced this issue May 6, 2024
The integration includes performance support. Also, add tests for the integration.

Closes getsentry#2400
szokeasaurusrex pushed a commit to glowskir/sentry-python that referenced this issue May 6, 2024
The integration includes performance support. Also, add tests for the integration.

Closes getsentry#2400
szokeasaurusrex pushed a commit to glowskir/sentry-python that referenced this issue May 6, 2024
The integration includes performance support. Also, add tests for the integration.

Closes getsentry#2400
@szokeasaurusrex szokeasaurusrex removed their assignment May 13, 2024
@sentrivana sentrivana added the Triaged Has been looked at recently during old issue triage label Jul 1, 2024
@antonpirker antonpirker self-assigned this Aug 7, 2024
@antonpirker
Copy link
Member

@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! 🥇

arjennienhuis pushed a commit to arjennienhuis/sentry-python that referenced this issue Sep 30, 2024
Adds a basic instrumentation for the Ray framework (https://www.ray.io/)

Closes getsentry#2400

----

Co-authored-by: Anton Pirker <anton@ignaz.at>
Co-authored-by: Ivana Kellyer <ivana.kellyer@sentry.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New Integration Integrating with a new framework or library Triaged Has been looked at recently during old issue triage
Projects
Archived in project
Archived in project
Archived in project
Development

Successfully merging a pull request may close this issue.

6 participants