Repository navigation
Conversation
…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
force-pushed
the
fix/otlp-ingest-conformance
branch
from
November 28, 2026 05:56
c2de050 to
d5c576b
Compare
…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.
This was referenced Nov 28, 2026
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 /v1/metricsdid not behave like an OTLP/HTTP receiver, and it decoded slowly.{"rejected":0}. OTLP/HTTP protobuf exporters (the OpenTelemetry SDKs and the Collector) parse the reply as a protobufExportMetricsServiceResponse, so they counted every successful export as failed (response_decode).service.name,telemetry.sdk.*,host.nameand similar labels, and dotted names that need quoted UTF-8 selectors in PromQL.ExportMetricsServiceResponse, withpartial_successwhen points were rejected. Errors carry agoogle.rpc.Statusbody. OTLP/JSON is not decoded and gets 415.--otlp-promote-resource-attributes a,bpromotes resource attributes to labels, as Prometheus'promote_resource_attributesdoes.partial_successand 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).ingest_shardstest flaky once this PR changed request timing (see "Flaky test fixed").service.namespace=shop, service.name=cart, service.instance.id=cart-7, host.name=node-1givesjob="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
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.crates/adapters/ingest/otlp/src/lib.rs:Walk::metricandWalk::point(the walk, DELTA, no recorded value, the previous-point memo);Walk::seriesandResourceLabels(the cache key);series_labelsandlabel_name(the label rules).crates/data-plane/src/lib.rs:write_otlp, andingest, which now returns the status and message.crates/adapters/ingest/prometheus-remote-write/src/{wire,series_cache}.rs:Reader/Value/varint_slowand the series cache moved out oflib.rsand made public, code unchanged. The cache no longer owns the builder; the Remote Write decoder holds anInterner(the cache plus its builder).benchmarks/micro/decode_bench.rsgains the OTLP half (the same series and samples as one gauge).otlpunit tests moved tosrc/tests.rsand were updated to the new label rules.docs/design/repo-layout.mdanddocs/design/data-plane-demo.md.Behavior: before → after
One export from an OpenTelemetry SDK: a cumulative counter
http_requests_totalwith point attributes{http.method="GET", job="point-job"}and a DELTA sumjobs_donewith one point, under the resource{service.namespace="shop", service.name="cart", service.instance.id="cart-7", host.name="node-1"}and a scopemeterwith attributescope.attr="x".200,content-type: application/json, body{"rejected":0}. The exporter reportsresponse_decodeand counts the export failed.200,content-type: application/x-protobuf, body anExportMetricsServiceResponsewithpartial_success { rejected_data_points: 1, error_message: "1 data points of sums with DELTA aggregation temporality were rejected: only cumulative sums are ingested" }{__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, alsohost_name="node-1"jobs_donepartial_successand inasap_otlp_rejected_points_total0StaleNaN, bits0x7ff0000000000002) for the value (gauge, sum),_sumwhen set and_count(histogram),_sumand_count(summary); the same as a Remote Write stale marker400 text/plain400 application/x-protobuf, agoogle.rpc.Statuswith the messageContent-Type: application/json400(decoded as protobuf, which fails)415 application/json,{"message":"OTLP/JSON is not supported: send application/x-protobuf"}/metricsasap_phase_{runs,cpu_seconds,wall_seconds}_total{phase="otlp_decode"}, plusasap_otlp_rejected_points_totalThis 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 tomath.Float64frombits(value.StaleNaN)whenpt.Flags().NoRecordedValue();helper.godoes the same for a histogram's_sum(only whenHasSum),_countand buckets, and a summary's_sum,_countand quantiles.value.StaleNaNis0x7ff0000000000002(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'sTimeRangedrops 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: 1at 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. Theasap_otlp_dropped_no_value_points_totalcounter 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.gocreateAttributes: point attributes, then promoted resource attributes (only where unset), thenjob/instance(always set), then scope labels only withPromoteScopeMetadata.metrics_to_prw.gosetResourceContext:job=service.namespace + "/" + service.name, orservice.namealone;instance=service.instance.id. The same file'sFromMetricsdrops a metric whose temporality is not cumulative unless delta ingestion is on ("invalid temporality and type combination"); the handler still replies 200.config/config.goDefaultOTLPConfig:TranslationStrategy: UnderscoreEscapingWithSuffixes(so UTF-8 names are not kept and are escaped),LabelNameUnderscoreSanitization: true,LabelNamePreserveMultipleUnderscores: true;promote_scope_metadatadefaults to false.prometheus/otlptranslatorLabelNamer.Buildandstrconv.gosanitizeLabelName: every character other than[a-zA-Z0-9]becomes_; a leading digit getskey_; a single leading_getskey; 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
otlpcrate docs):_totalor unit suffix. Translating them would rename planned series._sumand_count, whatever their temporality). A sum of unspecified temporality is read as cumulative. Prometheus drops both.[1, 2](Prometheus: base64),1e21as1000000000000000000000(Prometheus:1e+21); both unchanged. Arrays and maps print as empty text, so no label (Prometheus: JSON text).kll.,cms.orcountsketch.sketch_payload) are skipped, as before and as ASAPQuery does.Content-Typeother thanapplication/jsonis read as protobuf. Prometheus refuses unknown types with 400. Our behavior is unchanged from before.Interfaces
crates/adapters/ingest/otlp/src/lib.rsPointand the freedecodeare replaced byDecoder, 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 fromlib.rs, now public forotlp)crates/data-plane/src/lib.rs(DataPlanestays),remote_write.rs,main.rsimpl 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):Algorithm changes
OTLP decode: in-place walk with a series cache
otlp::decodebuilt the wholeExportMetricsServiceRequestwith prost, allocating every string, then cloned aBTreeMapof labels per point and per sample, andintern_pairshashed 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.ExportMetricsServiceRequest::decodeallocates every message.BTreeMapof scope and resource attributes is built.__name__, then collected to aVec<(String, String)>.intern_pairsis called per sample.Walk::request→resource_metrics→metric→pointwalk the bytes with the Remote Writewire::Reader; nothing is allocated per point.ResourceLabels::newcomputesjob,instanceand the promoted labels once per resource, and their length-prefixed bytes (key_prefix).PreviousPoint).Walk::seriesbuilds the keykey_prefix + len(name+suffix) + name + suffix + attribute bytesin a reused buffer and looks it up in theSeriesCache(the predicted next entry first, then the hash). Only on a miss are the attributes parsed and translated (series_labels) and the series interned.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 whenLabelOptionschange 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, anddecoders_give_the_same_series_and_samples(the same series and samples as Remote Write).decode_bench, an idle 40-core x86 node, pinned to one core, release build, median of four alternating runs (the base runs this PR'sdecode_benchwithdecode_otlp_samplesadapted to the base signature), base5f7b20c0vs this PR):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.
Decisions and open questions
opentelemetry-proto0.28's serde does not accept numbers for 64-bit fields, nor strings forasInt, both of which the spec allows.Verification
5f7b20c0cargo fmt --all -- --checkcargo clippy --workspace --all-targets --locked -- -D warningscargo test --workspace --locked(ulimit -n 65536)f895b85, on #886c619f61)/metricsnames, OTLP replies)c2de050only the removedasap_otlp_dropped_no_value_points_totallines differ (69,468 B atf895b85, unchanged by the storage fix)ingest_shards::a_shard_running_ahead_does_not_close_windows_earlyatf895b85decode_benchNew tests:
otlp::tests::resource_attributes_give_job_and_instance:jobcomes from namespace/name over the point'sjob,instancefromservice.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: theLabelNamercases, 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 giveStaleNaNfor 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 andStatusencodings, andEncoding::of_content_type.data_planeingest_protocols::otlp_replies_are_otlp_messages: over HTTP, a 200 protobuf reply,partial_successfor 120 DELTA points, a 400Status, and a 415 JSONStatus; also the/metricscounter 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 plannedsum by (job)answers one row,job="shop/cart".storagestore::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 threeingest_protocolsHTTP tests, run on the base (adapted to its API:Statusdecoded with a local copy of the message, the decode-level part left out), fail. The reply isapplication/json; 1080 samples are accepted instead of 1074; the answer has rowsjob0,job1,job2instead ofshop/cart.Parity dump: the dump of #886, plus an OTLP section with one SDK-like export (3
datagauges of 60 points, each with point attributesjob,instanceandhttp.method; one DELTA sum of 60 points; resourceservice.name=svc, service.instance.id=svc-1, host.name=h1; scope attributescope.attr=x), a malformed body and a JSON body, then the plannedsum 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/metricslines are removed). The intended differences:5f7b20c0200,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" }400,text/plain,Protobuf decode error: failed to decode Protobuf message: invalid varint400,application/x-protobuf,Status { message: "Protobuf decode error: truncated varint" }(the in-place reader's message)Content-Type: application/json400,text/plain, a protobuf decode error415,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 attributejob){job="svc"} 1665(service.namesetsjobover the point attribute, as in Prometheus)/metricsasap_phase_{runs,cpu_seconds,wall_seconds}_total{phase="otlp_decode"},asap_otlp_rejected_points_total(and the de-duplicated name list repeats theasap_phase_*names afterotlp_decode)Flaky test fixed
ingest_shards::a_shard_running_ahead_does_not_close_windows_earlybecame 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 answered422 "materialized view 1 has no rows tiling (0, 30000]"at 30 s, where the 1-shard plane answered200with no rows.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.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.Follow-ups
target_infoseries for non-identifying resource attributes, written as Prometheus does (one sample per half lookback delta)._totaland unit suffixes, escaping), if planned workloads should use Prometheus' OTLP names./v1/metrics(the route is still not served in forward mode).