Skip to content

storage/remote: migrate Remote Write 2.x receiver to AppenderV2 - #19459

Closed
krajorama wants to merge 1 commit into
krajo/rw1-receiver-appenderv2-v2from
krajo/rw2-receiver-appenderv2-v2
Closed

krajorama wants to merge 1 commit into
krajo/rw1-receiver-appenderv2-v2from
krajo/rw2-receiver-appenderv2-v2

Conversation

@krajorama

Copy link
Copy Markdown
Member

Part of #17632. Stacked on top of #19457 (RW 1.0 migration) — base branch is krajo/rw1-receiver-appenderv2-v2, so review only the top commit here.

What

The Remote Write 2.x receiver path (writeHandler.writeV2 / appendV2) is ported from V1 storage.Appender to storage.AppenderV2, matching the RW 1.0 path from #19457.

This folds together what #19251 and #19252 did separately, since the reason they were split (avoiding a per-exemplar interface call) no longer applies — AppendExemplars is mandatory and batched on this stack (#19455), so there's no standalone-vs-inline tradeoff to make for exemplars anymore:

  • Start timestamps are now passed directly as the AppenderV2.Append st parameter; the appender owns ST zero-sample injection, so the explicit AppendSTZeroSample / AppendHistogramSTZeroSample calls (and the handleHistogramZeroSample helper) are removed. The receiver still gates on ingestSTZeroSample, preserving prior behaviour.
  • Metadata is attached via AppendV2Options.Metadata on the first sample/histogram append of each series (same approach storage/remote: pass RW 2.0 exemplars and metadata via AppendV2Options #19252 took) — if that append is rejected, metadata is dropped with it. It's best-effort: Append no longer reports metadata errors, so samplesAppendedWithoutMetadata is no longer incremented on this path (the metric stays registered and is still used by the RW 1.0 path).
  • Exemplars are collected per series, sorted by timestamp (required by AppendExemplars's contract), and appended in one batched AppendExemplars call instead of a per-exemplar loop. Out-of-order exemplars still map to a 400; other exemplar errors remain a no-op — preserving prior behaviour.

With both RW 1.0 and 2.x on AppenderV2, the V1 appendable is no longer used by the receiver: NewWriteHandler drops its storage.Appendable parameter and the now-dead remoteWriteAppender wrapper is removed.

Tests

mockAppenderV2.Append now mirrors what a real AppenderV2 implementation does internally: it injects the ST zero-sample (via the existing V1 mock methods) when st != 0, and records metadata via opts.Metadata when present — both best-effort, matching production semantics. Added a case exercising metadata stored via AppendV2Options (appendMetadata: true), which wasn't previously covered — the existing table only tested the disabled case.

NONE

Port the Remote Write 2.x receiver path (writeHandler.writeV2 / appendV2)
from V1 storage.Appender to storage.AppenderV2, matching the RW 1.0 path.

- Start timestamps are now passed directly as the AppenderV2.Append st
  parameter; the appender owns ST zero-sample injection, so the explicit
  AppendSTZeroSample / AppendHistogramSTZeroSample calls (and the
  handleHistogramZeroSample helper) are removed. The receiver still gates
  on ingestSTZeroSample, preserving prior behaviour.
- Metadata is attached via AppendV2Options.Metadata on the first
  sample/histogram append of each series; if that append is rejected,
  metadata is dropped with it. It is best-effort: Append no longer
  reports metadata errors, so samplesAppendedWithoutMetadata is no
  longer incremented on this path (the metric stays registered and is
  still used by the RW 1.0 path).
- Exemplars are collected per series, sorted by timestamp, and appended
  in one batched AppendExemplars call instead of a per-exemplar loop.
  Out-of-order exemplars still map to a 400; other exemplar errors
  remain a no-op, preserving prior behaviour.

With both RW 1.0 and 2.x on AppenderV2, the V1 appendable is no longer
used by the receiver: NewWriteHandler drops its storage.Appendable
parameter and the now-dead remoteWriteAppender wrapper is removed.

Part of #17632.

Signed-off-by: György Krajcsovits <[email protected]>
@krajorama

Copy link
Copy Markdown
Member Author

we might be able to do it simply in one PR, closing this for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant