Repository navigation
Conversation
Two ingest adapters ported from ASAPQuery's main, as crates under
crates/adapters/ingest/, served by the data plane on ASAPQuery's routes:
- victoriametrics_remote_write: the Remote Write protobuf, zstd-compressed.
Its Decoder decompresses and hands the protobuf to the Remote Write
decoder (new Decoder::decode_uncompressed), so samples decode into the
caller's types with the same validation and series cache.
POST /api/v1/import.
- otlp: OTLP/HTTP metrics (protobuf, gzip optional) into one point per
sample, as ASAPQuery's receiver reads them. POST /v1/metrics, answering
{"rejected":0}.
Both feed the engine as Remote Write does (same 400/503/500), and are not
served in forward mode, which delivers only Remote Write bodies to the raw
store. Existing endpoints are unchanged.
- otlp: one push per data point for every metric type; drop encode and Limits' Default (test-only); error text as ASAPQuery's. - victoriametrics_remote_write: one-pass zstd when the frame states its size, streaming otherwise with the window capped by the size limit; reuse the Remote Write decoder's buffer cap; no re-exports. - data-plane: VictoriaMetrics decodes no longer counted as Remote Write decode time; OTLP limits mapped in decode_otlp_samples; a test that the three decoders give the same interned series and samples.
zzylol
force-pushed
the
refactor/layout-adapters
branch
from
November 28, 2026 00:56
a64b54c to
5d5b323
Compare
zzylol
force-pushed
the
refactor/layout-ingest-adapters
branch
from
November 28, 2026 00:56
93d4d49 to
11a1c3a
Compare
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
POST /api/v1/import) and OTLP metrics (POST /v1/metrics); the backend ingests only Prometheus Remote Write. Step 7 ofdocs/design/repo-layout.md(docs(design): repository layout and engine boundaries #874) brings both over as adapter crates.crates/adapters/ingest/victoriametrics-remote-write(victoriametrics_remote_write): decompresses zstd and hands the protobuf to the Remote Write decoder through a newprometheus_remote_write::Decoder::decode_uncompressed. There is no second protobuf decoder: samples are built into the caller's types (SampleBuilder), with the same validation, limits and series cache.crates/adapters/ingest/otlp(otlp): OTLP/HTTP metrics (protobuf, gzip optional) into onePointper sample, converted as ASAPQuery's receiver converts them.data-planeserves both on ASAPQuery's routes and feeds the engine as/api/v1/writedoes (the sameRawSamples andtry_ingest, the same 400/503/500).QueryRequest.Review guide
refactor/layout-adapters(refactor: Remote Write and Prometheus HTTP API into crates/adapters (layout step 6) #881). Stacked draft.pushfor every OTLP metric type; one-pass zstd; no test-only public items; the decoder-identity test.ingestreturns the refusal (clippyresult_large_err).#[inline(always)]on the shared request loop (see Benchmarks).crates/data-plane/src/remote_write.rs(the seam).Decoderincrates/adapters/ingest/victoriametrics-remote-write/src/lib.rs.pointsincrates/adapters/ingest/otlp/src/lib.rs.write_victoriametrics,write_otlp,ingestandrouterincrates/data-plane/src/lib.rs.Dependency graph
The VictoriaMetrics crate depends on the Remote Write adapter. Its wire format is that adapter's protobuf, and the alternatives are worse:
decode_uncompressedindata-planewould put protocol knowledge, the zstd-bomb limit and a reused buffer in the wiring crate.SampleBuilderincommonwould make every ingest adapter pull inasap-planner.The docs(design): repository layout and engine boundaries #874 doc now states the rule: an adapter depends on
common, on nothing, or on the adapter whose wire format it extends.opentelemetry-proto0.28 (ASAPQuery's version) with onlygen-tonic-messagesandmetrics. There is no gRPC server, but tonic's codegen types and the OpenTelemetry SDK still compile: 12 new lockfile packages, no new runtime services.Behavior: before → after
POST /api/v1/write, every query route,/metrics,/api/v1/status/asap,/-/ready, the watermarkPOST /api/v1/import(zstd Remote Write)POST /v1/metrics(OTLP protobuf,Content-Encoding: gzipoptional){"rejected":0}(ASAPQuery's answer); 400 / 503 / 500 as above. Forward mode: proxied, as beforeOTLP conversion, as ASAPQuery's
otlp_to_metric_points_and_sketches:__name__is the metric name. The scope's attributes come first, the resource's override them, and the point's override both.<name>_sum(when set) and<name>_count. Summaries always give both.kll./cms./countsketch.sketch_payloadattribute, and metrics with no name, are skipped.Interfaces
crates/adapters/ingest/prometheus-remote-write/src/lib.rsimpl<B: SampleBuilder> Decoder<B> { pub fn decode(&mut self, body: &[u8], limits: &Limits) -> Result<Vec<B::Sample>, RemoteWriteError>; + /// An uncompressed `WriteRequest`, as `decode` reads a decompressed body. + pub fn decode_uncompressed(&mut self, request: &[u8], limits: &Limits) -> Result<Vec<B::Sample>, RemoteWriteError>; } -const KEPT_DECOMPRESSED_BYTES: usize = 32 * 1024 * 1024; +pub const KEPT_DECOMPRESSED_BYTES: usize = 32 * 1024 * 1024;crates/adapters/ingest/victoriametrics-remote-write/src/lib.rs(new)crates/adapters/ingest/otlp/src/lib.rs(new)crates/data-plane/src/remote_write.rscrates/data-plane/src/lib.rsroutes (outside forward mode).route("/api/v1/write", post(write).layer(write_body_limit)) +.route("/api/v1/import", post(write_victoriametrics).layer(write_body_limit)) +.route("/v1/metrics", post(write_otlp).layer(write_body_limit))Tests
victoriametrics_remote_write(6):test_zstd_decode_single_sampleandtest_decode_invalid_zstd.otlp(5):_sum/_countfor histogram, exponential histogram and summary.prometheus_remote_write(+1):decode_uncompressedequalsdecode, and enforces the size limit.data_planetests/ingest_protocols.rs(+3):/api/v1/write,/api/v1/importand/v1/metrics(plain and gzip) gives byte-identical planned answers over the last minute, and the samesamples_accepted.&'static Series), timestamps and value bits.Gate on the restacked head (11a1c3a):
cargo fmt --all -- --checkandcargo clippy --workspace --all-targets --locked -- -D warningsclean,cargo test --workspace --locked: 218 passed, 0 failed, 3 ignored (51 suites) (#881: 203 passed, 0 failed, 3 ignored (46 suites;planner_executor_parity::push_precompute_stores_the_window_paths_view_rowsfailed once under load and passed alone); +15 new).forward_mode::refused_deliveries_are_retried_until_acceptedfailed once under load (a race between the mock raw store counting the accepted delivery and the forwarder counting it; code this PR does not touch) and passed 5 of 5 reruns and in the full run.Parity
This uses the uncommitted dump test from #880/#881, with additions:
/api/v1/write;/api/v1/status/asap.The fixture is the plan of
sum by (job) (sum_over_time(data[10s]))with 3 series written through 60 s. The dump records:--no-forward;date;/metricsnames and label sets.The dump is byte-identical to #881's head (32,039 bytes both).
Benchmarks
ingest_bench 10000 120 views 1 persistanddecode_bench, release builds, same host, cores 0–15, #881's head and this branch alternating.The write-acknowledged spread is noise: 1.2 M samples are written in 0.17–0.19 s, at a 10 ms resolution. With
#[inline]only on the shared request loop, one series per sample decoded at 0.082 µs (6 of 6 runs, about +2%). With#[inline(always)](commit 4) it decodes at 0.080 µs, the same as the base, in 5 of 5 interleaved runs.Deviations
POST /v1/metricsis served.__name__or with a label twice is rejected with 400, as a Prometheus Remote Write series is (ASAPQuery's decoder accepted both). An OTLP point attribute named__name__is replaced by the metric name.SampleBuilder-style interface for OTLP is deferred until it is.remote_write_decodekeeps counting Prometheus Remote Write only, so/metricsis unchanged.service.nameare not sanitized into Prometheus label names, as in ASAPQuery.Answer/ResultSampleincommon, why ingest adapters decode into caller types and not a boundary batch, and the verbatim forward, withFallbackClientas the seam for step 8.