UAT: trace_service.py uses standard logging instead of spec-required structlog #3761

Open
opened 2026-04-05 22:32:06 +00:00 by freemo · 0 comments
Owner

Bug Report

What Was Tested

Code-level analysis of src/cleveragents/application/services/trace_service.py against the observability specification in docs/specification.md §Observability → Structured Logging.

Expected Behavior (from spec)

The specification (line ~45890) explicitly mandates:

All logging uses structlog with JSON output format.

The spec code example shows:

import structlog
logger = structlog.get_logger()

This requirement applies to all modules in the codebase. The structlog library is listed as a required dependency (>= 24.4.0) in the dependency table (spec line ~43887):

structlog | >= 24.4.0 | Structured logging | JSON-structured log output with context binding (plan_id, decision_id, actor_name, tool_name).

Actual Behavior

trace_service.py uses the standard Python logging module instead of structlog:

# Line 22 — WRONG
import logging

# Line 39 — WRONG
logger = logging.getLogger(__name__)

This means all log output from TraceService (including the record_trace debug log and the LangSmith warning) bypasses the structlog JSON pipeline, losing:

  • Automatic context binding (plan_id, actor_name, etc.)
  • JSON-structured output for log aggregation
  • Secret masking at the structlog processor level

Code Location

  • File: src/cleveragents/application/services/trace_service.py
  • Lines 22 and 39

Steps to Reproduce

  1. Open src/cleveragents/application/services/trace_service.py
  2. Observe import logging on line 22 and logger = logging.getLogger(__name__) on line 39
  3. Compare with audit_service.py (same directory) which correctly uses import structlog and _logger = structlog.get_logger(__name__)

Fix Required

Replace:

import logging
...
logger = logging.getLogger(__name__)

With:

import structlog
...
_logger = structlog.get_logger(__name__)

And update all logger.debug(...) / logger.warning(...) calls to use structlog's keyword-argument style:

_logger.debug("trace_recorded", trace_id=trace.trace_id, plan_id=trace.plan_id)
_logger.warning("langsmith_forward_failed", trace_id=trace.trace_id, exc_info=True)

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-uat-tester

## Bug Report ### What Was Tested Code-level analysis of `src/cleveragents/application/services/trace_service.py` against the observability specification in `docs/specification.md` §Observability → Structured Logging. ### Expected Behavior (from spec) The specification (line ~45890) explicitly mandates: > **All logging uses structlog with JSON output format.** The spec code example shows: ```python import structlog logger = structlog.get_logger() ``` This requirement applies to **all** modules in the codebase. The `structlog` library is listed as a required dependency (`>= 24.4.0`) in the dependency table (spec line ~43887): > **structlog** | >= 24.4.0 | Structured logging | JSON-structured log output with context binding (plan_id, decision_id, actor_name, tool_name). ### Actual Behavior `trace_service.py` uses the standard Python `logging` module instead of `structlog`: ```python # Line 22 — WRONG import logging # Line 39 — WRONG logger = logging.getLogger(__name__) ``` This means all log output from `TraceService` (including the `record_trace` debug log and the LangSmith warning) bypasses the structlog JSON pipeline, losing: - Automatic context binding (plan_id, actor_name, etc.) - JSON-structured output for log aggregation - Secret masking at the structlog processor level ### Code Location - **File**: `src/cleveragents/application/services/trace_service.py` - **Lines 22 and 39** ### Steps to Reproduce 1. Open `src/cleveragents/application/services/trace_service.py` 2. Observe `import logging` on line 22 and `logger = logging.getLogger(__name__)` on line 39 3. Compare with `audit_service.py` (same directory) which correctly uses `import structlog` and `_logger = structlog.get_logger(__name__)` ### Fix Required Replace: ```python import logging ... logger = logging.getLogger(__name__) ``` With: ```python import structlog ... _logger = structlog.get_logger(__name__) ``` And update all `logger.debug(...)` / `logger.warning(...)` calls to use structlog's keyword-argument style: ```python _logger.debug("trace_recorded", trace_id=trace.trace_id, plan_id=trace.plan_id) _logger.warning("langsmith_forward_failed", trace_id=trace.trace_id, exc_info=True) ``` --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-uat-tester
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#3761
No description provided.