Skip to content

Conversation

@cretz
Copy link
Member

@cretz cretz commented Dec 2, 2025

What was changed

We already disable durable scheduler for the obvious possibly-non-deterministic OTel calls, but sadly some libraries (like DataDog) monkey patch Context.current which may make illegal calls, and accessing current context is done for most OTel calls.

So this issue disables durable scheduler for more OTel work and adds a test for a monkey patch of Context.current that does illegal things

Checklist

  1. Closes [Feature Request] Disable durable scheduler for all OTel in-workflow calls, not just some #359

@cretz cretz requested a review from a team as a code owner December 2, 2025 15:11
Copy link
Member

@chris-olszewski chris-olszewski left a comment

Choose a reason for hiding this comment

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

LGTM, one small question for my own knowledge

# Do nothing if replaying and not wanted during replay
return nil if !even_during_replay && Temporalio::Workflow::Unsafe.replaying?

# If there is no span on the context and the user hasn't opted in to always creating, do not create. This
Copy link
Member

Choose a reason for hiding this comment

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

Is Temporalio::Workflow::Unsafe.durable_scheduler_disabled hefty enough that we want to avoid calling it twice or was the block move just cleaner code?

Copy link
Member Author

@cretz cretz Dec 2, 2025

Choose a reason for hiding this comment

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

It's not too bad I don't think, it just unsets the fiber scheduler temporarily and turns off illegal call validation (just a bool setting).

I put in some thought here, but decided I'd rather keep the block-based approach as the only way to disable scheduler currently (instead of also supporting a split disable and re-enable), so I figured splitting the OTel part was better.

(note, my comment refers to "We cannot use ::OpenTelemetry::Trace.with_span here unfortunately", this line of code linked is just code we moved to inside the scheduler disabling)

@cretz cretz merged commit bf2ad8e into temporalio:main Dec 2, 2025
7 checks passed
@cretz cretz deleted the otel-disable-durable branch December 2, 2025 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Disable durable scheduler for all OTel in-workflow calls, not just some

2 participants