Skip to content

fix(otlp): OTLP/HTTP replies, Prometheus resource-attribute labels, DELTA sums rejected, in-place decoder - #887

Draft
zzylol wants to merge 3 commits into
chore/bump-planner-latestfrom
fix/otlp-ingest-conformance
Draft

zzylol wants to merge 3 commits into
chore/bump-planner-latestfrom
fix/otlp-ingest-conformance

Conversation

@zzylol

@zzylol zzylol commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Problem: POST /v1/metrics did not behave like an OTLP/HTTP receiver, and it decoded slowly.
    • It answered every request with JSON {"rejected":0}. OTLP/HTTP protobuf exporters (the OpenTelemetry SDKs and the Collector) parse the reply as a protobuf ExportMetricsServiceResponse, so they counted every successful export as failed (response_decode).
    • Every resource and scope attribute was copied into every series' labels. An SDK resource therefore gave each series service.name, telemetry.sdk.*, host.name and similar labels, and dotted names that need quoted UTF-8 selectors in PromQL.
    • DELTA sums were stored as if they were cumulative, and points flagged "no recorded value" were stored as 0.
    • Decoding took 2.54 µs per sample, against 0.105 µs for Remote Write: 24x slower on the decode bench.
  • Change:
    • Replies follow OTLP/HTTP: a protobuf ExportMetricsServiceResponse, with partial_success when points were rejected. Errors carry a google.rpc.Status body. OTLP/JSON is not decoded and gets 415.
    • Labels follow Prometheus 3.x's OTLP receiver defaults (rules and citations below). --otlp-promote-resource-attributes a,b promotes resource attributes to labels, as Prometheus' promote_resource_attributes does.
    • DELTA sums are rejected, reported in partial_success and counted on /metrics. A point flagged "no recorded value" gives Prometheus' stale marker (StaleNaN) for each sample it gives, as Prometheus' OTLP receiver writes it (see "No recorded value" below).
    • The decoder walks the protobuf in place with a series cache, as the Remote Write decoder does.
    • A view read no longer answers windows skipped as past retention as empty; this made an ingest_shards test flaky once this PR changed request timing (see "Flaky test fixed").
  • Effect: an OpenTelemetry SDK export now succeeds. A resource with service.namespace=shop, service.name=cart, service.instance.id=cart-7, host.name=node-1 gives job="shop/cart", instance="cart-7" and no other resource label. OTLP decode on the bench goes from 2.54 to 0.117 µs per sample (Remote Write: 0.104).

