Skip to content

Turn the otel-app sink into a fake backend for sketches and raw fragments - #613

Merged
zzylol merged 2 commits into
mainfrom
feat/fake-sink
Nov 9, 2026
Merged

zzylol merged 2 commits into
mainfrom
feat/fake-sink

Conversation

@zzylol

@zzylol zzylol commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Why

The backend cannot ingest the Collector's output yet. Until it can, the edge Collector's two outputs (sketch metrics over OTLP/gRPC and raw Gorilla fragments over HTTP) need somewhere to go that accepts them, reports what arrived, and can save the bodies for an offline accuracy check.

What

otel-app/sink becomes a fake backend that only receives:

  • OTLP/gRPC Export (-grpc, default :4317). Sketch data points are counted per sketch kind and encoding: DDSketch, KLLSketch, CountSketch, CountMinSketch, HLLSketch and SumAgg, each with Proto/ProtoDelta/Delta/Msgpack/MsgpackDelta. Any *Delta encoding is a delta payload, the rest are full state. Plain gauge/sum/histogram/summary points keep the existing SINK_STATS counts. The sink now accepts gzip-compressed exports.
  • HTTP POST /ingest/gorilla (-http, default :10908, the gorilla-merger port). This takes the cold fragment shipper's gzipped ASAPFRG1 frame. The sink counts requests, gzip and decompressed bytes, fragments, distinct series and samples.
  • -dump-dir (optional). Each request body goes to its own file, <receive-unix-ns>-<otlp|gorilla>-<seq>.bin. Without the flag, nothing is written.
  • -stats-every (optional). Prints the totals periodically. The totals are always printed on SIGINT/SIGTERM.

The sink does no merging, querying or accuracy computation.

How

  • OTLP is decoded with the patched collector pdata (pmetricotlp), the module the asapedgeprocessor encodes with (asap-precompute-go/otel.Encode). The patched proto bindings that the sink used before have no SumAgg variant, so Sum aggregations were invisible to it. otel-app/go.mod gains a replace go.opentelemetry.io/collector/pdata => ../opentelemetry-collector/pdata, set up the same way as the existing opentelemetry-go and proto replaces.
  • Full vs delta is read from each data point's encoding enum. That enum is the only place the edge marks it: otel.Encode maps precompute.EncodingProtoDelta/EncodingMsgpackDelta to the *Delta values.
  • Fragments are decoded with the existing gorilla.DecodeFragmentBatch and gorilla.DecodeFragmentSamples. Series are keyed by gorilla.FragmentLabels.
  • Gorilla dump files hold the body exactly as received (gzipped). OTLP dump files hold the ExportMetricsServiceRequest protobuf re-marshalled from the decoded request, because gRPC decodes the message before the handler runs.
  • The gRPC listen address moves from a positional argument to -grpc. No script in the repo passed it.

Before

  • The sink accepted only OTLP/gRPC and counted plain datapoints.
  • Sketch metrics were not broken down.
  • SumAgg was not seen.
  • gzip-compressed exports were rejected because no gzip decompressor was registered.
  • There was no endpoint for cold fragments and no way to keep the bodies.

After

SINK_STATS reqs=… datapoints=… bytes=…
SINK_SKETCH kind=DDSketch encoding=ProtoDelta mode=delta msgs=… bytes=…
SINK_RAW reqs=… gzip_bytes=… bytes=… fragments=… series=… samples=…

To use it, point the edge Collector's OTLP exporter at -grpc and cold.ship_endpoint at http://<sink>:10908/ingest/gorilla.

Verification

TestSinkCountsAndDumps sends:

  • one DDSketch delta envelope, built with otel.Encode and exported over gzip gRPC;
  • one gzipped ASAPFRG1 frame with 2 series and 5 samples, built with StreamingFragmentEncoder and EncodeFragmentBatch.

It checks every counter. It also checks that the dump dir holds exactly two files whose bytes equal the sent bodies.

go test -count=1 ./sink   # ok
go vet ./sink             # ok
go build .                # otel-app main still builds with the go.mod change

These were run against sketchlib-go main (cf7dac6) and again against the earlier CI pin (148643f). Both passed.

…ents

The backend cannot ingest the Collector's output yet, so the sink now
receives both outputs and only counts them:

- OTLP/gRPC Export, decoded with the patched pdata so every sketch
  variant (including SumAgg) is seen; sketch data points are counted per
  kind and encoding, where a *Delta encoding marks a delta payload.
  gzip-compressed exports are accepted.
- HTTP POST /ingest/gorilla, the cold fragment shipper's gzipped ASAPFRG1
  frame, decoded with asap-gorilla-go to count fragments, series and
  samples.

-dump-dir writes each request body to its own file for offline accuracy
comparison. The listen address moves from a positional argument to
-grpc, and -stats-every prints totals periodically.
@zzylol zzylol added the enhancement New feature or request label Nov 9, 2026
@zzylol
zzylol marked this pull request as ready for review November 9, 2026 03:50
@zzylol
zzylol merged commit 95dfe22 into main Nov 9, 2026
1 check failed
@zzylol
zzylol deleted the feat/fake-sink branch November 9, 2026 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant