Skip to content
Open
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
9d267e6
docs(spec): OpenTelemetry golden-signals middleware design
knutties May 10, 2026
ee4d70b
docs(plan): OpenTelemetry golden-signals middleware implementation plan
knutties May 10, 2026
1255c16
build: add opentelemetry deps to workspace
knutties May 10, 2026
b50e36d
build: enable tokio_unstable workspace-wide
knutties May 10, 2026
7db5239
build(service_utils): enable opentelemetry deps
knutties May 10, 2026
92b2f42
feat(observability): module skeleton
knutties May 10, 2026
b7483e7
feat(observability): config from env
knutties May 10, 2026
4b1cc8b
feat(observability): http method normalization
knutties May 10, 2026
33e67b8
feat(observability): MeterProvider with prometheus exporter
knutties May 11, 2026
3bea122
feat(observability): route template extraction helper
knutties May 11, 2026
ea2e596
feat(observability): build OTel attributes for HTTP metrics
knutties May 11, 2026
c05be67
feat(observability): RAII guard for active_requests gauge
knutties May 11, 2026
ebc24d3
feat(observability): MetricsMiddleware records HTTP signals
knutties May 11, 2026
73c35ee
feat(observability): /healthz /livez /readyz handlers
knutties May 11, 2026
e7bfadd
feat(observability): /metrics server on dedicated port
knutties May 11, 2026
f9518f0
feat(observability): db + redis pool saturation gauges
knutties May 11, 2026
ce50783
feat(observability): tokio runtime saturation gauges
knutties May 11, 2026
43cafd8
feat: exclude /healthz /livez /readyz from auth checks
knutties May 11, 2026
02113f1
feat: wire observability into main binary
knutties May 11, 2026
267a33c
test(observability): end-to-end integration
knutties May 11, 2026
dae4266
test(observability): cardinality regression budget
knutties May 11, 2026
77dc30b
docs: note metrics endpoints and tokio_unstable build flag
knutties May 11, 2026
c62b439
fix(observability): graceful degradation on init failure (review fix 1)
knutties May 11, 2026
60c0a30
fix(observability): __static__ sentinel, extract_route_from_response,…
knutties May 11, 2026
e71a4d6
fix(observability): merge OTEL_RESOURCE_ATTRIBUTES; document OTLP env…
knutties May 11, 2026
1bca586
docs(README): drop spec link from observability section
knutties May 11, 2026
faa7937
fix(observability): graceful OTLP degradation + gRPC protocol warning…
knutties May 11, 2026
e98e978
chore(deps): drop opentelemetry-semantic-conventions dep (item 2)
knutties May 11, 2026
6e93548
chore(observability): remove dead code stubs (items 4, 5, 6)
knutties May 11, 2026
1011088
fix(observability): expose redis.client.connections.connected gauge (…
knutties May 11, 2026
044c174
refactor(observability): inject env source into ObservabilityConfig::…
knutties May 11, 2026
3728b0b
fix(observability): mount health endpoints without empty-prefix scope
knutties May 12, 2026
9a58318
chore(deps): regenerate Cargo.lock after dropping opentelemetry-seman…
knutties May 14, 2026
e077a72
style: apply rustfmt to PR-touched files
knutties May 14, 2026
e9e4fea
fix(observability): clippy lints flagged by CI
knutties May 14, 2026
8ed83db
fix(observability): clippy async_yields_async in integration tests
knutties May 14, 2026
39b18c8
fix(observability): IPv6-safe metrics bind, percent-decoded OTEL reso…
knutties May 14, 2026
0f1c796
chore(observability): doc fixes and small style/semconv tweaks
knutties May 14, 2026
7c7bf13
fix(observability): detach metrics server lifetime from main API server
knutties May 14, 2026
8fb3096
refactor(observability): DRY env key names with FromStr-based parse h…
knutties May 15, 2026
940e755
refactor(observability): drop get_str — collapse into parse_or_default
knutties May 16, 2026
cb5f8ce
refactor(observability): introduce crate-private EnvSource marker trait
knutties May 16, 2026
80ee392
refactor(observability): collapse normalize_method to a single macro
knutties May 17, 2026
fabdf19
refactor(observability): read Handle::metrics() directly; drop tokio-…
knutties May 17, 2026
dc75c9b
chore(observability): remove /healthz /livez /readyz endpoints
knutties May 17, 2026
3269f9a
docs(observability): note post-implementation deviations from plan/spec
knutties May 17, 2026
7d6f51b
test(observability): move tokio-runtime check to integration test
knutties May 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Required by tokio-metrics for runtime instrumentation. Affects all
# crates in the workspace; only the saturation::tokio_runtime module
# consumes the additional APIs that this flag unlocks.
[build]
rustflags = ["--cfg", "tokio_unstable"]
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ test_logs
# pre-commit config
.pre-commit-config.yaml
.cargo
!.cargo/config.toml

#gradle files
.gradle
Expand Down
66 changes: 62 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,20 @@ diesel = { version = "2.2.4", package = "juspay_diesel", features = [
] }
fred = { version = "9.2.1" }
futures-util = "0.3.28"
humantime = "2.1"
inventory = "0.3"
itertools = { version = "0.10.5" }
jsonlogic = { version = "0.5.5", package = "juspay_jsonlogic" }
jsonschema = "~0.17"
leptos = { version = "0.6.11" }
log = { version = "0.4.20", features = ["kv_unstable_serde"] }
once_cell = { version = "1.18.0" }
opentelemetry = { version = "0.27", default-features = false, features = ["metrics"] }
opentelemetry_sdk = { version = "0.27", default-features = false, features = ["metrics", "rt-tokio"] }
opentelemetry-prometheus = { version = "0.27", default-features = false }
opentelemetry-otlp = { version = "0.27", default-features = false, features = ["metrics", "http-proto", "reqwest-client"] }
opentelemetry-semantic-conventions = { version = "0.27" }
prometheus = { version = "0.13", default-features = false }
regex = "1.9.1"
reqwest = { version = "0.11.18", features = ["json"] }
rs-snowflake = "0.6.0"
Expand All @@ -79,7 +86,9 @@ serde_json = { version = "1.0.140" }
secrecy = "0.10"
strum = "0.25"
strum_macros = "0.25"
thiserror = "1"
tokio = { version = "1.29.1", features = ["full"] }
tokio-metrics = { version = "0.3", default-features = false, features = ["rt"] }
toml = { version = "0.8.8", features = ["preserve_order"] }
tracing = "0.1.44"
tracing-subscriber = { version = "0.3.22", features = [
Expand All @@ -100,6 +109,9 @@ superposition_provider = { path = "crates/superposition_provider", version = "0.
superposition_sdk = { path = "crates/superposition_sdk", version = "0.106.2" }
service_utils = { path = "crates/service_utils", version = "0.106.2" }

[workspace.lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tokio_unstable)'] }

[workspace.lints.clippy]
mod_module_files = "warn"
manual_range_contains = "allow"
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,22 @@ Want a broader systems view? Open the [DeepWiki architecture guide](https://deep
- [Context7 LLM-friendly docs](https://context7.com/juspay/superposition)
- [DeepWiki repository guide](https://deepwiki.com/juspay/superposition)

## Metrics & observability

The HTTP API exposes Prometheus metrics on `SUPERPOSITION_METRICS_PORT` (default `9091`):

```
curl http://localhost:9091/metrics
```
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add a language identifier to the code fence.

markdownlint (MD040) flags this fence. Use bash so the curl snippet gets syntax highlighting and the lint passes.

📝 Suggested change
-```
-curl http://localhost:9091/metrics
-```
+```bash
+curl http://localhost:9091/metrics
+```
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
```
curl http://localhost:9091/metrics
```
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 157-157: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@README.md` around lines 157 - 159, The markdown code fence containing the
curl example is missing a language identifier, triggering markdownlint MD040;
update the fenced block that wraps the curl invocation (the triple-backtick
block around "curl http://localhost:9091/metrics") to include the bash language
identifier (```bash) so the snippet is syntax-highlighted and the lint rule
passes.


Health endpoints live on the main port: `GET /healthz`, `/livez`, `/readyz`.

**Note on `tokio_unstable`.** The workspace's `.cargo/config.toml` enables
`--cfg tokio_unstable` so `tokio-metrics` can collect runtime saturation. This
flag only adds APIs; no behavioural change for existing code. Contributors who
build outside `cargo` (e.g., custom IDE invocations) should pass the same flag,
or accept that the `runtime.tokio.*` metrics will be absent.

## Contributing

We welcome contributions across the platform, clients, docs, and examples.
Expand Down
9 changes: 9 additions & 0 deletions crates/service_utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,20 @@ diesel = { workspace = true }
diesel-adapter = { version = "1.2.0" }
fred = { workspace = true, features = ["metrics"] }
futures-util = { workspace = true }
humantime = { workspace = true }
inventory = { workspace = true }
log = { workspace = true }
once_cell = { workspace = true }
openidconnect = "3.5.0"
opentelemetry = { workspace = true }
opentelemetry_sdk = { workspace = true }
opentelemetry-otlp = { workspace = true }
opentelemetry-prometheus = { workspace = true }
opentelemetry-semantic-conventions = { workspace = true }
prometheus = { workspace = true }
rand = "0.8"
tokio = { workspace = true }
tokio-metrics = { workspace = true }
tracing = { workspace = true }
regex = { workspace = true }
reqwest = { workspace = true }
Expand All @@ -42,6 +50,7 @@ superposition_types = { workspace = true, features = [
"api",
"diesel_derives",
] }
thiserror = { workspace = true }
url = { workspace = true }
urlencoding = "~2.1.2"
uuid = {workspace = true}
Expand Down
11 changes: 11 additions & 0 deletions crates/service_utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
#![deny(unused_crate_dependencies)]
// Re-exported so T4+ modules can use them without triggering
// the `unused_crate_dependencies` lint while no source yet imports them.
use humantime as _;
use opentelemetry as _;
use opentelemetry_otlp as _;
use opentelemetry_prometheus as _;
use opentelemetry_sdk as _;
use opentelemetry_semantic_conventions as _;
use prometheus as _;
use tokio_metrics as _;
pub mod aws;
pub mod db;
pub mod encryption;
pub mod extensions;
pub mod helpers;
pub mod middlewares;
pub mod observability;
pub mod redis;
pub mod registry;
pub mod service;
Expand Down
Loading
Loading