Skip to content

Commit fa93a7f

Browse files
committed
refactor: remove CloudWatch monitoring integration
1 parent da79a4e commit fa93a7f

File tree

13 files changed

+365
-16671
lines changed

13 files changed

+365
-16671
lines changed

Dockerfile

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,7 @@ RUN pnpm install --frozen-lockfile --prod
3838

3939
# Copy built application from builder stage
4040
COPY --from=builder /app/dist ./dist
41-
COPY newrelic.js ./
42-
43-
# Set New Relic environment variables
44-
ENV NEW_RELIC_NO_CONFIG_FILE=false
45-
ENV NEW_RELIC_DISTRIBUTED_TRACING_ENABLED=true
46-
ENV NEW_RELIC_LOG=stdout
47-
ENV NEW_RELIC_LOG_LEVEL=info
41+
# Application configuration complete
4842

4943
# Change ownership to non-root user
5044
RUN chown -R typelets:nodejs /app
@@ -53,9 +47,9 @@ USER typelets
5347
# Expose port
5448
EXPOSE 3000
5549

56-
# Health check
50+
# Health check using new metrics endpoint
5751
HEALTHCHECK --interval=30s --timeout=3s --start-period=30s --retries=3 \
58-
CMD node -e "http.get('http://localhost:3000/', (res) => process.exit(res.statusCode === 200 ? 0 : 1))" || exit 1
52+
CMD node -e "http.get('http://localhost:3000/health', (res) => process.exit(res.statusCode === 200 ? 0 : 1))" || exit 1
5953

6054
# Start the application
6155
CMD ["pnpm", "start"]

README.md

Lines changed: 9 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ The backend API for the [Typelets Application](https://github.com/typelets/typel
2222
-**Fast & Type-Safe** with TypeScript and Hono
2323
- 🐘 **PostgreSQL** with Drizzle ORM
2424
- 💻 **Code Execution** via secure Judge0 API proxy
25-
- 📊 **Performance Monitoring** with New Relic APM
25+
- 📊 **Production Ready** with structured logging and error handling
26+
- 🏥 **Health Checks** with detailed system status and readiness probes
2627

2728
## Tech Stack
2829

@@ -31,7 +32,7 @@ The backend API for the [Typelets Application](https://github.com/typelets/typel
3132
- **Database**: PostgreSQL with [Drizzle ORM](https://orm.drizzle.team/)
3233
- **Authentication**: [Clerk](https://clerk.com/)
3334
- **Validation**: [Zod](https://zod.dev/)
34-
- **Monitoring**: [New Relic](https://newrelic.com/) for APM and error tracking
35+
- **Logging**: Structured console logging for development and production
3536
- **TypeScript**: Strict mode enabled for type safety
3637

3738
## Prerequisites
@@ -41,7 +42,6 @@ The backend API for the [Typelets Application](https://github.com/typelets/typel
4142
- PostgreSQL database (local installation or Docker)
4243
- Clerk account for authentication ([sign up here](https://dashboard.clerk.com))
4344
- Judge0 API key for code execution (optional - [get from RapidAPI](https://rapidapi.com/judge0-official/api/judge0-ce))
44-
- New Relic account for monitoring (optional - [sign up here](https://newrelic.com/signup))
4545

4646
## Local Development Setup
4747

@@ -77,16 +77,13 @@ cp .env.example .env
7777
- Create a free account at [Clerk Dashboard](https://dashboard.clerk.com)
7878
- Create a new application
7979
- (Optional) Get Judge0 API key from [RapidAPI](https://rapidapi.com/judge0-official/api/judge0-ce)
80-
- (Optional) Get New Relic license key from [New Relic Dashboard](https://one.newrelic.com/launcher/api-keys-ui.api-keys-launcher)
8180
- Update `.env` with your settings:
8281

8382
```env
8483
CLERK_SECRET_KEY=sk_test_your_actual_clerk_secret_key_from_dashboard
8584
CORS_ORIGINS=http://localhost:5173,http://localhost:3000
8685
# Optional: For code execution features
8786
JUDGE0_API_KEY=your_judge0_rapidapi_key_here
88-
# Optional: For performance monitoring and error tracking
89-
NEW_RELIC_LICENSE_KEY=your_new_relic_license_key_here
9087
```
9188

9289
5. **Set up database schema:**
@@ -169,7 +166,10 @@ If you prefer to install PostgreSQL locally instead of Docker:
169166
### Public Endpoints
170167

171168
- `GET /` - API information and health status
172-
- `GET /health` - Health check endpoint
169+
- `GET /health` - Enhanced health check with system status
170+
- `GET /metrics` - System metrics for monitoring dashboards
171+
- `GET /ready` - Readiness probe for container orchestration
172+
- `GET /live` - Liveness probe for container orchestration
173173
- `GET /websocket/status` - WebSocket server status and statistics
174174

175175
### Authentication
@@ -261,53 +261,6 @@ The application uses the following main tables:
261261
- **WebSocket Security**: JWT authentication, rate limiting, and connection limits
262262
- **Real-time Authorization**: Database-level ownership validation for all WebSocket operations
263263

264-
## Performance Monitoring
265-
266-
The API includes comprehensive monitoring via New Relic APM for production observability and performance optimization.
267-
268-
### Monitoring Features
269-
270-
- **Application Performance Monitoring (APM)**: Real-time performance metrics for HTTP requests, database queries, and external API calls
271-
- **Error Tracking**: Automatic error detection and alerting with detailed stack traces
272-
- **Custom Events**: Application startup, user authentication, and business logic events
273-
- **Transaction Tracing**: Detailed breakdown of slow requests and database operations
274-
- **Infrastructure Monitoring**: Server resources, memory usage, and system health
275-
276-
### Environment-Specific Monitoring
277-
278-
**Development Environment:**
279-
- App Name: `typelets-api-dev`
280-
- Debug-level logging with detailed instrumentation
281-
- Lower performance thresholds for early issue detection
282-
- Enhanced error collection and context
283-
284-
**Production Environment:**
285-
- App Name: `typelets-api-prod`
286-
- Optimized logging for performance
287-
- High-security mode with sensitive data filtering
288-
- Production-tuned sampling rates
289-
290-
### Monitored Operations
291-
292-
- **HTTP Requests**: All API endpoints with response times and status codes
293-
- **Database Queries**: PostgreSQL operations with query performance tracking
294-
- **External APIs**: Judge0 API calls with latency and error monitoring
295-
- **WebSocket Operations**: Real-time connection management and message processing
296-
- **File Operations**: Upload/download performance and error tracking
297-
298-
### New Relic Dashboard Access
299-
300-
Once configured, monitor your application at:
301-
- Development: Search for `typelets-api-dev` in your New Relic dashboard
302-
- Production: Search for `typelets-api-prod` in your New Relic dashboard
303-
304-
### Custom Monitoring
305-
306-
The application sends custom events for business intelligence:
307-
- `ApplicationStartup`: Server initialization with configuration details
308-
- User authentication events with performance metrics
309-
- Slow operation alerts (configurable thresholds)
310-
- Resource usage patterns and scaling indicators
311264

312265
## Environment Variables
313266

@@ -328,13 +281,9 @@ The application sends custom events for business intelligence:
328281
| `WS_MAX_CONNECTIONS_PER_USER`| Max WebSocket connections per user | No | 20 |
329282
| `WS_AUTH_TIMEOUT_MS` | WebSocket authentication timeout in milliseconds | No | 30000 (30 sec) |
330283
| `JUDGE0_API_KEY` | Judge0 API key for code execution | No* | - |
331-
| `NEW_RELIC_LICENSE_KEY` | New Relic license key for APM monitoring | No** | - |
332-
| `NEW_RELIC_APP_NAME` | Custom New Relic application name | No | Auto-generated |
333-
| `NEW_RELIC_LOG` | New Relic log output (stdout/stderr/filepath) | No | stdout (dev) / file (prod) |
334-
| `NEW_RELIC_LOG_LEVEL` | New Relic logging level (error/warn/info/debug/trace) | No | debug (dev) / info (prod) |
284+
| `LOG_LEVEL` | Logging level (error/warn/info/debug) | No | info (prod), debug (dev) |
335285

336286
*Required only for code execution features
337-
**Required only for performance monitoring and error tracking
338287

339288
## Development
340289

@@ -394,10 +343,8 @@ docker build -t typelets-api .
394343
# 3. Run API container for local testing
395344
docker run -p 3000:3000 --env-file .env typelets-api
396345

397-
# Or with explicit New Relic configuration
346+
# Run with environment file
398347
docker run -p 3000:3000 \
399-
-e NEW_RELIC_LICENSE_KEY=your_license_key_here \
400-
-e NEW_RELIC_APP_NAME="typelets-api-dev" \
401348
-e NODE_ENV=development \
402349
--env-file .env \
403350
typelets-api
@@ -434,24 +381,6 @@ This application is designed for production deployment using AWS ECS (Elastic Co
434381

435382
For production deployment, configure the same environment variables in your ECS task definition that you use locally in `.env`.
436383

437-
### Production Monitoring Setup
438-
439-
For production deployments, ensure New Relic monitoring is properly configured:
440-
441-
```bash
442-
# Example production environment variables in ECS task definition
443-
NODE_ENV=production
444-
NEW_RELIC_LICENSE_KEY=your_production_license_key
445-
NEW_RELIC_APP_NAME=typelets-api-prod
446-
NEW_RELIC_LOG=stdout
447-
NEW_RELIC_LOG_LEVEL=info
448-
```
449-
450-
This will automatically:
451-
- Enable production-optimized monitoring settings
452-
- Filter sensitive data from logs and traces
453-
- Set appropriate sampling rates for production scale
454-
- Create separate application monitoring (dev vs prod)
455384

456385
## Contributing
457386

newrelic.js

Lines changed: 0 additions & 104 deletions
This file was deleted.

0 commit comments

Comments
 (0)