Open CalebCourier opened 2 days ago
Upon further investigation, this issue is not present in our other instrumentations because the function being wrapper for tracing in those situations is outside of the ThreadPoolExecutor. i.e. in those cases we are wrapping the function that calls Validator.validate
not Validator.validate
itself like we are in the MLFlowInstrumentor.
Describe the bug When validators are run asynchronously, whether in an AsyncGuard or in a Guard when an async event loop is available (default behaviour), the spans created during a validator's
validate
method are orphaned from the parent spans. This is likely due to the function being run in an executor with which the context that holds the parent is not provided.To Reproduce
Expected behavior Spans should maintain relationships regardless of sync vs async.
Library version: 0.6.0 Likely all versions since https://github.com/guardrails-ai/guardrails/releases/tag/v0.5.10 for Guard All versions of async before 0.5.10 if
run_in_separate_process
was assigned toTrue
Additional context This behaviour was noticed with the MLFlowInstrumentor, but is likely present with all OTEL instrumentations. Though this should be tested.