fix: API deprecation headers, OTel sampling, email queue drain, and pool metrics (#680 #681 #682 #683) - #830
Merged
Merged
Conversation
…server-side warnings for deprecated API versions - Fix Deprecation header value from false to true (RFC 8594 boolean) - Add tracing::warn! in v1_deprecation_middleware for every deprecated call - Add tracing::warn! in versioning_middleware when a deprecated version is detected - Add DEPRECATED_VERSIONS constant to track which versions are deprecated - Document deprecation schedule and policy in API_SPEC.md Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…LER_ARG env vars with 10% production default - Add sample_rate_from_env() that reads the OTel standard env vars and falls back to the passed-in rate (which itself defaults from TRACE_SAMPLE_RATE / 0.1) - Call sample_rate_from_env() at the top of init_tracing so env vars take precedence - Update TRACING.md to document OTEL_TRACES_SAMPLER / OTEL_TRACES_SAMPLER_ARG, clarify 10% as the production default, and update all sampling examples Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ed configurable timeout - Add email_queue_drain_timeout() to shutdown.rs reading EMAIL_QUEUE_DRAIN_TIMEOUT_SECS (defaults to 60 s — more generous than the global 30 s to avoid losing in-flight emails) - Give the email queue worker its own ShutdownCoordinator so its drain timeout is independent of the global background-worker shutdown timeout - In main.rs shutdown sequence: drain email first, then drain blockchain workers, so in-flight email jobs have the best chance to complete before process exit Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…dle connections, acquire duration) - Add db_pool_connections_active and db_pool_connections_idle IntGaugeVec metrics - Add db_pool_acquire_duration_seconds HistogramVec metric with fine-grained buckets - Add observe_pool_connections() and observe_pool_acquire() methods to Metrics - Update Grafana dashboard panel 7 to use the new pool metric names (active vs idle) - Add new Grafana panel 10 for p50/p95 pool acquire duration with a 100ms alert threshold Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@Grace-CODE-D 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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves four independent backend issues across observability, reliability, and API contracts.
versioning.rsAPI versioning does not deprecate old versions with sunset headers #683 —versioning.rs:Deprecationheader was set tofalse; deprecated API versions produced no server-side warning.tracing_config.rsdoes not set a sampling rate for production traces #681 —tracing_config.rs: OTel standard env vars (OTEL_TRACES_SAMPLER/OTEL_TRACES_SAMPLER_ARG) were not read; production defaulted to 100 % sampling.shutdown.rsgraceful shutdown does not drain the email queue before exiting #682 —shutdown.rs: Email queue worker shared the global shutdown timeout with blockchain workers, risking in-flight email loss on slow graceful exits.metrics.rsPrometheus metrics do not include database pool utilization #680 —metrics.rs: Prometheus did not expose SQLx connection pool utilisation metrics needed to diagnose DB bottlenecks.Changes
fix(#683) — RFC 8594 Deprecation / Sunset headers (
versioning.rs,API_SPEC.md)Deprecation: false→Deprecation: true(RFC 8594 boolean signals deprecation).DEPRECATED_VERSIONSconstant (["v1"]) to track which versions are deprecated.tracing::warn!inversioning_middlewarewhen a deprecated version is detected in the request header.tracing::warn!inv1_deprecation_middlewareon every response so server-side monitoring can track client migration progress.services/api/API_SPEC.mddocumenting the deprecation policy, sunset date (2026-04-25), version selection, and migration guide.fix(#681) — OTel sampling env vars with 10 % production default (
tracing_config.rs,TRACING.md)pub fn sample_rate_from_env(default_rate: f64) -> f64that readsOTEL_TRACES_SAMPLERandOTEL_TRACES_SAMPLER_ARGper the OpenTelemetry SDK environment variable specification.init_tracingnow callssample_rate_from_envat the top; OTel standard env vars take precedence over the legacyTRACE_SAMPLE_RATEconfig value.traceidratioat0.1) when neither env var is set.always_on,always_off,traceidratio,parentbased_always_on,parentbased_always_off,parentbased_traceidratio.TRACING.mdto document all sampler options, the 10 % default, and updated all examples to use the OTel standard vars.fix(#682) — Email queue drain with dedicated configurable timeout (
shutdown.rs,main.rs)pub fn email_queue_drain_timeout() -> Durationtoshutdown.rsreadingEMAIL_QUEUE_DRAIN_TIMEOUT_SECS(default 60 s — more generous than the 30 s global timeout because losing in-flight emails is more costly than delaying exit).ShutdownCoordinator::new(1)inmain.rs, separate from the blockchain workers coordinator.EMAIL_QUEUE_DRAIN_TIMEOUT_SECS, then (2) drain blockchain workers withSHUTDOWN_TIMEOUT_SECS. Both timeouts are independently configurable via env var.fix(#680) — SQLx pool utilisation metrics (
metrics.rs,grafana-dashboard.json)db_pool_connections_active(IntGaugeVec) — connections currently checked out.db_pool_connections_idle(IntGaugeVec) — connections sitting idle in the pool.db_pool_acquire_duration_seconds(HistogramVec) — time spent waiting to acquire a connection; buckets from 0.1 ms to 1 s.observe_pool_connections(pool, active, idle)andobserve_pool_acquire(pool, duration)methods.db_pool_connections_active/db_pool_connections_idle).Closes
Closes #683
Closes #681
Closes #682
Closes #680