Context
Auto-instrumentation (issues #2 and #5) captures HTTP requests and DB queries, but business-level operations need manual spans with domain-specific attributes. This makes traces tell a meaningful story when debugging — you see "auth.login" and "items.create" instead of just "POST /api/v1/login/access-token".
Scope
Backend Manual Spans
Frontend Manual Spans (optional, lower priority)
Span Events
Add span events for significant state transitions:
- Login success/failure
- Item created/updated/deleted
- Validation errors
- Email sent/failed
Example
from opentelemetry import trace
tracer = trace.get_tracer(__name__)
@tracer.start_as_current_span("auth.login")
def login_access_token(session, form_data):
span = trace.get_current_span()
span.set_attribute("user.email", form_data.username)
user = crud.authenticate(session, email=form_data.username, password=form_data.password)
if not user:
span.set_attribute("auth.result", "failure")
span.add_event("login_failed", {"reason": "invalid_credentials"})
raise HTTPException(...)
span.set_attribute("auth.result", "success")
span.add_event("login_succeeded", {"user.id": str(user.id)})
# ...
Acceptance Criteria
Dependencies
Context
Auto-instrumentation (issues #2 and #5) captures HTTP requests and DB queries, but business-level operations need manual spans with domain-specific attributes. This makes traces tell a meaningful story when debugging — you see "auth.login" and "items.create" instead of just "POST /api/v1/login/access-token".
Scope
Backend Manual Spans
backend/app/api/routes/login.pyauth.loginaround authentication logic with attributes:user.email,auth.resultauth.password_recoveryaround password recovery with attribute:recovery.emailbackend/app/api/routes/items.pyitems.createwith attributes:item.title,item.owner_iditems.updatewith attributes:item.id,item.owner_iditems.deletewith attributes:item.idbackend/app/utils.pyemail.sendaround email sending with attributes:email.recipient,email.subjectbackend/app/crud.pydb.operation,db.entity_typeFrontend Manual Spans (optional, lower priority)
Span Events
Add span events for significant state transitions:
Example
Acceptance Criteria
auth.login,items.create)Dependencies