Fix: skip opentelemetry-instrument when OTEL is disabled#2968
Conversation
When OTEL_SDK_DISABLED=true (set automatically when no OTEL_ env vars are present), the opentelemetry-instrument wrapper does not properly pass through the WATCHFILES_CHANGES environment variable to watcher.py. This causes the filesystem watcher to silently fail - watchfiles detects changes but watcher.py receives an empty WATCHFILES_CHANGES and exits immediately without scheduling any rescans. The fix skips the opentelemetry-instrument wrapper when OTEL is disabled, allowing watchfiles to pass WATCHFILES_CHANGES directly to watcher.py. Fixes automatic rescan on filesystem change for users who don't configure OpenTelemetry (the majority of self-hosted deployments).
Summary of ChangesHello @Wadenschwinger, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a critical issue affecting the filesystem watcher's ability to detect and respond to file changes when OpenTelemetry is not configured. By introducing a conditional bypass for the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request addresses a bug where the filesystem watcher would silently fail when OpenTelemetry is disabled. The proposed fix correctly bypasses the opentelemetry-instrument wrapper when OTEL_SDK_DISABLED is true, ensuring the WATCHFILES_CHANGES environment variable is passed correctly. The change is correct and well-justified. I've added one suggestion to refactor the new code to reduce duplication and improve maintainability.
Description
When
OTEL_SDK_DISABLED=true(set automatically when noOTEL_env vars are present), theopentelemetry-instrumentwrapper does not pass through theWATCHFILES_CHANGESenvironment variable towatcher.py.This causes the filesystem watcher to silently fail:
watchfilesdetects changes butwatcher.pyreceives an emptyWATCHFILES_CHANGESand exits immediately without scheduling rescans.The fix: Skip the
opentelemetry-instrumentwrapper when OTEL is disabled, allowingwatchfilesto passWATCHFILES_CHANGESdirectly towatcher.py.This fixes
ENABLE_RESCAN_ON_FILESYSTEM_CHANGE=truefor users who don't configure OpenTelemetry.Checklist
Screenshots (if applicable)
Before fix (watcher exits immediately, no rescan scheduled):
After fix (watcher processes changes and schedules rescan):