Review guide

  • Base: chore/bump-planner-latest (chore: pin ASAPPlanner 566b35c and its asap_sketchlib d050037 (view format 5) #886). This is a stacked draft; chore: range step cap in the query engine, one plan test helper, QueryOutcome as Result #888 (cleanups) stacks on it.
  • Read first:
    1. crates/adapters/ingest/otlp/src/lib.rs:
      • the module doc, which states the translation rules and how they differ from Prometheus;
      • Walk::metric and Walk::point (the walk, DELTA, no recorded value, the previous-point memo);
      • Walk::series and ResourceLabels (the cache key);
      • series_labels and label_name (the label rules).
    2. crates/data-plane/src/lib.rs: write_otlp, and ingest, which now returns the status and message.
  • Mechanical:
    • crates/adapters/ingest/prometheus-remote-write/src/{wire,series_cache}.rs: Reader/Value/varint_slow and the series cache moved out of lib.rs and made public, code unchanged. The cache no longer owns the builder; the Remote Write decoder holds an Interner (the cache plus its builder).
    • benchmarks/micro/decode_bench.rs gains the OTLP half (the same series and samples as one gauge).
    • The old otlp unit tests moved to src/tests.rs and were updated to the new label rules.
    • The docs: README, docs/design/repo-layout.md and docs/design/data-plane-demo.md.

Behavior: before → after

One export from an OpenTelemetry SDK: a cumulative counter http_requests_total with point attributes {http.method="GET", job="point-job"} and a DELTA sum jobs_done with one point, under the resource {service.namespace="shop", service.name="cart", service.instance.id="cart-7", host.name="node-1"} and a scope meter with attribute scope.attr="x".

Before After
Reply 200, content-type: application/json, body {"rejected":0}. The exporter reports response_decode and counts the export failed. 200, content-type: application/x-protobuf, body an ExportMetricsServiceResponse with partial_success { rejected_data_points: 1, error_message: "1 data points of sums with DELTA aggregation temporality were rejected: only cumulative sums are ingested" }
Series of the counter {__name__="http_requests_total", http.method="GET", job="point-job", service.namespace="shop", service.name="cart", service.instance.id="cart-7", host.name="node-1", scope.attr="x"} {__name__="http_requests_total", http_method="GET", job="shop/cart", instance="cart-7"}; with --otlp-promote-resource-attributes host.name, also host_name="node-1"
DELTA sum jobs_done stored as a cumulative series rejected, counted in partial_success and in asap_otlp_rejected_points_total
Attribute with an empty value (or an array or map) a label with an empty value no label (as Prometheus)
Point flagged "no recorded value" stored as 0 a stale marker (StaleNaN, bits 0x7ff0000000000002) for the value (gauge, sum), _sum when set and _count (histogram), _sum and _count (summary); the same as a Remote Write stale marker
Malformed body 400 text/plain 400 application/x-protobuf, a google.rpc.Status with the message
Content-Type: application/json 400 (decoded as protobuf, which fails) 415 application/json, {"message":"OTLP/JSON is not supported: send application/x-protobuf"}
/metrics no OTLP phase asap_phase_{runs,cpu_seconds,wall_seconds}_total{phase="otlp_decode"}, plus asap_otlp_rejected_points_total

This serves the raw-path end-to-end measurement. An SDK or Collector exporting OTLP straight to the backend now gets successful exports and the series names Prometheus would store, and ingest CPU per OTLP sample is now close to Remote Write's.

No recorded value

Prometheus main ccdfcea (3.16.0), storage/remote/otlptranslator/prometheusremotewrite: number_data_points.go (addGaugeNumberDataPoints, addSumNumberDataPoints) sets the sample to math.Float64frombits(value.StaleNaN) when pt.Flags().NoRecordedValue(); helper.go does the same for a histogram's _sum (only when HasSum), _count and buckets, and a summary's _sum, _count and quantiles. value.StaleNaN is 0x7ff0000000000002 (model/value/value.go). This PR writes the same marker for each sample it gives (it gives no bucket or quantile series). The Remote Write path already keeps stale markers as samples, and the executor's TimeRange drops them when it reads, so the series ends at that point instead of after the lookback window.

Example: a gauge whose instrument was removed sends one last point with flags: 1 at 175 s. Dropped (before), the series still answers instant queries up to the lookback window after its previous sample; with the stale marker, it answers nothing after 175 s, as in Prometheus. The asap_otlp_dropped_no_value_points_total counter is removed: nothing is dropped any more, and Remote Write does not count stale markers either.

Prometheus rules followed, with sources

Prometheus main ccdfcea (3.16.0):

  • storage/remote/otlptranslator/prometheusremotewrite/helper.go createAttributes: point attributes, then promoted resource attributes (only where unset), then job/instance (always set), then scope labels only with PromoteScopeMetadata.
  • metrics_to_prw.go setResourceContext: job = service.namespace + "/" + service.name, or service.name alone; instance = service.instance.id. The same file's FromMetrics drops a metric whose temporality is not cumulative unless delta ingestion is on ("invalid temporality and type combination"); the handler still replies 200.
  • config/config.go DefaultOTLPConfig: TranslationStrategy: UnderscoreEscapingWithSuffixes (so UTF-8 names are not kept and are escaped), LabelNameUnderscoreSanitization: true, LabelNamePreserveMultipleUnderscores: true; promote_scope_metadata defaults to false.
  • prometheus/otlptranslator LabelNamer.Build and strconv.go sanitizeLabelName: every character other than [a-zA-Z0-9] becomes _; a leading digit gets key_; a single leading _ gets key; a name that is only underscores is refused.
  • target_info (addResourceTargetInfo) is not implemented: Prometheus writes one sample every half lookback delta (2.5 min by default) across the request's time span, so it is not a one-line addition. Listed under follow-ups.

Where this PR deliberately differs (also listed in the otlp crate docs):

  • Metric names are not translated: no escaping and no _total or unit suffix. Translating them would rename planned series.
  • Histograms keep their old behavior (_sum and _count, whatever their temporality). A sum of unspecified temporality is read as cumulative. Prometheus drops both.
  • Values print as Rust prints them: bytes as [1, 2] (Prometheus: base64), 1e21 as 1000000000000000000000 (Prometheus: 1e+21); both unchanged. Arrays and maps print as empty text, so no label (Prometheus: JSON text).
  • An attribute whose name Prometheus refuses (empty, or only underscores once escaped) gives no label; Prometheus drops the whole point.
  • Points with a sketch payload attribute (kll., cms. or countsketch.sketch_payload) are skipped, as before and as ASAPQuery does.
  • A body with any Content-Type other than application/json is read as protobuf. Prometheus refuses unknown types with 400. Our behavior is unchanged from before.

Interfaces

crates/adapters/ingest/otlp/src/lib.rs

+/// The caller's series and sample types, as the Remote Write decoder takes them.
+pub use prometheus_remote_write::SampleBuilder;
+/// How resource attributes become labels; default: none promoted.
+#[derive(Debug, Clone, Default, PartialEq)]
+pub struct LabelOptions {
+    /// Resource attributes (OTLP names) that label every series of their resource, as Prometheus' `otlp.promote_resource_attributes`.
+    pub promote_resource_attributes: Vec<String>,
+}
+/// A decoded request.
+#[derive(Debug, PartialEq)]
+pub struct Decoded<S> {
+    /// The samples, in request order.
+    pub samples: Vec<S>,
+    /// Points rejected and reported in the reply: the points of DELTA sums.
+    pub rejected_points: u64,
+}
+impl<S> Decoded<S> {
+    /// Why points were rejected, for `partial_success.error_message`; `None` when none were.
+    pub fn rejection_message(&self) -> Option<String>;
+}
+/// A decoder kept between requests (thread-local in the data plane): its gzip buffer, series cache and key buffer.
+pub struct Decoder<B: SampleBuilder> { /* private */ }
+impl<B: SampleBuilder> Decoder<B> {
+    pub fn new(builder: B) -> Self;
+    /// The samples of a request body; errors: not gzip when it says so, not protobuf, over a limit.
+    pub fn decode(&mut self, body: &[u8], content_encoding: Option<&str>, options: &LabelOptions, limits: &Limits) -> Result<Decoded<B::Sample>, OtlpError>;
+}
+/// A request's encoding, from its `Content-Type`; the reply uses the same one.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum Encoding {
+    /// `application/x-protobuf`, and any other or no content type.
+    Protobuf,
+    /// `application/json` (not decoded: 415).
+    Json,
+}
+impl Encoding {
+    pub fn of_content_type(content_type: Option<&str>) -> Self;
+    pub fn content_type(self) -> &'static str;
+}
+/// The body of a 200 reply: an encoded `ExportMetricsServiceResponse`, `partial_success` set when points were rejected.
+pub fn export_response_body(rejected_points: u64, message: Option<&str>) -> Vec<u8>;
+/// `google.rpc.Status` with its message only (field 2), the body of every 4xx/5xx reply.
+#[derive(Clone, PartialEq, Message)]
+pub struct Status {
+    #[prost(string, tag = "2")]
+    pub message: String,
+}
+/// The protobuf reader's errors become `OtlpError::Protobuf`.
+impl From<RemoteWriteError> for OtlpError;
+/// A 4xx/5xx reply body, encoded as the request was.
+pub fn status_body(encoding: Encoding, message: &str) -> Vec<u8>;
-/// One sample of a series.
-pub struct Point {
-    pub labels: Vec<(String, String)>,
-    pub timestamp_ms: i64,
-    pub value: f64,
-}
-pub fn decode(body: &[u8], content_encoding: Option<&str>, limits: &Limits) -> Result<Vec<Point>, OtlpError>;

