Skip to content

Commit 3912fcd

Browse files
Merge pull request #64 from Code-Paragon/feature/metrics
feat: metrics endpoint for monitoring
2 parents c26c2c2 + 257541b commit 3912fcd

6 files changed

Lines changed: 561 additions & 1786 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ dist
66
.env.*
77
*.log
88

9+
/.idea
10+
911
# Database
1012
database.db
1113
database.db-*

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,27 @@ API gateway, usage metering, and billing services for the Callora API marketplac
2020

2121
## Vault repository behavior
2222

23+
<<<<<<< HEAD
24+
Endpoint:
25+
26+
`GET /api/developers/analytics`
27+
28+
Authentication:
29+
30+
- Requires `x-user-id` header (developer identity for now).
31+
32+
Query params:
33+
34+
- `from` (required): ISO date/time
35+
- `to` (required): ISO date/time
36+
- `groupBy` (optional): `day | week | month` (default: `day`)
37+
- `apiId` (optional): filters to one API (must belong to authenticated developer)
38+
- `includeTop` (optional): set to `true` to include `topEndpoints` and anonymized `topUsers`
39+
=======
2340
- Enforces one vault per user per network.
2441
- `balanceSnapshot` is stored in smallest units using non-negative integer `bigint` values.
2542
- `findByUserId` is network-aware and returns the vault for a specific user/network pair.
43+
>>>>>>> main
2644
2745
## Local setup
2846

@@ -34,8 +52,21 @@ API gateway, usage metering, and billing services for the Callora API marketplac
3452
npm install
3553
npm run dev
3654
```
55+
<<<<<<< HEAD
56+
57+
3. API base: `http://localhost:3000`
58+
### Docker Setup
59+
60+
You can run the entire stack (API and PostgreSQL) locally using Docker Compose:
61+
62+
```bash
63+
docker compose up --build
64+
```
65+
The API will be available at http://localhost:3000, and the PostgreSQL database will be mapped to local port 5432.
66+
=======
3767

3868
3. API base: [http://localhost:3000](http://localhost:3000). Example: [http://localhost:3000/api/health](http://localhost:3000/api/health).
69+
>>>>>>> main
3970
4071
## Scripts
4172

@@ -47,6 +78,15 @@ API gateway, usage metering, and billing services for the Callora API marketplac
4778
| `npm test` | Run unit tests |
4879
| `npm run test:coverage` | Run unit tests with coverage |
4980

81+
### Observability (Prometheus Metrics)
82+
83+
The application exposes a standard Prometheus text-format metrics endpoint at `GET /api/metrics`.
84+
It automatically tracks `http_requests_total`, `http_request_duration_seconds`, and default Node.js system metrics.
85+
86+
#### Production Security:
87+
In production (NODE_ENV=production), this endpoint is protected. You must configure the METRICS_API_KEY environment variable and scrape the endpoint using an authorization header:
88+
Authorization: Bearer <YOUR_METRICS_API_KEY>
89+
5090
## Project layout
5191

5292
```text
@@ -62,6 +102,12 @@ callora-backend/
62102

63103
## Environment
64104

105+
<<<<<<< HEAD
106+
- `PORT` — HTTP port (default: 3000). Optional for local dev.
107+
108+
This repo is part of [Callora](https://github.com/your-org/callora). Frontend: `callora-frontend`. Contracts: `callora-contracts`.
109+
=======
65110
- `PORT` - HTTP port (default: 3000). Optional for local dev.
66111

67112
This repo is part of [Callora](https://github.com/your-org/callora). Frontend: `callora-frontend`. Contracts: `callora-contracts`.
113+
>>>>>>> main

0 commit comments

Comments
 (0)