hyperdx/packages/api/src/tasks
Warren 348a4044e8
migration: migrate to Pino (logger) (#1269)
Summary

  Migrates the HyperDX API and related services from Winston to Pino for standardized,
  faster, and more structured logging with improved OpenTelemetry integration.

Changes

  Core Migration

  - Replaced Winston with Pino across all logging infrastructure
  - Upgraded @hyperdx/node-opentelemetry from v0.8.2 to v0.9.0 to support Pino
  transport
  - Removed deprecated dependencies:
    - winston and express-winston
    - @opentelemetry/host-metrics and @opentelemetry/sdk-metrics (consolidated into
  newer OTel SDK)
  - Added new dependencies:
    - pino and pino-http for core logging
    - pino-pretty for development console output

  Logger Configuration (packages/api/src/utils/logger.ts)

  Production:
  - Outputs stringified JSON to stdout via pino/file transport
  - Maintains HyperDX transport integration when API key is configured
  - Includes full OpenTelemetry trace context (trace_id, span_id, trace_flags)
 
<img width="830" height="184" alt="Screenshot 2025-10-14 at 4 31 36 PM" src="https://github.com/user-attachments/assets/82e60919-5c4d-4688-a6f5-d54632aef749" />


  Development:
  - Uses pino-pretty for human-readable, colorized console output
  - Hides verbose fields from console: pid, hostname, trace_id, span_id, trace_flags
  - HTTP request/response objects excluded from logs via custom serializers

<img width="825" height="350" alt="image" src="https://github.com/user-attachments/assets/64b293d8-bc95-4715-931a-dbf73483d247" />

  HTTP Logging:
  - Replaced express-winston with pino-http
  - Custom log levels based on HTTP status codes (warn for 4xx, error for 5xx+)
  - Simplified log messages: HTTP {method} {url}

  Error Logging Updates

  Updated error logging patterns throughout the codebase to follow Pino's structured
  logging conventions:

  // Before (Winston)
  logger.error('Error message:', error);

  // After (Pino)
  logger.error({ err: error }, 'Error message');


Ref: HDX-2588

This PR should also address issue: https://github.com/hyperdxio/hyperdx/issues/1035
2025-10-15 17:15:46 +00:00
..
__tests__ feat(alert): allow defining ClickHouse request timeout (#1239) 2025-10-06 17:47:25 +00:00
providers migration: migrate to Pino (logger) (#1269) 2025-10-15 17:15:46 +00:00
checkAlerts.ts migration: migrate to Pino (logger) (#1269) 2025-10-15 17:15:46 +00:00
index.ts migration: migrate to Pino (logger) (#1269) 2025-10-15 17:15:46 +00:00
pingPongTask.ts feat: limit how many tasks are executing at any time (#1103) 2025-08-25 19:01:03 +00:00
template.ts migration: migrate to Pino (logger) (#1269) 2025-10-15 17:15:46 +00:00
tracer.ts chore: Add spans for alert processing (#1219) 2025-09-29 20:20:36 +00:00
types.ts feat(alert): allow defining ClickHouse request timeout (#1239) 2025-10-06 17:47:25 +00:00
usageStats.ts migration: migrate to Pino (logger) (#1269) 2025-10-15 17:15:46 +00:00
util.ts refactor: enable allowing additional alert logic for sass hosting (#1050) 2025-08-06 17:21:42 +00:00