Point and the free decode are replaced by Decoder, which decodes into the caller's samples, so labels are no longer copied per point.

crates/adapters/ingest/prometheus-remote-write/src/{lib,wire,series_cache}.rs (moved from lib.rs, now public for otlp)

+/// The in-place protobuf reader and the series cache, for `otlp` too.
+pub mod series_cache;
+pub mod wire;
+/// One protobuf field value.
+pub enum Value<'a> {
+    Varint(u64),
+    Fixed64(u64),
+    Bytes(&'a [u8]),
+    Fixed32,
+}
+/// A protobuf reader over borrowed bytes; a malformed message is `RemoteWriteError::Protobuf`.
+pub struct Reader<'a> {
+    bytes: &'a [u8],
+    /// Where the next field starts.
+    pub position: usize,
+    /// Where the field read last starts (its tag).
+    pub field_start: usize,
+}
+impl<'a> Reader<'a> {
+    pub fn new(bytes: &'a [u8]) -> Self;
+    /// The next field number and value; `None` at the end.
+    pub fn field(&mut self) -> Result<Option<(u64, Value<'a>)>, RemoteWriteError>;
+}
+/// Series handles by the bytes of their key, with the next-lookup prediction.
+pub struct SeriesCache<S: Copy> { /* private */ }
+impl<S: Copy> SeriesCache<S> {
+    pub fn new() -> Self;
+    pub fn get(&mut self, key: &[u8]) -> Option<S>;
+    pub fn insert(&mut self, key: &[u8], series: S);
+}

crates/data-plane/src/lib.rs (DataPlane stays), remote_write.rs, main.rs

 impl DataPlane {
+    /// Labels OTLP series with the resource attributes `options` promotes.
+    pub fn with_otlp_label_options(self, options: otlp::LabelOptions) -> Self;
 }
-pub fn remote_write::decode_otlp_samples(body: &[u8], content_encoding: Option<&str>, limits: &Limits) -> Result<Vec<RawSample>, otlp::OtlpError>;
+pub fn remote_write::decode_otlp_samples(body: &[u8], content_encoding: Option<&str>, options: &otlp::LabelOptions, limits: &Limits) -> Result<otlp::Decoded<RawSample>, otlp::OtlpError>;
+/// CLI: OTLP resource attributes, by OTLP name, that label every series of their resource (comma-separated).
+--otlp-promote-resource-attributes <a,b,...>

crates/internal-metrics/src/lib.rs

 /// Every measurement the engine's threads record (stays).
 pub struct Metrics {
     pub push: Option<PushMetrics>,
     pub remote_write_decode: PhaseStats,
+    /// OTLP decode and series interning, on the HTTP threads (`phase="otlp_decode"`).
+    pub otlp_decode: PhaseStats,
+    /// OTLP points rejected: points of DELTA sums (`asap_otlp_rejected_points_total`).
+    pub otlp_rejected_points: AtomicU64,
     pub append: PhaseStats,
     pub precompute: Vec<(String, PhaseStats)>,
     pub precompute_windows: Vec<WindowLatency>,
     pub precompute_busy_ns: AtomicU64,
     pub precompute_threads: AtomicU64,
     pub watermark_ms: AtomicI64,
     pub raw_data_bytes: AtomicU64,
     pub raw_data_samples: AtomicU64,
     pub raw_data_panes: AtomicU64,
     pub view_bytes: AtomicU64,
     pub view_persisted_bytes: AtomicU64,
     pub view_sync_ns: AtomicU64,
     pub view_windows_not_persisted: AtomicU64,
     pub view_windows_loaded: AtomicU64,
     pub view_persist_over_bound: AtomicU64,
     pub view_file_bytes: AtomicU64,
     pub view_segments_marked_cold: AtomicU64,
 }

Usage (from crates/data-plane/tests/ingest_protocols.rs::otlp_resource_attributes_give_job_and_instance, run at this commit):

// The operator starts the data plane with a plan for `sum by (job) (sum_over_time(data[1m]))`
// (here `data_plane()` builds it in process; on the CLI, `data_plane --plan plan.json`,
// optionally with `--otlp-promote-resource-attributes deployment.environment`).
let (state, app) = data_plane();
// An SDK-like export: six `data` gauges, 180 points each, point attributes `instance`
// and `job`, under the resource {service.namespace=shop, service.name=cart,
// service.instance.id=cart-7, host.name=node-1, deployment.environment=prod} and a scope
// `meter` with attribute scope.attribute=s (no label).
let body = prost::Message::encode_to_vec(&request);
// `write_otlp` decodes it (`decode_otlp_samples` -> `otlp::Decoder::decode`, which gives each
// point job="shop/cart" and instance="cart-7" over the point's own) and ingests it.
let (status, _, _) = post_otlp(&app, "application/x-protobuf", body).await;
// 200, application/x-protobuf, an empty ExportMetricsServiceResponse (no bytes).
assert_eq!(status, StatusCode::OK);
// The planned query at its newest step (180 s): one row, job="shop/cart", whose value `sum`
// is the six series' values over the last minute; all 6 x 180 samples were accepted.
let (answers, accepted) = answers(&state, &app).await;
assert_eq!(accepted, 6 * 180);
assert_eq!(common::per_job(answers.last().unwrap()), vec![("shop/cart".to_string(), sum)]);

Algorithm changes

OTLP decode: in-place walk with a series cache

  • Problem: otlp::decode built the whole ExportMetricsServiceRequest with prost, allocating every string, then cloned a BTreeMap of labels per point and per sample, and intern_pairs hashed the full label set. On the bench this took 2.54 µs per sample for 10,000 one-sample series, against 0.105 µs for Remote Write.
  • Before:
    1. ExportMetricsServiceRequest::decode allocates every message.
    2. Per scope, a BTreeMap of scope and resource attributes is built.
    3. Per point: that map is cloned, the point's attributes are inserted, and the result is cloned again per sample with __name__, then collected to a Vec<(String, String)>.
    4. intern_pairs is called per sample.
  • After:
    1. Walk::request → resource_metrics → metric → point walk the bytes with the Remote Write wire::Reader; nothing is allocated per point.
    2. ResourceLabels::new computes job, instance and the promoted labels once per resource, and their length-prefixed bytes (key_prefix).
    3. Per point, the encoded attributes are one byte slice (or their concatenation, when interleaved with other fields). If it equals the previous point's slice in the same metric, that point's series is reused (PreviousPoint).
    4. Otherwise Walk::series builds the key key_prefix + len(name+suffix) + name + suffix + attribute bytes in a reused buffer and looks it up in the SeriesCache (the predicted next entry first, then the hash). Only on a miss are the attributes parsed and translated (series_labels) and the series interned.
  • Correctness: a series' labels are a function of the resource's job/instance/promoted labels, the metric name and suffix, and the point's attribute bytes. The key holds all of them, unambiguously (every part but the last is length-prefixed). So a cache hit always gives the series a fresh translation would give, even when LabelOptions change between requests on the same thread-local decoder. Sketch payload points are never cached. Tests: a_decoder_interns_each_series_once, consecutive_points_share_their_series, interleaved_attributes_decode_as_contiguous_ones, and decoders_give_the_same_series_and_samples (the same series and samples as Remote Write).
  • Complexity: per sample, one walk of the point's fields plus either a slice compare (same attributes as the previous point) or a key copy of about 100 bytes and a compare or hash. A miss costs as before. Memory: one cache entry per series seen per thread (its key bytes), as Remote Write keeps.
  • Measured (decode_bench, an idle 40-core x86 node, pinned to one core, release build, median of four alternating runs (the base runs this PR's decode_bench with decode_otlp_samples adapted to the base signature), base 5f7b20c0 vs this PR):
Shape Remote Write, base → PR (µs/sample) OTLP, base → PR (µs/sample) OTLP / Remote Write, PR
10,000 series × 1 sample 0.106 → 0.104 2.54 → 0.117 1.13x
100 series × 100 samples 0.027 → 0.027 2.48 → 0.081 3.0x

The 100-sample shape stays about 3x Remote Write's, because OTLP repeats each point's attributes and timestamp per sample, where Remote Write lists a series' samples under one label set.

  • Assumptions and limits: a sender that reorders attributes from request to request makes new cache entries for the same label set (correct, but more memory). Remote Write has the same property for label order.

Decisions and open questions

  • Needs reviewer decision:
    1. OTLP/JSON request bodies: 415 here (kept, approved 2026-11-28). Decoding them would need an OTLP JSON mapping. opentelemetry-proto 0.28's serde does not accept numbers for 64-bit fields, nor strings for asInt, both of which the spec allows.
  • Decided (approved with the raw-path report, 2026-11-28): follow Prometheus' resource-attribute convention, with an allow-list flag; reject DELTA sums; no-value points give stale markers (approved 2026-11-28, replacing the earlier drop); keep histograms as they were; reply with protobuf for protobuf requests.

Verification

Scope Result vs base 5f7b20c0 Notes
cargo fmt --all -- --check clean
cargo clippy --workspace --all-targets --locked -- -D warnings clean
cargo test --workspace --locked (ulimit -n 65536) 249 passed, 0 failed, 3 ignored (head f895b85, on #886 c619f61) base 236 passed / 3 ignored; same names plus the 13 new tests below; none newly failing see the flaky test fix below
Parity dump (answers, /metrics names, OTLP replies) only the intended differences see below; vs the previous head c2de050 only the removed asap_otlp_dropped_no_value_points_total lines differ (69,468 B at f895b85, unchanged by the storage fix)
ingest_shards::a_shard_running_ahead_does_not_close_windows_early at f895b85 50/50 alone; 20/20 with three full-suite loops and one busy loop per core alongside (load average 20–34 on 40 cores) before the fix: 16/20 alone on an idle host see "Flaky test fixed" below
decode_bench see table above

New tests:

  • otlp::tests::resource_attributes_give_job_and_instance: job comes from namespace/name over the point's job, instance from service.instance.id, and other resource attributes are not labels.
  • otlp::tests::promoted_resource_attributes_are_labels: promoted attributes have escaped names; a point attribute wins; an absent attribute gives nothing.
  • otlp::tests::attribute_names_are_escaped_as_prometheus_does: the LabelNamer cases, the ; join of colliding names, and empty values giving no label.
  • otlp::tests::delta_sums_are_rejected: DELTA sums are rejected and counted; cumulative and unspecified sums and DELTA histograms are read.
  • otlp::tests::no_recorded_value_points_give_stale_markers: flagged gauge, histogram (with and without _sum) and summary points give StaleNaN for each sample, bit for bit; a value set on a flagged point is not read.
  • otlp::tests::a_decoder_interns_each_series_once: cache hits; a different resource label, name, attribute or option gives a new series.
  • otlp::tests::consecutive_points_share_their_series: the previous-point memo across attributes, metrics and histogram suffixes.
  • otlp::tests::interleaved_attributes_decode_as_contiguous_ones: attributes split by other fields.
  • otlp::tests::replies_are_otlp_messages: the reply and Status encodings, and Encoding::of_content_type.
  • data_plane ingest_protocols::otlp_replies_are_otlp_messages: over HTTP, a 200 protobuf reply, partial_success for 120 DELTA points, a 400 Status, and a 415 JSON Status; also the /metrics counter and phase.
  • ingest_protocols::otlp_points_without_a_recorded_value_are_stale_markers: over HTTP, an OTLP request with one flagged point per series gives the answers and the accepted-sample count (1080) of a Remote Write request with a stale marker in each place.
  • ingest_protocols::otlp_resource_attributes_give_job_and_instance: the planned sum by (job) answers one row, job="shop/cart".
  • storage store::tests::windows_skipped_after_the_stream_start_are_missing: a view whose first stored window is (260, 270] with the stream start at 0 answers (0, 30] and (250, 280] as missing; (-20, -10] (before the stream start) as empty. Fails before the fix.

Test first (stale markers): both new tests fail on the previous head c2de050 (drop): the decoder gives only the unflagged gauge sample, and 1074 samples are accepted instead of 1080 (the answers are equal: the executor drops stale markers when it reads). Earlier, the three ingest_protocols HTTP tests, run on the base (adapted to its API: Status decoded with a local copy of the message, the decode-level part left out), fail. The reply is application/json; 1080 samples are accepted instead of 1074; the answer has rows job0, job1, job2 instead of shop/cart.

Parity dump: the dump of #886, plus an OTLP section with one SDK-like export (3 data gauges of 60 points, each with point attributes job, instance and http.method; one DELTA sum of 60 points; resource service.name=svc, service.instance.id=svc-1, host.name=h1; scope attribute scope.attr=x), a malformed body and a JSON body, then the planned sum by (job) query. Apart from the lines below, the dump is byte-identical to the base (the 65,517 bytes after the OTLP section, once the new /metrics lines are removed). The intended differences:

Dump line Base 5f7b20c0 This PR
Export reply 200, application/json, {"rejected":0} 200, application/x-protobuf, 112 bytes: partial_success { rejected_data_points: 60, error_message: "60 data points of sums with DELTA aggregation temporality were rejected: only cumulative sums are ingested" }
Malformed body 400, text/plain, Protobuf decode error: failed to decode Protobuf message: invalid varint 400, application/x-protobuf, Status { message: "Protobuf decode error: truncated varint" } (the in-place reader's message)
Content-Type: application/json 400, text/plain, a protobuf decode error 415, application/json, {"message":"OTLP/JSON is not supported: send application/x-protobuf"}
sum by (job) (sum_over_time(data[10s])) at 60 {job="j0"} 1110, {job="j1"} 555 (the point attribute job) {job="svc"} 1665 (service.name sets job over the point attribute, as in Prometheus)
/metrics asap_phase_{runs,cpu_seconds,wall_seconds}_total{phase="otlp_decode"}, asap_otlp_rejected_points_total (and the de-duplicated name list repeats the asap_phase_* names after otlp_decode)

Flaky test fixed

ingest_shards::a_shard_running_ahead_does_not_close_windows_early became flaky with this PR's first commit (#886 0/35 failures, this PR about 1 in 15 runs, more on a loaded host). The 8-shard plane answered 422 "materialized view 1 has no rows tiling (0, 30000]" at 30 s, where the 1-shard plane answered 200 with no rows.

  • Cause: the failing side was the 1-shard plane, and the bug is in storage, not in OTLP or sharding.
    • The test writes 600 s of samples in ten one-minute requests. If the coordinator takes several requests before its first window closes, the watermark is already past the view's retention. The ingestion then skips the windows that would already be dropped (close_windows, crates/precompute/src/ingestion.rs). The view's first stored window then starts at 260 s instead of -10 s.
    • ViewStore::read (crates/storage/src/store.rs) took the first stored window as where the view's data starts, because the stream start is declared. So it answered a range reaching back into the skipped windows as empty (200), although those windows had data.
    • A plane that built its first window answered the same range as missing (422). Which case happened depended on timing. This PR changed the timing of request handling but not the logic; storage and precompute are unchanged from chore: pin ASAPPlanner 566b35c and its asap_sketchlib d050037 (view format 5) #886.
  • Fix (commit f895b85): the read's floor is now the earlier of the view's first stored window start and the stream start. Only a range wholly before both reads as empty. At 30 s both planes now answer 422 (evicted), every run.
  • Test first: the new store test above fails before the fix.

Follow-ups

  • target_info series for non-identifying resource attributes, written as Prometheus does (one sample per half lookback delta).
  • Metric-name translation (_total and unit suffixes, escaping), if planned workloads should use Prometheus' OTLP names.
  • OTLP/JSON request decoding, and OTLP over gRPC.
  • The forward-mode tee for /v1/metrics (the route is still not served in forward mode).

@zzylol zzylol added bug Something isn't working area: data plane Runtime ingestion, storage, and query-serving data paths labels Nov 28, 2026
…ELTA sums rejected, in-place decoder

- /v1/metrics replies with a protobuf ExportMetricsServiceResponse
  (partial_success counts rejected points) and google.rpc.Status bodies
  for errors; OTLP/JSON gets 415.
- Labels follow Prometheus' OTLP receiver defaults: point attributes with
  escaped names; service.namespace/service.name -> job,
  service.instance.id -> instance; other resource attributes only via
  --otlp-promote-resource-attributes; scope attributes not labels.
- Sums with DELTA temporality are rejected; points flagged no recorded
  value are dropped; both counted on /metrics.
- The decoder walks the protobuf in place with a series cache (the wire
  reader and cache of prometheus-remote-write, now public modules) and a
  previous-point memo; otlp_decode phase on /metrics.
Prometheus' OTLP receiver writes StaleNaN for each sample of a point
flagged FLAG_NO_RECORDED_VALUE (the value; a histogram's _sum when set
and _count; a summary's _sum and _count), so the series goes stale at
that point. Write the same marker instead of dropping the point; the
Remote Write path keeps stale markers the same way. The drop counter
(Decoded::dropped_no_value_points, asap_otlp_dropped_no_value_points_total)
is removed: nothing is dropped any more.
@zzylol
zzylol force-pushed the fix/otlp-ingest-conformance branch from c2de050 to d5c576b Compare November 28, 2026 05:56
…ead as missing, not empty

When the watermark jumps past a view's retention before its first window
closes, the ingestion skips the windows that would already be dropped, so
the view's first stored window starts after the declared stream start.
The view read took that first window as where the view's data starts and
answered a range reaching back into the skipped windows as empty (200
with no rows), although they had data; a view whose first window was
built answered the same range as missing (422). Which happened depended
on how many requests the coordinator took before its first close, so
ingest_shards' a_shard_running_ahead_does_not_close_windows_early was
flaky: the 1-shard plane sometimes skipped and answered 200 at 30 s while
the 8-shard plane answered 422.

The read's floor is now the earlier of the first stored window's start
and the stream start: only a range wholly before both reads as empty.
New store test windows_skipped_after_the_stream_start_are_missing fails
before the fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: data plane Runtime ingestion, storage, and query-serving data paths bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant