Repository navigation
feat(backend): WebSocket relay retry and telemetry, payment processor telemetry suites, log retention validation - #1602
Conversation
…ssor telemetry suites, strict log retention validation WebSocket relay deliveries retry transient failures with full-jitter exponential backoff and dead-letter what still fails; relay alert metrics, rules and /health/websocket-relay; integration and stress suites for payment processor telemetry with a bounded asset label; strict option validation and log scrubbing for the log retention service.
|
@noevidence1017 is attempting to deploy a commit to the Emmanuel's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@noevidence1017 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! 🚀 |
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| - | - | Generic High Entropy Secret | a5a3939 | backend/src/lib/websocket-relay-retry.test.js | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secret safely. Learn here the best practices.
- Revoke and rotate this secret.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
Summary
WebSocket Relay Service: automated retry with exponential backoff (#1454)
src/lib/websocket-relay-retry.js:withRelayRetry(operation, options): full-jitter backoffrandom(0, min(maxDelayMs, baseDelayMs * 2^n)), with amaxAttemptscap, a totalmaxElapsedMsbudget andAbortSignalsupport.deliverRelayMessage(message, send, { circuitBreaker, dlq }): retries a delivery, then moves the message to the dead letter queue with its total retry count when every attempt fails.redriveDeadLetters(dlq, send, { limit }): replays queued messages oldest first; messages that fail again go back on the queue and are not retried twice in the same run.retryable: falseand an open circuit breaker fail at once, so retries never defeat the breaker.RELAY_RETRY_MAX_ATTEMPTS,RELAY_RETRY_BASE_DELAY_MS,RELAY_RETRY_MAX_DELAY_MSandRELAY_RETRY_MAX_ELAPSED_MS, and every value is clamped to a safe range.WebSocket Relay Service: Prometheus alert metrics and health telemetry (#1453)
src/lib/websocket-relay-telemetry.jswith its own registry:websocket_relay_deliveries_total{outcome}andwebsocket_relay_retries_total{operation,result}.websocket_relay_retry_delay_seconds.websocket_relay_health_state,websocket_relay_delivery_failure_ratio,websocket_relay_dlq_depth,websocket_relay_circuit_openandwebsocket_relay_last_delivery_timestamp_seconds.attachRelayHealthSource().GET /health/websocket-relayendpoint: 503 only when unhealthy, 200 when degraded.GET /healthnow also reportsservices.websocket_relayfor information only./metricsnow merges the relay telemetry registry and the existingrelay_*registry ([Backend] Implement granular metrics tracking for Websocket Relay #1083), which was defined but never scraped before.docs/alerts/websocket-relay.rules.yml: unhealthy, circuit open, high failure ratio, retries exhausted, DLQ backlog, and no successful deliveries for 30 minutes. A test checks that every metric the rules reference is actually registered.Payment Processor Telemetry: integration and stress suite (#1481)
tests/integration/payment-processor-telemetry.test.jsscrapes the real/metricsroute and parses the Prometheus text. It checks:payment_processor_*series is in the merged output;+Infequals_count, correct_sum);load-tests/payment-processor-telemetry-stress.test.jschecks:createPaymentSessionused the request'sbody.assetas a label, so any client could create one time series per arbitrary string, including onvalidation_failed. The newtoAssetLabel()keeps well-formed asset codes (upper-cased) and maps anything else toinvalid, orunknownwhen missing. It is applied at bothpaymentServicecall sites that used a raw asset.Log Retention & Archival Service: payload sanitization and strict validation (#1472)
parsePositiveIntegernow only accepts plain base-10 integers in range. Before,parseIntsilently turned values like30daysinto 30; now30days,1e3,-5,0x10and1.5are rejected with aLogRetentionValidationErrorthat names the option or environment variable. The old two-argument call still works.retentionDays1-3650,batchSize1-50000,maxDurationMs1s-24h, plus a newmaxBatches/LOG_PURGE_MAX_BATCHEScap.query(), and everything is validated before the first query runs.^[a-z_][a-z0-9_]{0,62}$; values are always bind parameters.batchSize, and themaxBatchescap stops a misbehaving driver from looping forever.sanitizeLogMessage()masks credentials (scheme://user:pass@,password=,token=,Bearer ...), strips control characters to prevent log injection, and caps length. The purge script now logs only the scrubbed message and the error's name and code, not the raw error object, which can echo the database connection string.Tests
backend/src/lib/websocket-relay-retry.test.jsbackend/src/lib/websocket-relay-telemetry.test.jsbackend/src/lib/log-retention-validation.test.jsbackend/tests/integration/payment-processor-telemetry.test.jsbackend/load-tests/payment-processor-telemetry-stress.test.jsDocs
backend/docs/WEBSOCKET_RELAY.md(new)backend/docs/LOG_RETENTION.md(new)backend/docs/PAYMENT_PROCESSOR.md: new telemetry suite section (the following sections are renumbered)backend/docs/alerts/websocket-relay.rules.yml(new)Notes
log-retention.test.jscases still apply.srcyet. The retry and telemetry helpers are ready to be wired in where a relay connection is created; usage is indocs/WEBSOCKET_RELAY.md.reconnectWithBackoffis unchanged.purgeWebhookLogsoptions are rejected.assetlabel onpayment_processor_sessions_total,payment_processor_session_duration_secondsand confirmed verifications is now upper-cased, with invalid input bucketed asinvalid. Dashboards filtering on a lower-case asset value would need updating./metricsoutput grows by therelay_*andwebsocket_relay_*series.closes #1454
closes #1453
closes #1481
closes #1472