Skip to content

refactor(emit): re-target agent OTLP export from gateway:4317 → backend:4317 - #243

Merged
zzylol merged 1 commit into
mainfrom
retarget-agent-export-to-backend
May 15, 2026
Merged

zzylol merged 1 commit into
mainfrom
retarget-agent-export-to-backend

Conversation

@zzylol

@zzylol zzylol commented May 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Pre-flight for the upcoming ASAPCollector deployment PR that collapses the data path from
agent → gateway → asapquery-backend to agent → asapquery-backend.

Why this works: asapquery-backend's --enable-otel-ingest already accepts *SketchDataPoints and routes them through the precompute engine's accumulators (DDSketchAccumulator / HLLAccumulator / etc.) — these merge per-aggregation_id across all incoming agents server-side. No middle-tier OTel gateway merge processor is needed.

Functional changes

  • ThreeStageEmitter::emit_per_stage — default EdgeStageConfig.exporter_target flips from Stage(StageId::Gateway)Stage(StageId::Backend).
  • All 4 edge-emit call sites of build_otlp_exporter / resolve_export_endpoint flip default_host from "gateway""backend":
    • emit_edge_yaml (stage_config.rs:231)
    • emit_edge_yaml_5sketch_routing variant (stage_config.rs:966)
    • OTAP edge emit, Modes 1 and 2 (otap.rs:191, 205)
    • Telegraf edge emit, Modes 1 and 2 (telegraf.rs:90, 95)
  • emit_gateway_yaml unchanged — the gateway's own OTLP exporter still targets backend:4317 (correct, when a deployment does run a gateway).

Kept-in-source per ”keep gateway impl in repos” intent

  • emit_gateway_yaml, StageConfig::Gateway, AgentRole::Gateway push — all preserved. They no longer reach any subscriber in the default deployment, but topologies re-introducing a middle tier can flip EdgeStageConfig.exporter_target back to Stage(Gateway) post-emit.

Test plan

  • cargo check clean (only pre-existing warnings)
  • cargo test --lib: 686 passed; 0 failed
  • cargo test --tests --bins: 27 passed; 0 failed
  • 3 assertions that the agent's emitted YAML/TOML contains gateway:4317 flip to assert backend:4317.

🤖 Generated with Claude Code

…nd:4317

The deployment is collapsing the data path from
  agent → gateway → asapquery-backend
to
  agent → asapquery-backend
because asapquery-backend's `--enable-otel-ingest` already accepts
sketch data points and merges them per-aggregation_id via its precompute
engine accumulators (DDSketchAccumulator / HLLAccumulator / etc.) — no
middle-tier OTel gateway merge processor is required.

Functional changes:

- `ThreeStageEmitter::emit_per_stage` (emitter.rs:379): default
  `EdgeStageConfig.exporter_target` flips from `Stage(StageId::Gateway)`
  to `Stage(StageId::Backend)`. Comment added explaining the rationale.
- All 4 edge-emit call sites of `build_otlp_exporter` /
  `resolve_export_endpoint` flip `default_host` from `"gateway"` to
  `"backend"`:
    * `emit_edge_yaml`                          (stage_config.rs:231)
    * `emit_edge_yaml_5sketch_routing` variant  (stage_config.rs:966)
    * OTAP edge emit, Modes 1 and 2             (otap.rs:191, 205)
    * Telegraf edge emit, Modes 1 and 2         (telegraf.rs:90, 95)
- `emit_gateway_yaml` (stage_config.rs:461) unchanged — the gateway's
  own OTLP exporter still targets `backend:4317` (correct).

Code kept-but-unused:
- `emit_gateway_yaml` + `StageConfig::Gateway` + `AgentRole::Gateway`
  push remain in source. They no longer reach any subscriber in the
  default deployment but are preserved per the "keep gateway impl in
  source" intent. Topologies that re-introduce a middle tier can flip
  EdgeStageConfig.exporter_target back to Stage(Gateway) post-emit.

Test updates:

- The 3 assertions that the agent YAML/TOML contains `gateway:4317` flip
  to assert `backend:4317`:
    * `stage_config.rs:1509-1513` (OTel agent yaml)
    * `otap.rs:461-464`           (OTAP agent yaml)
    * `telegraf.rs:367-370, 399-402` (Telegraf agent toml)
- Doc-comment at `stage_config.rs:1196-1199` and the inline rationale
  at `stage_config.rs:228` updated.

Build: clean. 686 lib tests + 27 binary tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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