fix: mark tracer disabled when tracing is disabled via env var#4203
fix: mark tracer disabled when tracing is disabled via env var#4203koriyoshi2041 wants to merge 1 commit into
Conversation
Traceloop.init() returns early when TRACELOOP_TRACING_ENABLED is false, but unlike the enabled=False init flag it never called TracerWrapper.set_disabled(True). The TracerWrapper was therefore left uninitialized rather than disabled, so @workflow/@task decorators printed "Traceloop not initialized" warnings instead of running as silent no-ops. Mirror the init-flag path and mark the tracer disabled.
|
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughWhen tracing is disabled via the ChangesDisabled Tracing Silent No-op Behavior
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
I have read the CLA Document and I hereby sign the CLA |
Fixes #4191.
There are two ways to disable tracing, and they diverge:
Traceloop.init(enabled=False)callsTracerWrapper.set_disabled(True)and returns, so@workflow/@taskdecorators become clean no-ops (verify_initialized()returnsFalseearly when disabled).TRACELOOP_TRACING_ENABLED=falsejust prints"Tracing is disabled"and returns withoutset_disabled(True).So with the env var,
TracerWrapperis never initialized and never marked disabled. Decorated functions then hit the uninitialized branch and spamWarning: Traceloop not initialized, make sure you call Traceloop.init().The fix calls
TracerWrapper.set_disabled(True)in the env-var path too, mirroring theenabled=Falsebranch.Added
test_tracing_disabled_via_env_var_is_silent_noop(intest_sdk_initialization.py): withTRACELOOP_TRACING_ENABLED=false, afterinit()a@workflow-decorated call must not print the "not initialized" warning. It fails before the fix and passes after.(The issue title says
TRACELOOP_TRACKING_ENABLED, but the actual env var isTRACELOOP_TRACING_ENABLED— the behavior is the same regardless.)Summary by CodeRabbit
Bug Fixes
Tests