Add optional Monocle observability (opt-in) - #3
Draft
imohammedansari wants to merge 1 commit into
Draft
Conversation
imohammedansari
force-pushed
the
monocle-optional
branch
from
July 15, 2026 22:58
bbc49a5 to
20b0d1e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add optional Monocle observability (opt-in)
Adds optional Monocle tracing to the Deep Research assistant. Monocle is an OpenTelemetry-based tracer for agentic apps; it records each run end-to-end (LLM calls, agent steps, tool invocations, with inputs/outputs, timings, token counts). It is entirely opt-in and a clean no-op unless enabled.
Env interface (unprefixed, shared across the Monocle-enabled apps)
MONOCLE_TRACING— truthy gate, OFF by default.MONOCLE_EXPORTERS— plural, comma-separated; defaultfile. Validated againstfile, console, okahu, s3, blob, gcs.OKAHU_API_KEY— required only when theokahuexporter is selected.The app reads
MONOCLE_EXPORTERSitself, fails fast on an unknown exporter orokahu-without-key, then forwards the comma-separated string verbatim assetup_monocle_telemetry(workflow_name="openai-agents-deep-research", monocle_exporters_list=...).Optional dependency
monocle_apptraceis amonocleextra insetup.py(pip install "deep-researcher[monocle]"); it is not in corerequirements.txt/install_requires. EnablingMONOCLE_TRACINGwithout the extra raises a clearRuntimeErrorwith the install hint. Telemetry helpers are no-ops when disabled or absent.Behaviour (4 cases verified)
MONOCLE_TRACINGunset)monocle_apptracenever importedMONOCLE_EXPORTERS=file,consolesetup_monocle_telemetry(..., monocle_exporters_list="file,console")MONOCLE_EXPORTERSunset"file"RuntimeErrorwithpip install "deep-researcher[monocle]"hintokahuwithout keyValueErrorfail-fast before instrumentingFiles changed
deep_researcher/utils/telemetry.py(new) — gated setup + no-op async span/scope helpersdeep_researcher/main.py— onesetup_telemetry(...)call + single workflow -> agentic.turn span shaping (no-op when disabled)setup.py—monocleextra.env.example—MONOCLE_TRACING/MONOCLE_EXPORTERS/OKAHU_API_KEYREADME.md— "Monocle Tracing" subsection under Trace MonitoringAuthor: Mohammed Ansari mohammed.ansari@okahu.ai. No secrets (placeholder
okh_xxxxxxxx). Offline test suite unchanged (the pre-existingtest_reformat_section_headingsfailure is unrelated).