Skip to content

Standardize structured logging on slog across all services #43

@haasonsaas

Description

@haasonsaas

Problem

Logging is fragmented across 3 libraries with no standard:

Logger Services
log.Printf() (unstructured) identity, keys, memory, meter, audit, registry
log/slog (structured) llm-gateway, prompts, parker, service-runtime
zerolog (structured) gate

Six services use the standard library's log package — unstructured text to stderr. In production this means:

  • Can't filter by log level
  • Can't search by structured field (org ID, request ID, user ID)
  • Can't correlate logs across requests
  • Log aggregation tools (Loki, CloudWatch, etc.) can't parse them

Proposal

  1. Standardize on log/slog (stdlib, no extra dependency, already used by 4 services + service-runtime)
  2. Provide a NewLogger() factory in service-runtime that configures:
    • JSON handler in production (ENVIRONMENT=production)
    • Text handler in development
    • Default attributes: service name, version, environment
  3. Require request-scoped logging via middleware that injects request ID, org ID, and actor into the slog context
  4. Migrate gate from zerolog to slog (or accept the divergence — gate is already structured)

Migration path

  • service-runtime already has slog primitives in observability/logging.go
  • Replace log.Printf()slog.Info() / slog.Error() with structured fields
  • Each service migration is a small PR (mostly find-and-replace)

Services to migrate

  • identity
  • keys
  • memory
  • meter
  • audit
  • registry
  • gate (optional — already structured via zerolog)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions