Skip to content

Add prometheus metics format to worker#271

Merged
Xhristin3 merged 1 commit into
XStreamRollz:mainfrom
Uche44:obs/prometheus-metrics-support
Jun 16, 2026
Merged

Add prometheus metics format to worker#271
Xhristin3 merged 1 commit into
XStreamRollz:mainfrom
Uche44:obs/prometheus-metrics-support

Conversation

@Uche44

@Uche44 Uche44 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Successfully added Prometheus text-based exposition format support to the stream processing worker's metrics endpoint.

##Changes Made
###Stream Processing Worker (xstreamroll-processing)

  • metrics.ts

Updated startMetricsServer to route metric requests to either Prometheus format or JSON based on the URL path (/metrics, /metrics/json, /metrics/prometheus) and the Accept header.

Implemented content negotiation: If the client requests /metrics with Accept: application/json (excluding standard browser wildcard accepts or text/plain), it returns JSON. Otherwise, it defaults to standard Prometheus formatting.

Added # HELP and # TYPE comments to the Prometheus exposition format output.

  • metrics.test.ts

Added a full suite of integration tests for the metrics server.

Used port 0 for test server instantiation to dynamically allocate a free port on the host, avoiding port collisions.

Covered all permutations of request routing, content negotiation headers (Accept), and default response types.

Verification Results
Automated Tests
Ran the full test suite in xstreamroll-processing successfully:
image

@Uche44

Uche44 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

@Xhristin3 please merge

@Xhristin3 Xhristin3 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.

Nice work on this one @Uche44! The content negotiation logic is clean — love how you handled the Accept header edge cases (excluding */* and text/plain from triggering JSON). The Prometheus exposition format includes proper # HELP and # TYPE comments, and the test suite covers all the endpoint permutations + 404 routing. Really thorough. Closes #226 cleanly. 🚀

@Xhristin3 Xhristin3 merged commit 43a52cc into XStreamRollz:main Jun 16, 2026
1 check passed
@Uche44

Uche44 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

Thank you @Xhristin3

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants