New Feature Submissions:
- Does your submission pass tests?
- ✅
cargo test -p common
- ✅
cargo test -p qdrant
- Have you formatted your code locally using
cargo +nightly fmt --all command prior to submission?
- ✅
cargo +nightly fmt --all
- Have you checked your code using
cargo clippy --workspace --all-features command?
- Not fully on my macOS environment due to local Python /
pyo3 mismatch (abi3-py310 implies Python >= 3.10; my local interpreter is 3.9).
- I did run:
- ✅
cargo clippy -p qdrant --all-targets
Changes to Core Features:
- Have you added an explanation of what your changes do and why you’d like us to include them?
- See “Problem Statement”, “Solution”, and “Implementation Details” sections above.
- Have you written new tests for your core changes, as applicable?
- Not yet; happy to add tests if maintainers request specific coverage.
- Have you successfully ran tests with your changes locally?
- Yes — see commands above.
🎯 Summary (Fixes #3322)
This PR introduces per-collection metrics for the REST API, addressing the request in #3322 to provide more granular visibility into Qdrant’s performance. It enables monitoring of latencies and request counts on a per-collection basis, which is essential for deployments with multiple collections.
/claim #3322
🔧 Problem Statement
Currently, REST metrics are aggregated globally. This makes it difficult for users to:
- Identify which specific collection is experiencing high latency or traffic.
- Debug performance bottlenecks that might be isolated to a single collection.
- Track usage patterns across a multi-tenant environment.
🚀 Solution: REST Per-Collection Granularity
This implementation adds a collection label to relevant REST metrics.
Key Features:
- Automatic Extraction: The Actix middleware now extracts collection names from request paths.
- Path Normalization: To prevent high-cardinality issues in Prometheus, specific paths (e.g.,
/collections/my-coll/points/search) are normalized to a generic template (/collections/{name}/points/search) for the endpoint label, while still preserving the specific collection in the collection label.
- Telemetry Anonymization: Maintains system privacy by masking collection names in shared telemetry data while preserving the per-collection structure.
- Backward Compatibility: Existing global metrics remain unchanged; per-collection metrics are added as a new dimension.
📝 Implementation Details
Middleware Improvements
Modified src/actix/actix_telemetry.rs to:
- Implement extract_collection_from_path.
- Handle path normalization to ensure metrics labels remain manageable.
- Capture per-collection statistics during the request lifecycle.
Metrics & Telemetry
WebApiTelemetry: Extended to store responses_by_collection.
- MetricsProvider: Updated to output
rest_per_collection_... metrics when whitelisted endpoints are hit.
- Anonymization: Ensured that
Anonymize for WebApiTelemetry properly masks collection names to collection_N during export.
Running test cases locally
https://github.com/user-attachments/assets/c07d14e8-d9ee-40c7-b059-a67f8d6f3bb6
Testing feature implementation locally
Calling endpoint without per_collection parameter
sets per_collection=false by default

Calling endpoint with per_collection=true parameter
@generall