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

Fix arq tests in POTel #3875

Open
wants to merge 5 commits into
base: potel-base
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion sentry_sdk/integrations/arq.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import sys

from opentelemetry.trace.status import StatusCode

import sentry_sdk
from sentry_sdk.consts import OP, SPANSTATUS
from sentry_sdk.integrations import DidNotEnable, Integration
Expand Down Expand Up @@ -116,7 +118,14 @@ async def _sentry_run_job(self, job_id, score):
origin=ArqIntegration.origin,
) as span:
return_value = await old_run_job(self, job_id, score)
span.set_status(SPANSTATUS.OK)

status_unset = (
hasattr(span._otel_span, "status")
and span._otel_span.status.status_code == StatusCode.UNSET
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like that we're accessing the underlying _otel_span here -- would prefer to have POTelSpan manage the proxying as much as possible. We could add a status property to POTelSpan that returns _otel_span.status and use that here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you are right. I thought this is done in multiple integrations and I will fix it in another Pr. But I guess I misremembered.
Will fix it in this PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have now implemented a status property. Have a look at the tests, because the Otel span statuses and the Sentry span status are different, the Sentry status one can get with the status property can be different from the one that has been set with set_status() before. And I default to "UNKNOWN_ERROR". Does this look ok to you?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes sense.

if status_unset:
span.set_status(SPANSTATUS.OK)

return return_value

Worker.run_job = _sentry_run_job
Expand Down
Loading