Repository navigation
Conversation
bwplotka
left a comment
There was a problem hiding this comment.
Interesting, I'd opt for a different logic
| // the combined AppenderV2.Append. AppendV2Options.Exemplars must be sorted by | ||
| // timestamp. | ||
| var exemplars []exemplar.Exemplar | ||
| for _, ep := range ts.Exemplars { |
There was a problem hiding this comment.
This is tricky given #19250 (comment) gap.
(Technically we should if Exemplar > 0 AND no sample and no histogram - we should likely write to standalone Exemplar for now. Then if it's related to sample/histogram we should either write to (A1) all(or (A2) first if we don't trust dedup logic) OR (B) change proto to have a new Exemplar field per sample so this logic is explicit.
| } | ||
| exemplars = append(exemplars, e) | ||
| } | ||
| slices.SortStableFunc(exemplars, func(a, b exemplar.Exemplar) int { return cmp.Compare(a.Ts, b.Ts) }) |
There was a problem hiding this comment.
We could also consider requiring this from protocol perspective
| } | ||
| // firstOpts returns opts for the first sample/histogram of the series and | ||
| // empty options for the rest, so exemplars and metadata are attached once. | ||
| firstOpts := func() storage.AppendV2Options { |
There was a problem hiding this comment.
again, metadata should be safe to be attached again
There was a problem hiding this comment.
also in practice we shouldn't see penalty (we always send 1 sample)
Part of the migration off the V1 storage.Appender interface (#17632). Builds on the Remote Write 2.x AppenderV2 migration. The previous step ported writeV2 to AppenderV2 but still appended exemplars and metadata through the standalone AppendExemplar / UpdateMetadata calls. This takes advantage of the combined AppenderV2.Append: for each received series, the exemplars (sorted by timestamp, as the interface requires) and metadata are attached to the first sample or histogram append via AppendV2Options, and the remaining appends of the series carry empty options. Consequences: - Exemplar results now come back as storage.AppendPartialError from that first Append. The X-Prometheus-Remote-Write-Written-Exemplars count is derived from it (appended = provided - errored), out-of-order exemplars still map to a 400, and other exemplar errors remain a no-op, preserving the previous behaviour. - Metadata is best-effort within Append and no longer reports an error, so the samplesAppendedWithoutMetadata increment is dropped from the RW 2.x path (the metric stays registered and is still used by the RW 1.0 path). No test asserts this metric. - remoteWriteAppenderV2.UpdateMetadata is removed as it is no longer used. Note: exemplars/metadata are attached to the first sample/histogram, so if that first append is rejected (e.g. an out-of-order first sample) they are dropped with it; previously exemplars were appended in a separate pass. This only affects that edge case. A new test case exercises metadata stored via AppendV2Options (metadata storage was previously not covered by the handler test). Signed-off-by: György Krajcsovits <[email protected]> Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Signed-off-by: György Krajcsovits <[email protected]>
53a4cf6 to
c517673
Compare
|
favor #19457 over this |
Part of #17632. Stacked on top of #19251 — base branch is
krajo/rw2-receiver-appenderv2, so review only the top commit here.What
#19251 ported the RW 2.x receiver to
AppenderV2but still appended exemplars and metadata through the standaloneAppendExemplar/UpdateMetadatacalls. This takes advantage of the combinedAppenderV2.Append: for each received series, exemplars (sorted by timestamp, as the interface requires) and metadata are attached to the first sample/histogram append viaAppendV2Options, and the remaining appends of the series carry empty options.Consequences
storage.AppendPartialErrorfrom that firstAppend.X-Prometheus-Remote-Write-Written-Exemplarsis derived from it (appended = provided − errored); out-of-order exemplars still map to400, other exemplar errors remain a no-op — preserving prior behaviour.Appendand no longer reports an error, so thesamplesAppendedWithoutMetadataincrement is dropped from the RW 2.x path. The metric stays registered and is still used by the RW 1.0 path. No test asserts it.remoteWriteAppenderV2.UpdateMetadatais removed (no longer used).Edge case
Exemplars/metadata attach to the first sample/histogram, so if that first append is rejected (e.g. an out-of-order first sample) they are dropped with it; previously exemplars were appended in a separate pass. This only affects that specific case.
Tests
The mock's V2 appender now records
opts.Exemplars/opts.Metadataand returns partial errors, so the existing V2-message assertions hold. Added a case exercising metadata stored via AppendV2Options — metadata storage was previously not covered by the handler test.