Skip to content

Add structlog to uninstrumented high-traffic modules #185

@abhi1092

Description

@abhi1092

Factory experiment 4. Hypothesis: Add structlog to 4 uninstrumented high-traffic modules.

What to Build

Add structured logging via structlog.get_logger() to these modules:

  1. factory/mcp_server.py (8 functions, 0 log statements): Add log = structlog.get_logger() and log at function entry for list_tools, call_tool, server startup/shutdown, and tool dispatch errors.

  2. factory/runners/__init__.py (2 functions, 0 log statements): Log runner selection and initialization.

  3. factory/runners/_stream.py (3 functions, 0 log statements): Log stream processing start, chunk handling, and completion.

  4. factory/runners/protocol.py (2 functions, 0 log statements): Log protocol method dispatch.

Use log.info() for key operations, log.debug() for routine paths, log.warning() for fallback/error paths. Follow existing codebase patterns — bind context with log.bind(runner=..., role=...) where relevant.

Acceptance Criteria

  • All 4 modules have structlog logging
  • At least 15 new log statements across the modules
  • Follow existing logging patterns (structlog.get_logger() at module level)
  • All existing tests pass
  • Eval score does not regress

Constraints

  • Read CLAUDE.md before starting
  • Do NOT touch files outside declared scope
  • Do NOT modify eval/score.py or .factory/
  • Do NOT add logging to pure data models (models.py, ace/models.py)
  • Use log.debug() for routine operations, log.info() for key state transitions

Metadata

Metadata

Assignees

No one assigned

    Labels

    implementationFactory experiment implementation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions