Skip to content
This repository was archived by the owner on Jun 29, 2026. It is now read-only.

feat: API monitoring - #49

Merged
polyipseity merged 8 commits into
mainfrom
feat/api-monitoring
Mar 4, 2026
Merged

feat: API monitoring#49
polyipseity merged 8 commits into
mainfrom
feat/api-monitoring

Conversation

@wylited

Copy link
Copy Markdown
Member

How this monitoring system will work is that each API service will expose a fastify-metrics endpoint at /metrics, which requires a prometheus key to access.
this is a Prometheus scrapable endpoint for our monitoring platform.

Furthermore, if provided, it will fastify will log automatically to a Loki logging server using pino-loki.

The rest of the setup for monitoring will be done on the usthing server.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds API monitoring capabilities to the template API service by integrating Prometheus metrics collection via fastify-metrics and optional Loki logging via pino-loki. The metrics endpoint can be optionally protected with a bearer token for security.

Changes:

  • Added fastify-metrics and pino-loki dependencies for monitoring and logging
  • Implemented configurable Loki transport for centralized logging
  • Created /metrics endpoint with optional authentication via PROMETHEUS_KEY
  • Updated test helper to support passing custom options for testing different configurations

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 7 comments.

Show a summary per file
FileDescription
yarn.lockAdded dependencies for fastify-metrics, pino-loki, prom-client, and related packages
package.jsonAdded fastify-metrics and pino-loki to dependencies
src/app.tsImplemented Loki transport configuration, metrics endpoint with optional authentication
test/helper.tsModified build function to accept optional AppOptions for flexible testing
test/routes/metrics.test.tsAdded comprehensive tests for metrics endpoint with and without authentication

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadsrc/app.ts Outdated
Comment threadtest/routes/metrics.test.ts
Comment threadtest/routes/metrics.test.ts
Comment threadsrc/app.ts
Comment threadsrc/app.ts
Comment threadsrc/app.ts Outdated
Comment threadsrc/app.ts

@polyipseitypolyipseity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed! Once you address the two minor issues by yourself, you can merge it.

@polyipseity
polyipseity merged commit 0fbe36a into mainMar 4, 2026
9 checks passed
@polyipseity
polyipseity deleted the feat/api-monitoring branch March 4, 2026 13:59
@github-actionsgithub-actionsBot mentioned this pull request Mar 4, 2026
flandia pushed a commit that referenced this pull request Mar 5, 2026
---------
Co-authored-by: William So <polyipseity@gmail.com>
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@wylited@polyipseity