hyperdx/packages/api
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
..
docs/auto_provision feat: Set up default sources/connections with env var in server mode (#817) 2025-05-16 23:17:37 +00:00
migrations feat: setup clickhouse migration tool + update metrics schema (add is_delta + is_monotonic fields) (#138) 2023-12-03 14:06:50 -08:00
scripts feat: Adds auto openapi doc generation + swagger UI for API (#779) 2025-04-29 17:54:34 +00:00
src migration: migrate to Pino (logger) (#1269) 2025-10-15 17:15:46 +00:00
.Dockerignore first commit 2023-09-12 20:08:05 -07:00
.env.development chart ai assistant (#1243) 2025-10-07 14:47:10 -04:00
.env.test Add ingestion key check to otel collector via OpAMP (#825) 2025-05-23 01:41:35 +00:00
.eslintignore ci: port v1 metric tests - Pt1 (#638) 2025-02-27 08:07:47 +00:00
.eslintrc.js fix: Update tsconfigs to resolve IDE type errors (#1150) 2025-09-11 08:55:14 -04:00
CHANGELOG.md Release HyperDX (#1197) 2025-09-29 16:05:02 -07:00
Dockerfile fix: Update tsconfigs to resolve IDE type errors (#1150) 2025-09-11 08:55:14 -04:00
jest.config.js ci: port v1 metric tests - Pt1 (#638) 2025-02-27 08:07:47 +00:00
jest.setup.ts ci: port v1 metric tests - Pt1 (#638) 2025-02-27 08:07:47 +00:00
migrate-mongo-config.ts feat: setup clickhouse migration tool + update metrics schema (add is_delta + is_monotonic fields) (#138) 2023-12-03 14:06:50 -08:00
package.json migration: migrate to Pino (logger) (#1269) 2025-10-15 17:15:46 +00:00
tsconfig.build.json fix: Update tsconfigs to resolve IDE type errors (#1150) 2025-09-11 08:55:14 -04:00
tsconfig.json Add copy-to-clipboard buttons in RawLogTable for log line data and URLs (#1227) 2025-10-10 15:50:34 +01:00