Skip to content

Conversation

@typelets
Copy link
Owner

Changes

Removed

  • ❌ New Relic APM dependencies (newrelic, @types/newrelic)
  • newrelic.js configuration file
  • ❌ New Relic initialization in src/server.ts
  • ❌ Environment variables: NEW_RELIC_APP_NAME, NEW_RELIC_LICENSE_KEY, NEW_RELIC_LOG_LEVEL

Added

  • prom-client for Prometheus metrics collection
  • src/lib/prometheus.ts - Comprehensive metrics definitions
  • ✅ Prometheus metrics instrumentation across all services:
    • HTTP: Request counts, duration histograms, status codes
    • WebSocket: Active connections (gauge), message counts by type and direction
    • Database: Query counts and duration by operation and table
    • Cache: Operations, hit/miss rates, operation duration
    • Code Execution: Duration and success rates by language
    • Business Events: Custom event tracking
    • Security Events: Security-related event tracking
    • System Metrics: Node.js memory, CPU, event loop, and GC metrics
  • ✅ Basic Auth protection for /metrics endpoint using METRICS_API_KEY
  • ✅ Grafana setup documentation in README

Modified

  • 🔄 /metrics endpoint now returns Prometheus text format instead of JSON
  • 🔄 /metrics endpoint now requires Basic Auth for security
  • 🔄 src/lib/logger.ts - Replaced New Relic calls with Prometheus metrics
  • 🔄 Updated README.md with Grafana configuration instructions

Available Metrics

All metrics are prefixed with typelets_:

  • typelets_http_requests_total - Total HTTP requests (counter)
  • typelets_http_request_duration_ms - HTTP request duration (histogram)
  • typelets_websocket_connections_total - Active WebSocket connections (gauge)
  • typelets_websocket_messages_total - WebSocket message count (counter)
  • typelets_database_queries_total - Database query count (counter)
  • typelets_database_query_duration_ms - Database query duration (histogram)
  • typelets_cache_operations_total - Cache operations (counter)
  • typelets_cache_hits_total - Cache hit/miss tracking (counter)
  • typelets_code_executions_total - Code execution count (counter)
  • typelets_code_execution_duration_ms - Code execution duration (histogram)
  • typelets_business_events_total - Business events (counter)
  • typelets_security_events_total - Security events (counter)
  • Plus all default Node.js metrics (memory, CPU, event loop, GC)

Testing

  • ✅ Build successful (167.1kb)
  • ✅ All TypeScript errors resolved
  • ✅ Metrics endpoint returns valid Prometheus format
  • ✅ Basic Auth protection working correctly
  • ✅ All instrumentation points verified (HTTP, WebSocket, Database, Cache, Code Execution)

- Remove New Relic APM dependencies and configuration
- Add prom-client for Prometheus metrics collection
- Implement comprehensive metrics across all services:
    - HTTP requests (count, duration, status codes)
    - WebSocket connections and messages (by type and direction)
    - Database queries (count, duration by operation and table)
    - Cache operations (hits, misses, duration)
    - Code execution (duration, success rate by language)
    - Business and security events
    - Node.js system metrics (memory, CPU, event loop)
- Update /metrics endpoint to use Basic Auth for Grafana
- Add METRICS_API_KEY environment variable for authentication
- Update documentation with Grafana setup instructions
@typelets typelets self-assigned this Oct 17, 2025
@typelets typelets merged commit c5b315f into main Oct 17, 2025
4 checks passed
@typelets
Copy link
Owner Author

🎉 This PR is included in version 1.9.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants