Skip to content

chore: add tracing #56

Open
Open

Description

@darinkishore

need to be able to emit logs, show prompts, warnings, etc...

DSRs should set up tracing::

Activity

  1. darinkishore commented on Feb 12, 2026

    @darinkishore
    CollaboratorAuthor

    Codebase audit — current tracing state

    Already instrumented (using tracing crate):

    • LM::call() — #[tracing::instrument(name = "dsrs.lm.call")]
    • LM::execute_tool_loop() — #[tracing::instrument(name = "dsrs.lm.tool_loop")]
    • ResponseCache::new/get/insert — instrumented
    • Predict::forward() — #[tracing::instrument(name = "dsrs.predict.forward")]
    • ChatAdapter::format/parse — has debug!() and trace!() calls
    • LMClient connection setup — has debug!()/warn!()/trace!() calls

    Not instrumented (gaps):

    • ChainOfThought::forward() — no tracing spans
    • ReAct::forward() — no tracing spans
    • All optimizer methods (COPRO::compile, GEPA::compile, MIPROv2::compile) — no spans at all. These are long-running and would benefit the most from progress visibility
    • DataLoader::load_* methods — no spans
    • evaluate_trainset() / evaluation loop — no spans
    • Constraint validation in bamltype::parse_llm_output — no spans

    What "add tracing" should mean concretely:

    1. Optimizer observability — these run for minutes/hours. Need:

      • Per-trial spans with trial number, candidate instruction, score
      • Progress indicators (current trial / total trials)
      • Aggregated stats (best score so far, avg score)
    2. Module composition spans — when ChainOfThought calls Predict internally, the span hierarchy should show the nesting

    3. Prompt visibility — debug!() level should emit the full formatted prompt and raw LM response (currently only partial)

    4. Structured fields — use tracing structured fields (not string interpolation) so spans are machine-parseable:

      #[tracing::instrument(
          name = "dsrs.copro.trial",
          fields(trial = idx, predictor = name, score)
      )]
    5. Subscriber setup — provide a convenience dspy_rs::init_tracing() that sets up tracing-subscriber with sensible defaults (env-filter, fmt layer). Currently users have to configure this themselves.

    Not blocked on anything — can be done incrementally file by file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions