Skip to content

Commit 121aa2f

Browse files
committed
feat: OpenTelemetry support
1 parent deede2b commit 121aa2f

10 files changed

Lines changed: 4301 additions & 1604 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,5 @@ vite.config.ts.timestamp-*
143143
.vscode
144144
/nginx.conf
145145
docker-compose-override.yml
146-
.vercel
146+
.vercel
147+
docker-compose.test.yml

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ dashboard.
4242
![Docker](https://img.shields.io/badge/Docker-2496ED.svg?style=for-the-badge&logo=docker&logoColor=white)
4343
![Redis](https://img.shields.io/badge/Redis-%23DC382D.svg?style=for-the-badge&logo=redis&logoColor=white)
4444
![React Hook Form](https://img.shields.io/badge/React%20Hook%20Form-%23EC5990.svg?style=for-the-badge&logo=reacthookform&logoColor=white)
45+
![OpenTelemetry](https://img.shields.io/badge/OpenTelemetry-FFFFFF?&style=for-the-badge&logo=opentelemetry&logoColor=black)
4546
![Grafana](https://img.shields.io/badge/Grafana-%23F46800.svg?style=for-the-badge&logo=grafana&logoColor=white)
47+
![Loki](https://img.shields.io/badge/Loki-F46800.svg?style=for-the-badge&logo=grafana&logoColor=white)
48+
![Tempo](https://img.shields.io/badge/Tempo-4B9E5F.svg?style=for-the-badge&logo=grafana&logoColor=white)
4649
![Prometheus](https://img.shields.io/badge/Prometheus-%23E6522C.svg?style=for-the-badge&logo=prometheus&logoColor=white)
4750
![Vitest](https://img.shields.io/badge/Vitest-%23E6522C.svg?style=for-the-badge&logo=vitest&logoColor=white)
4851

@@ -57,7 +60,6 @@ dashboard.
5760
> ️ Before you start, make sure you have the following installed:
5861
>
5962
> - [pnpm](https://pnpm.io/installation) (package manager used in this project)
60-
> - [TypeScript](https://www.typescriptlang.org/download) (`tsc` compiler)
6163
6264
### 1. Clone the repository
6365

backend/.env.example

Lines changed: 54 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,54 @@
1-
# ========================================
2-
# REQUIRED CONFIG
3-
# ========================================
4-
5-
# MongoDB URI (Required — without this the backend won’t run)
6-
MONGO_DB_URI=mongodb://localhost:27017/cronjob-scheduler
7-
8-
# REDIS CONFIGURATION
9-
REDIS_URL=redis://localhost:6379
10-
11-
# ========================================
12-
# OPTIONAL CONFIG (only needed if you’re testing these features or Deploying)
13-
# ========================================
14-
15-
# MongoDB collection name for Agenda.js
16-
MONGO_DB_COLLECTION=agendaJobs
17-
18-
# JWT secret for authentication
19-
JWT_SECRET=dev_secret_key
20-
21-
# Frontend URL (adjust if you’re not using frontend)
22-
CLIENT_URL=http://localhost:5173
23-
24-
# Port for backend server
25-
PORT=3000
26-
27-
# Google OAuth (required only if working on Google login)
28-
GOOGLE_CLIENT_ID=GOOGLE_CLIENT_ID
29-
GOOGLE_CLIENT_SECRET=GOOGLE_CLIENT_SECRET
30-
GOOGLE_CALLBACK_URL=http://localhost:3000/auth/google/callback
31-
32-
# Enable/disable email service (false by default for contributors)
33-
ENABLE_EMAIL_SERVICE=false
34-
35-
# Email service URL (only if email-service is running locally/public)
36-
EMAIL_SERVICE_URL=http://localhost:3001
37-
38-
# Email service secret (must match email-service if enabled)
39-
EMAIL_SERVICE_SECRET=EMAIL_SERVICE_SECRET
40-
41-
# Qstash token (only if working with email queueing)
42-
QSTASH_TOKEN=QSTASH_TOKEN
43-
44-
# PROMETHEUS SECRET
45-
PROMETHEUS_SECRET=PROMETHEUS_SECRET
46-
47-
# APP_JOB_NAME (to differentiate prom-clients)
48-
APP_JOB_NAME=runner
1+
# ========================================
2+
# REQUIRED CONFIG
3+
# ========================================
4+
5+
# MongoDB URI (Required — without this the backend won’t run)
6+
MONGO_DB_URI=mongodb://localhost:27017/cronjob-scheduler
7+
8+
# REDIS CONFIGURATION
9+
REDIS_URL=redis://localhost:6379
10+
11+
# ========================================
12+
# OPTIONAL CONFIG (only needed if you’re testing these features or Deploying)
13+
# ========================================
14+
15+
# MongoDB collection name for Agenda.js
16+
MONGO_DB_COLLECTION=agendaJobs
17+
18+
# JWT secret for authentication
19+
JWT_SECRET=dev_secret_key
20+
21+
# Frontend URL (adjust if you’re not using frontend)
22+
CLIENT_URL=http://localhost:5173
23+
24+
# Port for backend server
25+
PORT=3000
26+
27+
# Google OAuth (required only if working on Google login)
28+
GOOGLE_CLIENT_ID=GOOGLE_CLIENT_ID
29+
GOOGLE_CLIENT_SECRET=GOOGLE_CLIENT_SECRET
30+
GOOGLE_CALLBACK_URL=http://localhost:3000/auth/google/callback
31+
32+
# Enable/disable email service (false by default for contributors)
33+
ENABLE_EMAIL_SERVICE=false
34+
35+
# Email service URL (only if email-service is running locally/public)
36+
EMAIL_SERVICE_URL=http://localhost:3001
37+
38+
# Email service secret (must match email-service if enabled)
39+
EMAIL_SERVICE_SECRET=EMAIL_SERVICE_SECRET
40+
41+
# Qstash token (only if working with email queueing)
42+
QSTASH_TOKEN=QSTASH_TOKEN
43+
44+
# PROMETHEUS SECRET
45+
PROMETHEUS_SECRET=PROMETHEUS_SECRET
46+
47+
# APP_JOB_NAME (to differentiate prom-clients)
48+
APP_JOB_NAME=runner
49+
50+
# OPENTELEMETRY TRACING CONFIGURATION
51+
OTEL_TRACING_ENABLED=true
52+
OTEL_SERVICE_NAME=cronjob-backend
53+
OTEL_TRACES_EXPORTER=otlp
54+
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318

backend/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ FROM node:${NODE_VERSION}-alpine AS base
77
WORKDIR /usr/src/app
88

99
# =================== deps stage ============================================
10-
FROM base as deps
10+
FROM base AS deps
1111

1212
RUN --mount=type=cache,target=/root/.npm \
1313
npm install -g pnpm@${PNPM_VERSION}
@@ -18,7 +18,7 @@ RUN --mount=type=bind,source=package.json,target=package.json \
1818
pnpm install --prod --frozen-lockfile
1919

2020
# =================== build stage ============================================
21-
FROM deps as build
21+
FROM deps AS build
2222

2323
RUN --mount=type=bind,source=package.json,target=package.json \
2424
--mount=type=bind,source=pnpm-lock.yaml,target=pnpm-lock.yaml \
@@ -29,7 +29,7 @@ COPY . .
2929
RUN pnpm run build
3030

3131
# =================== final stage ============================================
32-
FROM base as final
32+
FROM base AS final
3333

3434
ENV NODE_ENV production
3535

backend/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"start": "node --env-file=.env ./dist/src/server.js",
99
"watch": "tsc -w",
1010
"build": "tsc -p tsconfig.build.json",
11-
"dev": "concurrently \"tsc -w\" \"node --watch ./dist/src/server.js\"",
11+
"dev": "concurrently \"tsc -w\" \"node --watch --env-file=.env ./dist/src/server.js\"",
1212
"bun": "bun ./src/server.ts",
1313
"bun watch": "bun --watch ./src/server.ts",
1414
"test": "vitest run"
@@ -17,6 +17,10 @@
1717
"license": "MIT",
1818
"packageManager": "pnpm@10.32.1",
1919
"dependencies": {
20+
"@opentelemetry/api": "^1.9.1",
21+
"@opentelemetry/auto-instrumentations-node": "^0.78.0",
22+
"@opentelemetry/exporter-trace-otlp-http": "^0.220.0",
23+
"@opentelemetry/sdk-node": "^0.220.0",
2024
"agenda": "^5.0.0",
2125
"bcrypt": "^6.0.0",
2226
"cookie-parser": "^1.4.7",
@@ -48,7 +52,7 @@
4852
"mockingoose": "^3.0.0",
4953
"pino-pretty": "^13.1.1",
5054
"supertest": "^7.2.2",
51-
"typescript": "^5.9.2",
55+
"typescript": "^7.0.2",
5256
"vitest": "^4.1.0"
5357
}
5458
}

0 commit comments

Comments
 (0)