Skip to content

KLL: OTLP export and sketch serialization - #75

Merged
zzylol merged 3 commits into
mainfrom
kll_integration
Mar 25, 2026
Merged

zzylol merged 3 commits into
mainfrom
kll_integration

Conversation

@GnaneshGnani

@GnaneshGnani GnaneshGnani commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

Changes

  1. Code changes

    • Added OTLP sketch payload export behavior for KLL output flow.
    • Switched KLL sketch payload emission to a portable protobuf envelope in the KLL processor.
    • Updated processor:
      • processor/kllprocessor/processor.go
  2. Implementation pattern used in the processor

    • Build sketch state using sketchlib.
    • Convert sketch to a portable envelope using SerializePortable().
    • Encode the envelope with proto.Marshal(env).
    • Attach encoded bytes into OTLP metric attributes for Sketch Payload Flow.
    • Keep Raw Metrics Flow behavior unchanged unless the selected mode intentionally emits sketch-only output.
  3. Go module file changes

    • Updated KLL processor-local module files to support portable serialization path:
      • processor/kllprocessor/go.mod
      • processor/kllprocessor/go.sum
  4. OTLP exporter compatibility settings

    • encoding: proto
    • compression: gzip or none

Compression notes

  • gzip is supported in both flows and is currently configured in KLL test configs for both Raw Metrics Flow and Sketch Payload Flow.
  • gzip is recommended for sketch-heavy Sketch Payload Flow traffic.
  • none is supported and useful for debugging payload size behavior, but it can hit request size limits more easily depending on environment limits.

OTLP message shape

Common wire format (both flows):

  • OTLP HTTP endpoint: POST /v1/metrics
  • OTLP gRPC service/method: opentelemetry.proto.collector.metrics.v1.MetricsService/Export
  • Body: Protobuf ExportMetricsServiceRequest
  • Optional HTTP compression: gzip (or none)

gRPC transport notes

  • gRPC uses the same ExportMetricsServiceRequest message as HTTP.
  • There is no HTTP path like /v1/metrics in gRPC; the RPC method is MetricsService.Export.
  • In local runs in this integration, gRPC receiver is typically on :4317 and HTTP receiver on :4318.
  • Message shape inside the payload is identical across HTTP and gRPC (same resource_metrics -> scope_metrics -> metrics -> data_points structure).

Shared top-level structure:

ExportMetricsServiceRequest {
    resource_metrics: [
        {
            resource: { attributes: [...] },
            scope_metrics: [
                {
                    scope: { name, version, attributes[...] },
                    metrics: [ ... ]
                }
            ]
        }
    ]
}

Raw Metrics Flow message shape

In this flow, data points carry numeric values directly (gauge/sum/etc.).

ExportMetricsServiceRequest {
    resource_metrics: [
        {
            scope_metrics: [
                {
                    metrics: [
                        {
                            name: "http_requests_total",
                            data: Sum {
                                data_points: [
                                    {
                                        time_unix_nano: 1710000000000000000,
                                        attributes: {
                                            "service.name": "checkout",
                                            "method": "GET",
                                            "status": "200"
                                        },
                                        as_int | as_double: 42
                                    }
                                ]
                            }
                        }
                    ]
                }
            ]
        }
    ]
}

How ASAPQuery treats it:

  • No sketch payload attribute is present.
  • Points are parsed as regular metrics and routed as Raw Metrics Flow.

Sketch Payload Flow message shape (KLL)

In this flow, processor attaches serialized sketch bytes into OTLP attributes.
Sketch bytes are produced as:

  1. SerializePortable()
  2. proto.Marshal(...)
  3. store resulting bytes in a sketch payload attribute

Expected sketch payload attribute key in this PR:

  • kll.sketch_payload
ExportMetricsServiceRequest {
    resource_metrics: [
        {
            scope_metrics: [
                {
                    metrics: [
                        {
                            name: "kll_latency",
                            data: Gauge {
                                data_points: [
                                    {
                                        time_unix_nano: 1710000000000000000,
                                        attributes: {
                                            "service.name": "checkout",
                                            "region": "us-east-1",
                                            "kll.k": 256,
                                            "kll.count": 1200,
                                            "kll.sketch_payload": <bytes>
                                        },
                                        as_double: 1200
                                    }
                                ]
                            }
                        }
                    ]
                }
            ]
        }
    ]
}

How ASAPQuery treats it:

  • If kll.sketch_payload is present, the point is classified as Sketch Payload Flow.
  • Payload bytes are logged/processed as sketch data, not as a regular raw numeric point.

How to test these changes

1) Start ASAPQuery OTLP receiver

From ASAPQuery/:

cd ASAPQuery
RUST_LOG=query_engine_rust=debug ./target/release/query_engine_rust \
    --enable-otel-ingest \
    --otel-grpc-port 4317 \
    --otel-http-port 4318 \
    --kafka-topic dummy \
    --input-format json \
    --config asap-query-engine/examples/promql/inference_config.yaml \
    --streaming-config asap-query-engine/examples/promql/streaming_config.yaml \
    --streaming-engine arroyo \
    --prometheus-scrape-interval 15 \
    --output-dir /tmp/asapquery \
    --query-language promql \
    --lock-strategy global

Expected startup logs include OTLP listeners on :4317 (gRPC) and :4318 (HTTP).

2) Run KLL processor config

From DataCollector/opentelemetry-collector-contrib-patch/:

Raw Metrics Flow:

cd /home/gnanesh/ProjectASAP/DataCollector/opentelemetry-collector-contrib-patch
./KLL --config cmd/kll/asap_query_config/config-otlp-pathway1.yaml

Sketch Payload Flow (KLL, batch):

cd /home/gnanesh/ProjectASAP/DataCollector/opentelemetry-collector-contrib-patch
./KLL --config cmd/kll/asap_query_config/config-otlp-pathway2-batch.yaml

3) Run load generator

From DataCollector/otel_collector_benchmark/:

cd ProjectASAP/DataCollector/otel_collector_benchmark
go run main.go --endpoint localhost:53217 --workers 2 --hosts 5 --metrics 10 --duration 15s

Notes:

  • Use localhost:53217 when the processor otlp receiver gRPC endpoint is 0.0.0.0:53217.
  • For HTTP load into processor receiver, use the matching HTTP endpoint and sender tooling.

@GnaneshGnani GnaneshGnani changed the title Update KLL processor sketch serialization KLL: OTLP export and sketch serialization Mar 24, 2026
@GnaneshGnani
GnaneshGnani requested a review from zzylol March 24, 2026 04:22
@GnaneshGnani GnaneshGnani linked an issue Mar 24, 2026 that may be closed by this pull request
5 tasks
@zzylol
zzylol merged commit dacec8c into main Mar 25, 2026
@zzylol
zzylol deleted the kll_integration branch March 25, 2026 10:42
SieDeta pushed a commit that referenced this pull request Apr 17, 2026
* Update KLL processor sketch serialization

* Restore KLL non-serialization logic

* rename pathway references
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.

Connecting DataCollector and ASAPQuery

2 participants