feat(observability): adds tracing withing POST /v1/certificates endpoint#2818
feat(observability): adds tracing withing POST /v1/certificates endpoint#2818ygrishajev merged 1 commit intomainfrom
Conversation
📝 WalkthroughWalkthroughThis pull request adds distributed tracing instrumentation across multiple services and repositories by applying the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/api/src/certificate/services/certificate/certificate.service.ts (1)
43-47: Nit: use object shorthand forencryptedKey.♻️ Suggested simplification
return { certPem: crtpem, pubkeyPem: pubpem, - encryptedKey: encryptedKey + encryptedKey };🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/api/src/certificate/services/certificate/certificate.service.ts` around lines 43 - 47, The returned object explicitly repeats the property name for encryptedKey; update the return in the certificate creation function (the block that currently returns { certPem: crtpem, pubkeyPem: pubpem, encryptedKey: encryptedKey }) to use object shorthand by returning { certPem: crtpem, pubkeyPem: pubpem, encryptedKey } so the property name is not duplicated.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@apps/api/src/certificate/services/certificate/certificate.service.ts`:
- Around line 43-47: The returned object explicitly repeats the property name
for encryptedKey; update the return in the certificate creation function (the
block that currently returns { certPem: crtpem, pubkeyPem: pubpem, encryptedKey:
encryptedKey }) to use object shorthand by returning { certPem: crtpem,
pubkeyPem: pubpem, encryptedKey } so the property name is not duplicated.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
apps/api/src/auth/services/api-key/api-key-auth.service.tsapps/api/src/billing/repositories/user-wallet/user-wallet.repository.tsapps/api/src/certificate/services/certificate/certificate.service.tsapps/api/src/user/repositories/user/user.repository.ts
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2818 +/- ##
==========================================
- Coverage 53.96% 53.11% -0.86%
==========================================
Files 1020 985 -35
Lines 23608 22777 -831
Branches 5776 5683 -93
==========================================
- Hits 12740 12097 -643
+ Misses 9477 9298 -179
+ Partials 1391 1382 -9
*This pull request uses carry forward flags. Click here to find out more.
🚀 New features to boost your workflow:
|
Why
The
POST /v1/certificatesendpoint takes ~20s (up to 1,5min), with ~12s being completely untraced betweenAuthInterceptor.interceptandManagedSignerService.executeDerivedDecodedTxByUserId. This makes it impossible to identify the bottleneck (JWT/JWKS validation, DB lookups, or PEM certificate generation).What
Adds
@Trace()decorators to key methods in the certificate creation flow to break down the untraced gap:UserRepository.findById,findByUserId,markAsActiveUserWalletRepository.findOneByUserIdApiKeyAuthService.getAndValidateApiKeyFromHeaderCertificateService.createCertificateService.generatePEMviawithSpan(external package, can't use decorator)Summary by CodeRabbit
Chores
Refactor