[APMSVLS-497][APMSVLS-498] test: add fake-intake for APM payload-level tests#1194
Open
lucaspimentel wants to merge 14 commits into
Open
[APMSVLS-497][APMSVLS-498] test: add fake-intake for APM payload-level tests#1194lucaspimentel wants to merge 14 commits into
lucaspimentel wants to merge 14 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces an in-process “fake Datadog intake” test harness for Bottlecap APM payload-level integration testing, enabling assertions on decoded stats/traces payload fields rather than only verifying that an HTTP request occurred.
Changes:
- Add
FakeIntakeaxum server that accepts/api/v0.2/statsand/api/v0.2/traces, decodes bodies, and storespb::StatsPayload/pb::AgentPayloadfor tests. - Add new APM integration tests that exercise the stats and traces flush paths and assert on decoded payload fields.
- Make
StatsFlusher::newaccept an explicit stats intake URL so tests can redirect it to the fake intake; update the production call site accordingly.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| bottlecap/tests/common/mod.rs | Adds a shared tests/common module exposing fake_intake. |
| bottlecap/tests/common/fake_intake.rs | Implements the in-process fake intake server with decoding and captured payload storage. |
| bottlecap/tests/apm_integration_test.rs | Adds payload-level integration tests for stats and traces flush paths. |
| bottlecap/src/traces/stats_flusher.rs | Accepts stats_url in the constructor and logs the actual endpoint used. |
| bottlecap/src/bin/bottlecap/main.rs | Passes trace_stats_url(&config.site) into StatsFlusher::new. |
| bottlecap/Cargo.toml | Adds dev-dependencies for msgpack and gzip decoding used by the fake intake. |
| bottlecap/Cargo.lock | Updates lockfile for the new dev-dependencies. |
duncanista
reviewed
Apr 24, 2026
Contributor
duncanista
left a comment
There was a problem hiding this comment.
Seems like the stats URL change is different to what this PR claims, do we really need them together?
5 tasks
2b10774 to
2e77c12
Compare
Member
Author
I split that small refactor out into #1210 and stacked this PR on that one. |
8f52b41 to
6fbe14b
Compare
2e77c12 to
027f404
Compare
6fbe14b to
56162d9
Compare
f6f171f to
c51ec4d
Compare
4 tasks
56162d9 to
1850777
Compare
…tests Spawns an axum server on a random local port that accepts POSTs on /api/v0.2/stats (msgpack + gzip) and /api/v0.2/traces (protobuf, with zstd/gzip/identity decompression), decodes each body on arrival, and stores the decoded pb::StatsPayload / pb::AgentPayload for tests to query via typed methods. Two integration tests cover both flush paths: - stats_payload_roundtrip_through_fake_intake: drives StatsFlusher::send directly and asserts on decoded hit counts, span kind, peer tags, and HTTP metadata. - trace_payload_roundtrip_through_fake_intake: drives TraceFlusher::flush through the real aggregator and asserts on decoded trace/span IDs and service metadata. Tests redirect StatsFlusher at the fake-intake by passing FakeIntake::stats_url() to StatsFlusher::new, which was lifted to take the URL as a parameter in a prior commit. Prototype for APMSVLS-494 phase 1; extraction to a shared datadog/apm-agent-parity-rs crate is planned for phase 2. Co-Authored-By: Claude <noreply@anthropic.com>
service_source and span_derived_primary_tags were added in 2.0.0 (crates.io) but the workspace pins the git version (1.0.0). 🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
- Return Result instead of panicking on bad decompression; axum converts handler panics to TCP aborts, not 500s, which produces opaque test failures - Warn on unrecognized Content-Encoding instead of silently treating as identity - Make base_url() private; stats_url()/traces_url() cover all uses 🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
base_url() was private and never called; stats_url() and traces_url() accessed the field directly. Removing it also makes the blanket #![allow(dead_code)] in common/mod.rs unnecessary. 🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
fake_intake was re-exported from tests/common/mod.rs, causing it to be compiled into every test binary. logs_integration_test and metrics_integration_test never use it, so the compiler emitted dead-code errors under RUSTFLAGS=-D warnings. Remove the re-export from common/mod.rs and include the module directly in apm_integration_test via #[path]. Remove the now-unused `mod common;` declarations from logs and metrics test files. 🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
The Drop impl already sends the shutdown signal and aborts the task. The explicit shutdown() method was never called in any test. 🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
c51ec4d to
aff7b2f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of changes
Adds an in-process fake intake that lets bottlecap's integration tests decode and inspect real outgoing APM payloads.
The fake intake accepts both APM flush endpoints (
/api/v0.2/statsand/api/v0.2/traces), decodes each request body on arrival, and exposes typed query methods so tests can assert on individual fields. Two new integration tests exercise the fullStatsFlusherandTraceFlusherfake-intake round trip.Reason for change
Allow integration tests to inspect APM payloads and catch regressions.
Implementation details
POST /api/v0.2/statsandPOST /api/v0.2/traces, decodes each body on arrival, and stores the results.Test coverage
Added 2 new tests that server that use the new fake intake and serve as POCs.
Other details
Implements APMSVLS-497 and APMSVLS-498.
After the fake intake is proven and the API is stable, phase 2 will extract
fake_intake.rsinto a shared crate consumed by both bottlecap and SCL.