Skip to content

feat(metrics): add Prometheus latency histogram for /api/markets - #869

Merged
greatest0fallt1me merged 2 commits into
Predictify-org:mainfrom
MJ-RWA:feat/prometheus-markets-latency-histogram
Jul 29, 2026
Merged

feat(metrics): add Prometheus latency histogram for /api/markets#869
greatest0fallt1me merged 2 commits into
Predictify-org:mainfrom
MJ-RWA:feat/prometheus-markets-latency-histogram

Conversation

@MJ-RWA

@MJ-RWA MJ-RWA commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds Prometheus request latency instrumentation for the /api/markets endpoint using a prom-client Histogram with explicit buckets and route labels. This improves observability by enabling latency tracking and performance analysis while preserving existing endpoint behavior.

Closes #28

Changes Made

  • Added a Prometheus Histogram for /api/markets request latency.

  • Registered the histogram in the metrics registry using the project's existing metrics infrastructure.

  • Configured explicit latency buckets for accurate request duration measurement.

  • Added route labels (and other standard labels where applicable) to support filtering and aggregation.

  • Instrumented the /api/markets endpoint to record request latency for both successful and failed requests.

  • Prevented duplicate metric registration to ensure compatibility with repeated initialization and test environments.

  • Preserved standardized error handling and existing API behavior.

  • Integrated with the project's structured logging and correlation ID conventions where applicable.

  • Added focused tests covering:

    • Histogram registration
    • Request latency observation
    • Route label assignment
    • Explicit bucket configuration
    • Successful and failed request scenarios
    • Duplicate registration safeguards
  • Updated relevant documentation to describe the new latency metric.

Testing

  • Added unit and integration tests for the latency histogram.
  • Verified metrics are recorded correctly for /api/markets.
  • Confirmed no changes to existing endpoint responses or error handling.
  • Ran the project's linting and test suites successfully.

Notes

This change is fully backward compatible and introduces no API-breaking changes. It adds internal Prometheus latency metrics to improve monitoring and operational visibility for the /api/markets endpoint.

Closes: #602

@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@MJ-RWA Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@greatest0fallt1me
greatest0fallt1me merged commit 2af79d3 into Predictify-org:main Jul 29, 2026
1 check passed
@greatest0fallt1me

Copy link
Copy Markdown
Contributor

Clean PR — merged 🙌

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.

Add prometheus latency histogram for /api/markets [b#028] Off-chain market metadata attachments (URI policy)

2 participants