rdev/internal/logging/fields.go
jordan f20fc6c51c
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
feat(saga): implement enterprise-grade resilience architecture
Fixes issues from code review of resilience implementation:

- Wire saga system in main.go (SagaRepository, SagaExecutor, SagaHandler)
- Fix CompletedSteps() to include skipped steps for dependency resolution
- Fix reverse loop bug in saga compensation (use standard swap pattern)
- Add circuit breaker state change callbacks for Prometheus metrics

Phase 1 (Build Resilience):
- Add failure:retry to all component Kaniko build steps
- Add preflight registry health check before builds
- Add services-deployed sync point to decouple docs from critical path

Phase 2 (API Resilience):
- Add pipeline retry endpoint (POST /projects/{id}/pipelines/{number}/retry)
- Wire circuit breakers with metrics callbacks
- Add /health/circuits endpoint for circuit breaker status

Phase 3 (Saga Engine):
- Full domain model (Saga, SagaStep, RetryPolicy, BackoffType)
- PostgreSQL saga repository with CRUD and step management
- Saga executor with retry, compensation, skip step support
- Saga API handlers with CRUD and control operations

Phase 4 (Observability):
- Add saga metrics (total, step_duration, retry, circuit_breaker_state)
- Add logging fields (saga_id, saga_name, step_name)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-08 01:58:02 -07:00

78 lines
2.1 KiB
Go

// Package logging provides enterprise-grade structured logging for rdev.
// It wraps slog with standardized field names, context propagation,
// automatic sensitive data redaction, and per-component log levels.
package logging
// Standard field names for structured logging.
// Using constants ensures consistent field names across the codebase,
// making logs queryable and reducing typos.
const (
// Request/trace context
FieldRequestID = "request_id"
FieldTraceID = "trace_id"
FieldSpanID = "span_id"
// User/auth context
FieldUserID = "user_id"
FieldAPIKeyID = "api_key_id"
FieldAPIKeyTag = "api_key_tag"
// Project context
FieldProjectID = "project_id"
FieldProjectName = "project_name"
// Component identification
FieldComponent = "component"
FieldHandler = "handler"
FieldService = "service"
FieldWorker = "worker"
FieldAdapter = "adapter"
// Operation context
FieldOperation = "operation"
FieldAction = "action"
FieldMethod = "method"
FieldPath = "path"
FieldStatus = "status"
// Error handling - ALWAYS use "error", never "err" or "e"
FieldError = "error"
FieldErrorCode = "error_code"
FieldErrorType = "error_type"
FieldStackTrace = "stack_trace"
// Performance/timing
FieldDuration = "duration_ms"
FieldStartTime = "start_time"
FieldEndTime = "end_time"
FieldRetryCount = "retry_count"
// Resource identifiers
FieldPodName = "pod_name"
FieldNamespace = "namespace"
FieldContainerID = "container_id"
FieldBuildID = "build_id"
FieldDeploymentID = "deployment_id"
FieldWorkID = "work_id"
FieldQueueName = "queue_name"
// HTTP context
FieldHTTPMethod = "http_method"
FieldHTTPPath = "http_path"
FieldHTTPStatus = "http_status"
FieldHTTPRemoteAddr = "http_remote_addr"
FieldHTTPUserAgent = "http_user_agent"
FieldHTTPHost = "http_host"
// Audit context
FieldAuditAction = "audit_action"
FieldAuditResource = "audit_resource"
FieldAuditResult = "audit_result"
FieldAuditDetails = "audit_details"
// Saga context
FieldSagaID = "saga_id"
FieldSagaName = "saga_name"
FieldStepName = "step_name"
)