๐ Production Monitoring & Bug Tracing Guide
This guide details how to monitor system health, trace logs across microservice components, inspect production data, and diagnose bugs in the live InventoryAlert production environment on Render.
๐ 1. Live Production Endpointsโ
| Service / Interface | Production Link | Purpose |
|---|---|---|
| API Host | https://inventorymanagementsystem-s55e.onrender.com | Base production API host |
| Swagger UI | https://inventorymanagementsystem-s55e.onrender.com/swagger | Interactive API testing & endpoint documentation |
| Scalar Docs | https://inventorymanagementsystem-s55e.onrender.com/scalar/v1 | Searchable OpenAPI specification |
| Health Check | https://inventorymanagementsystem-s55e.onrender.com/healthz | System health probe (returns Healthy HTTP 200) |
| AWS Moto Proxy | https://inventorymanagementsystem-s55e.onrender.com/aws | Public endpoint proxying requests to internal Moto SQS/DynamoDB |
๐ 2. System Health Monitoringโ
Health Check Endpoint (/healthz)โ
- URL:
https://inventorymanagementsystem-s55e.onrender.com/healthz - Method:
GET - Response:
200 OKwith JSON payload indicating system status:{"status": "Healthy","totalDuration": "00:00:00.0123000","entries": {"postgresql": { "status": "Healthy" },"redis": { "status": "Healthy" }}} - Automated Uptime Monitoring: A background
KeepAliveJobperiodically pings/healthzto prevent free-tier container sleep.
๐งต 3. Log Tracing & Correlation IDsโ
Distributed Tracing Headerโ
Every request processed by the API host is stamped with a unique Correlation ID:
- HTTP Header:
X-Correlation-ID - Log Property:
CorrelationId
If a client sends an X-Correlation-ID header, the system retains it. Otherwise, middleware generates a new Guid for the request lifecycle.
Log Format & Serilog Setupโ
In production, stdout emits structured JSON logs formatted with Serilog:
{
"@t": "2026-08-13T13:00:00.1234567Z",
"@l": "Error",
"@mt": "Unhandled exception occurred while processing request {RequestPath}",
"CorrelationId": "c8a1e2f3-4b5c-6d7e-8f90-1a2b3c4d5e6f",
"SourceContext": "InventoryAlert.Api.Middleware.GlobalExceptionHandler",
"RequestPath": "/api/v1/portfolio/positions",
"Exception": "System.InvalidOperationException: ..."
}
Request & Response Body Loggingโ
Production environment has Api__EnableBodyLogging=true enabled:
- Request payloads (JSON bodies) are recorded under log property
RequestBodyfor HTTP POST/PUT operations. - Allows immediate verification of exact payload submitted during error investigation.
๐ 4. Step-by-Step Production Bug Diagnosis Runbookโ
Step 1: Obtain Correlation ID or Timestampโ
When a user reports an issue or an HTTP 500 error occurs:
- Check the response body returned to the client (RFC 7807
ProblemDetailscontainstraceId/correlationId). - If unknown, note the exact timestamp (UTC) and endpoint path (
e.g., POST /api/v1/alert-rules).
Step 2: Query Container Logs on Renderโ
- Open the Render Dashboard for
inventorymanagementsystem-s55e. - Filter logs by log level:
ErrororWarning. - Search for the specific
CorrelationIdto view the full request-response lifecycle across API handlers and background workers.
Step 3: Local Log Viewer with Seq (Docker)โ
To analyze production logs locally in Seq (http://localhost:5341):
- In Seq search bar, filter by Correlation ID:
CorrelationId = 'c8a1e2f3-4b5c-6d7e-8f90-1a2b3c4d5e6f'
- Filter for uncaught errors:
@Level = 'Error' or @Level = 'Fatal'
- Filter by component context:
SourceContext like '%Worker%' or SourceContext like '%StockDataService%'
Step 4: DynamoDB Data Tracing via dynamodb-adminโ
To inspect news read models and DynamoDB items in production:
- Execute
dynamodb-adminlocally pointing to the Render Moto proxy:DYNAMO_ENDPOINT=https://inventorymanagementsystem-s55e.onrender.com/aws npx dynamodb-admin - Open
http://localhost:8001to view live tables:inventoryalert-market-newsinventoryalert-company-news
โ๏ธ 5. Monitoring Background Workers & Hangfireโ
- Worker Process: Managed by Supervisord alongside API host inside the container (
InventoryAlert.Worker). - Hangfire Job Execution:
SyncPricesJob: Syncs Finnhub stock quotes every 30 minutes.ProcessQueueJob: Continuous SQS polling loop for alert evaluations.SyncCompanyNewsJob&SyncMarketNewsJob: Background fetchers for DynamoDB news entries.
- Failures & Retries: Hangfire automatically retries failed jobs up to 10 times with exponential backoff. Failed job details are logged under
Hangfire.AutomaticRetryAttribute.
๐ ๏ธ 6. Quick Troubleshooting Matrixโ
| Symptom | Probable Cause | Action |
|---|---|---|
| HTTP 500 on API request | Unhandled exception in application logic | Search Render logs for CorrelationId & review stack trace |
| HTTP 401 Unauthorized | Missing or expired JWT Token | Re-authenticate via POST /api/v1/auth/login |
| Prices not updating | Finnhub rate limit or worker error | Check worker logs for Finnhub:ApiKey limits or SyncPricesJob status |
| DynamoDB empty/unreachable | Proxy endpoint mismatch | Verify DYNAMO_ENDPOINT=https://inventorymanagementsystem-s55e.onrender.com/aws |
| Neon PostgreSQL connection drop | SSL mode requirement or connection pool exhaustion | Confirm sslmode=require in connection string |