Skip to content

feat(backend): add request tracing spans around domain service boundaries#1155

Merged
Devsol-01 merged 4 commits into
Devsol-01:mainfrom
teethaking:main
Jun 30, 2026
Merged

feat(backend): add request tracing spans around domain service boundaries#1155
Devsol-01 merged 4 commits into
Devsol-01:mainfrom
teethaking:main

Conversation

@teethaking

Copy link
Copy Markdown
Contributor

Closes #1097


Summary

Adds distributed tracing spans around the four core domain service boundaries (governance, referrals, savings, and blockchain indexer) so that request flows are fully visible in APM tooling. Spans are added conditionally — only when an APM/tracing context is present — so the change is backward compatible with environments where tracing is not configured.


What changed

Governance Service

  • Wrapped key domain operations in named spans (e.g. proposal creation, vote submission, resolution)
  • Span attributes include operation type, relevant entity IDs, and outcome status

Referrals Service

  • Added spans around referral creation, validation, and reward calculation boundaries
  • Span context propagated correctly across async calls within the service

Savings Service

  • Wrapped deposit, withdrawal, and interest computation operations in spans
  • Span timing captures full domain logic duration, excluding unrelated I/O where possible

Blockchain Indexer

  • Added spans around block processing, event parsing, and database write boundaries
  • Long-running indexer operations are broken into child spans for granular visibility in APM traces

General

  • Span creation is guarded by a check for an active tracing context — if APM is not configured, no spans are created and behavior is unchanged
  • Span naming follows a consistent convention: service.operation (e.g. governance.submitVote, indexer.processBlock)
  • Errors within spans are recorded on the span before re-throwing, so failures are visible in APM alongside their trace

How to verify

  • Run the backend with APM/tracing enabled and trigger operations across each domain service
  • Open the APM dashboard and confirm traces are visible for governance, referrals, savings, and blockchain indexer operations
  • Confirm span names follow the documented service.operation convention
  • Trigger an error in a domain service and confirm the span records the error and is visible in APM
  • Run without APM configured and confirm no errors or behavior changes occur (guard condition works correctly)

Checklist

  • Spans added to governance service boundaries
  • Spans added to referrals service boundaries
  • Spans added to savings service boundaries
  • Spans added to blockchain indexer boundaries
  • Span naming follows consistent service.operation convention
  • Errors recorded on spans before re-throwing
  • Spans are no-op when APM/tracing is not configured
  • Traces visible and correctly structured in APM

teethaking and others added 3 commits June 30, 2026 03:55
)

- Add TraceSpan method decorator in common/decorators
- Inject DistributedTracingService (@optional) into GovernanceService,
  ReferralsService, SavingsService, IndexerService
- Decorate all public domain methods with named spans:
    governance.createProposal, editProposal, getProposals, castVote,
    queueProposal, executeProposal, cancelProposal, finalizeVoting,
    delegate, revokeDelegate
    referrals.generateReferralCode, applyReferralCode,
    checkAndCompleteReferral, distributeRewards, getReferralStats,
    getUserReferrals, generateCustomCode, getLeaderboard
    savings.createProduct, updateProduct, findAllProducts,
    findOneProduct, compareProducts, findProductWithLiveData,
    migrateSubscriptionsToVersion, subscribe, findMySubscriptions,
    getProductMetrics, getProductCapacitySnapshot, findMyGoals,
    createGoal, updateGoal, deleteGoal, transferToGoal,
    createWithdrawalRequest
    indexer.runIndexerCycle, processEventsForReplay,
    fetchEventsFromRange
- Spans visible at GET /api/apm/traces via existing ApmController
- Add unit spec for TraceSpan decorator (CI test coverage)
feat(apm): Add request tracing spans for domain services (Devsol-01#1097)
@drips-wave

drips-wave Bot commented Jun 30, 2026

Copy link
Copy Markdown

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

@vercel

vercel Bot commented Jun 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
nestera Skipped Skipped Jun 30, 2026 3:22am

@Devsol-01 Devsol-01 merged commit cdd7b84 into Devsol-01:main Jun 30, 2026
2 of 5 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.

[Backend] -- Add Request Tracing Spans for Domain Services

2 participants