Skip to content

Add optional Monocle observability (opt-in) - #3

Draft
imohammedansari wants to merge 1 commit into
mainfrom
monocle-optional
Draft

Add optional Monocle observability (opt-in)#3
imohammedansari wants to merge 1 commit into
mainfrom
monocle-optional

Conversation

@imohammedansari

@imohammedansari imohammedansari commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Adds optional, opt-in Monocle observability to Open Deep Research, following the same app-owned env interface as the existing LangSmith tracing gate. Off by default; a default install is unaffected.

Env interface (parallel to LANGSMITH_*)

Variable Purpose Default
MONOCLE_TRACING Truthy gate that turns tracing on off
MONOCLE_EXPORTERS Comma-separated exporters: file, console, okahu, s3, blob, gcs file
OKAHU_API_KEY Required only when okahu is selected

What it does

  • The app reads MONOCLE_EXPORTERS itself, validates each entry against the known set, and fails fast on an unknown exporter or an okahu selection without OKAHU_API_KEY — before any instrumentation runs, so a config typo surfaces a clear error rather than an opaque one.
  • It then forwards the value as setup_monocle_telemetry(workflow_name="open-deep-research", monocle_exporters_list=<MONOCLE_EXPORTERS or "file">). The app owns the exporter selection rather than deferring to Monocle's own env var.
  • When MONOCLE_TRACING is unset/false the block is a no-op and monocle_apptrace is never imported.
  • monocle_apptrace is an optional [monocle] extra (not a core dependency). Enabling tracing without the extra raises a clear install hint: pip install "open_deep_research[monocle]".

Each run writes one trace file to .monocle/, viewable in the Monocle VS Code extension; the okahu exporter sends traces to Okahu for cross-run analysis.

Files changed

  • src/open_deep_research/deep_researcher.py — guarded, gated setup helper (initialized once at import).
  • .env.exampleMONOCLE_TRACING / MONOCLE_EXPORTERS / OKAHU_API_KEY block.
  • pyproject.tomlmonocle optional extra.
  • README.md — "Monocle Tracing" section under Configurations.

Verification (4 cases)

  • Disabled (default): module imports, monocle_apptrace never imported, setup not called.
  • Enabled + installed: setup_monocle_telemetry called; MONOCLE_EXPORTERS=file,console → forwarded "file,console"; unset → "file".
  • Enabled + extra absent: RuntimeError with the pip install "open_deep_research[monocle]" hint.
  • Fail-fast: unknown exporter → ValueError; okahu without OKAHU_API_KEYValueError.

Also confirmed with the real installed monocle_apptrace that import open_deep_research.deep_researcher works both disabled (no .monocle/ written) and enabled (real setup runs).

@imohammedansari
imohammedansari force-pushed the monocle-optional branch 3 times, most recently from 44c2171 to 501698a Compare July 15, 2026 22:44
@imohammedansari imohammedansari changed the title Make Monocle observability optional (env-gated, optional extra) Add optional Monocle observability (opt-in) Jul 15, 2026
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.

1 participant