Skip to content

feat: observability metrics and live vote tallies (#382, #364)#397

Merged
overprodigy merged 2 commits into
Iris-IV:mainfrom
testersweb0-bug:feat/observability-and-live-votes
May 29, 2026
Merged

feat: observability metrics and live vote tallies (#382, #364)#397
overprodigy merged 2 commits into
Iris-IV:mainfrom
testersweb0-bug:feat/observability-and-live-votes

Conversation

@testersweb0-bug
Copy link
Copy Markdown
Contributor

Summary

Closes #382 and #364

  • Observability ([Observability] Add structured logging + metrics for RPC and transaction failures #382): Emit structured events for every contract error code, simulation failure, submission failure, confirmation timeout, and RPC error. Events are logged as JSON, posted to /api/observability/events for aggregation, and optionally forwarded to an external webhook. The admin observability dashboard visualizes rolling failure rates and surfaces alerts when thresholds are exceeded.
  • Live vote tallies ([Feature] Live vote tallies via campaign_vote_cast events #364): Poll Soroban campaign_vote_cast events on campaign detail and increment approve/reject counts without refetching the full campaign. Quorum and approval-threshold progress in VotingComponent recompute from live props. Falls back to on-chain vote getter polling when event streaming is unavailable.

Changes

Area Files
Observability core src/lib/observability/*
Contract instrumentation src/lib/contractClient.ts
API src/app/api/observability/events/route.ts, metrics/route.ts
Admin dashboard src/components/admin/ObservabilityDashboard.tsx, src/app/[locale]/admin/observability/page.tsx
Live votes src/lib/sorobanEvents.ts, src/hooks/useCampaignVoteEvents.ts, src/hooks/useLiveVoteTallies.ts
Detail page src/app/[locale]/causes/[id]/CauseDetailClient.tsx
Config .env.example
Tests observability.test.ts, sorobanEvents.test.ts, useLiveVoteTallies.test.tsx

How it works

Observability

  1. Any Soroban RPC or transaction failure in contractClient calls recordObservabilityFailure / recordObservabilityKind.
  2. Successful transactions emit transaction_success for rate denominators.
  3. The browser POSTs events to /api/observability/events; the server keeps a rolling buffer and computes 5-minute rates.
  4. GET /api/observability/metrics returns counters, rates, active alerts, and recent events.
  5. Admins open Admin → RPC & transaction metrics (/admin/observability) for the dashboard.

Live votes

  1. useLiveVoteTallies loads initial approve/reject counts from get_approve_votes / get_reject_votes.
  2. useCampaignVoteEvents polls getEvents for ("campaign_vote_cast", campaign_id, *) every 5s.
  3. New events increment upvotes or downvotes from the approve: bool payload.
  4. If mocks are enabled or the contract is unset, polling reconciliation runs every 30s instead.

Configuration

NEXT_PUBLIC_USE_MOCKS=false
NEXT_PUBLIC_CONTRACT_ADDRESS=C...

# Live votes
NEXT_PUBLIC_VOTE_EVENTS_POLL_MS=5000
NEXT_PUBLIC_VOTE_TALLIES_POLL_MS=30000

# Observability
NEXT_PUBLIC_OBSERVABILITY_WEBHOOK_URL=          # optional external sink
OBSERVABILITY_ALERT_SIMULATION_FAILURE_RATE=0.15
OBSERVABILITY_ALERT_SUBMISSION_FAILURE_RATE=0.1
OBSERVABILITY_ALERT_RPC_TIMEOUT_RATE=0.2

…IV#364)

Emit structured RPC/transaction failure events with aggregated metrics, alert thresholds, and an admin dashboard. Poll campaign_vote_cast Soroban events on campaign detail with polling fallback for live approve/reject tallies.
@sshdopey
Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 29, 2026

@testersweb0-bug 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

@overprodigy overprodigy linked an issue May 29, 2026 that may be closed by this pull request
3 tasks
@sshdopey
Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@overprodigy overprodigy merged commit d7efb42 into Iris-IV:main May 29, 2026
3 of 8 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

Development

Successfully merging this pull request may close these issues.

[Observability] Add structured logging + metrics for RPC and transaction failures [Feature] Live vote tallies via campaign_vote_cast events

3 participants