Skip to content

feat: yield expiry, bulk epochs endpoint, and OpenTelemetry tracing - #897

Merged
Jayy4rl merged 2 commits into
StellarYield:mainfrom
Gbangbolaoluwagbemiga:fix/issues-823-824-825-826
Jul 26, 2026
Merged

feat: yield expiry, bulk epochs endpoint, and OpenTelemetry tracing#897
Jayy4rl merged 2 commits into
StellarYield:mainfrom
Gbangbolaoluwagbemiga:fix/issues-823-824-825-826

Conversation

@Gbangbolaoluwagbemiga

Copy link
Copy Markdown
Contributor

Summary

Resolves four assigned issues across epoch data management and observability.

#823 — Track unclaimed yield expiry per epoch

  • Added migration 029_epoch_expiry.sql: nullable expires_at TIMESTAMPTZ column on epochs
  • YIELD_CLAIM_EXPIRY_DAYS env var (optional, default null = never expires) added to config
  • recordEpoch() calculates and stores expires_at when the env var is set
  • getUserPendingYield() query filters expires_at > NOW() so expired epochs never appear in pending yield

#824 — Add bulk epoch data endpoint

  • YieldService.getEpochsBulk(contractId, from, to) returns epochs in the inclusive range
  • GET /api/v1/yields/:contractId/epochs/bulk?from=<epoch>&to=<epoch> — no pagination, single response
  • Returns HTTP 400 when to - from > 500 or params are invalid; from must be ≤ to
  • Each entry includes yieldAmount, totalShares, yieldPerShare, distributedAt

#825 — Add OpenTelemetry tracing to Express middleware

  • Added @opentelemetry/sdk-node, @opentelemetry/auto-instrumentations-node, @opentelemetry/api, and @opentelemetry/exporter-trace-otlp-http to dependencies
  • src/instrumentation.ts initialises the OTel SDK; exports traces to OTLP when OTEL_EXPORTER_OTLP_ENDPOINT is set, no-ops when absent
  • Imported as the first line of src/index.ts so all auto-instrumentation patches apply before any other module loads

#826 — Add trace context propagation to DB queries

  • query() in db/index.ts now wraps every SQL call in a db.query child span
  • Span attributes: db.statement (first 80 chars of SQL) and db.response.rows
  • Span is attached to context.active() so it appears as a child of the current HTTP request span
  • Errors are recorded on the span and re-thrown; span always ends in finally

Closes #823
Closes #824
Closes #825
Closes #826

…, OTel tracing (StellarYield#825, StellarYield#826)

StellarYield#823 — Track unclaimed yield expiry per epoch
- Migration 029_epoch_expiry.sql adds nullable expires_at to epochs
- YIELD_CLAIM_EXPIRY_DAYS env var (null = never expires) wired through config
- recordEpoch() populates expires_at from the env var when set
- getUserPendingYield() filters out expired epochs via expires_at > NOW()

StellarYield#824 — Bulk epoch data endpoint
- YieldService.getEpochsBulk() returns epochs in an inclusive [from, to] range
- GET /api/v1/yields/:contractId/epochs/bulk?from=&to= returns up to 500 epochs
- Returns HTTP 400 when the range exceeds 500 or params are invalid

StellarYield#825 — OpenTelemetry tracing for Express
- Added @opentelemetry/sdk-node and auto-instrumentations-node packages
- src/instrumentation.ts initialises the OTel SDK; exports to OTLP when
  OTEL_EXPORTER_OTLP_ENDPOINT is set, no-ops otherwise
- Imported as first line of src/index.ts so all auto-instrumentation hooks fire

StellarYield#826 — Trace context propagation to DB queries
- query() in db/index.ts now opens a child db.query span with db.statement
  and db.response.rows attributes, attached to the active trace context
- Span is ended (and error-marked on throw) in a finally block
@drips-wave

drips-wave Bot commented Jul 25, 2026

Copy link
Copy Markdown

@Gbangbolaoluwagbemiga 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

@Jayy4rl
Jayy4rl merged commit 609b699 into StellarYield:main Jul 26, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants