Honeycomb for Test-Failure Root Cause in Agentic QE
Most CI pipelines leave two artifacts when a test fails: a JUnit XML file and a wall of stdout. Engineers open the log, search for "ERROR" and start guessing. That works for a handful of flaky tests and then collapses, because logs say what happened, not why it happened on this run, on this worker, with this dependency version, when it did not yesterday.
Honeycomb is built around wide events: single structured records that carry every dimension of an operation. Applied to test execution, one event per test lets you compare failing and passing runs across runner, image tag, environment and retry count in one query. That comparison is also what agentic quality engineering needs. Failures in tests that call a model or drive an agent depend on dimensions logs rarely capture: model version, prompt version, which tool was called, how many steps the agent took. With those on the event, the same analysis that finds a bad runner finds a bad prompt.
This article covers why wide events change failure triage, how to instrument pytest with OpenTelemetry and send spans to Honeycomb, how to use BubbleUp and the Query API, where instrumentation goes wrong, and how to apply the approach to eval and agent failures.
Learn Python, Behave, GitHub Copilot, APIs, and CI/CD by building a real framework you can finish in a weekend.
Why Wide Events Change the Failure-Triage Model
A wide event in Honeycomb is a JSON object with no schema restrictions — you emit one per test case and stuff it with every relevant dimension: test name, suite, runner ID, retry number, outcome, wall-clock duration, Git SHA, branch, environment, external service latency, container image tag. Honeycomb stores these in a columnar store optimized for high-cardinality GROUP BY queries, not for full-text search. That distinction matters: Loki is excellent for failure tracking when you already know what string to look for; Honeycomb is better when you don't know which dimension is the culprit.
In a modern test architecture, Honeycomb sits alongside — not instead of — your existing observability stack. Loki or Datadog Logs handle raw stdout; Prometheus or Datadog Metrics track suite-level pass rates over time; Honeycomb handles the structured trace data that lets you answer "which combination of runner OS, DB version, and retry count predicts the checkout_flow failures?" That's a query no log aggregator answers cheaply, and it's the question that cuts duration variance investigations from hours to minutes.
Instrumenting Tests with OpenTelemetry and Querying BubbleUp
Start by emitting one span per test case using the OpenTelemetry Python SDK. The span carries the test result as a structured attribute, not buried in a log message. Wire this into a Pytest plugin so every test in the suite is covered without per-test boilerplate:
# conftest.py — OTel span per test case
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace.export import BatchSpanProcessor
import pytest, os, time
provider = TracerProvider()
provider.add_span_processor(
BatchSpanProcessor(OTLPSpanExporter(
endpoint="https://api.honeycomb.io/v1/traces",
headers={"x-honeycomb-team": os.environ["HONEYCOMB_API_KEY"],
"x-honeycomb-dataset": "ci-test-results"} # dataset header: Honeycomb Classic only
))
)
trace.set_tracer_provider(provider)
tracer = trace.get_tracer("pytest.suite")
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_protocol(item, nextitem):
with tracer.start_as_current_span(item.nodeid) as span:
span.set_attribute("test.suite", item.module.__name__)
span.set_attribute("ci.runner", os.environ.get("RUNNER_NAME", "local"))
span.set_attribute("ci.branch", os.environ.get("GITHUB_REF_NAME", ""))
span.set_attribute("ci.sha", os.environ.get("GITHUB_SHA", ""))
span.set_attribute("env.tier", os.environ.get("DEPLOY_ENV", "staging"))
span.set_attribute("db.version", os.environ.get("DB_IMAGE_TAG", ""))
outcome = yield # the protocol hook's result is not a test report
span.set_attribute("test.passed", not getattr(item, "_otel_failed", False))
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item, call):
outcome = yield
rep = outcome.get_result() # a TestReport for setup, call or teardown
span = trace.get_current_span() # still the test span: we are inside runtest_protocol
if rep.failed:
item._otel_failed = True
span.set_attribute("test.failure_msg", str(rep.longrepr)[:500])
span.set_attribute("test.failed_phase", rep.when)
span.set_status(trace.StatusCode.ERROR)
The db.version and env.tier attributes are the ones most likely to surprise you — after a couple of weeks of data, BubbleUp may show that failures of one test cluster on a particular database image or environment tier. That kind of correlation is invisible in a flat log stream.
Once data is flowing, the BubbleUp query is straightforward. In Honeycomb's UI, run a query over the test spans, open BubbleUp, and select the failing spans (test.passed = false) as the area of interest; BubbleUp ranks every attribute by how much it over-indexes in that selection versus the rest. The output is a ranked list of field/value pairs, showing how differently each value is distributed in the selected failures versus the baseline; start with the top few. You can also drive the underlying breakdown query programmatically via the Honeycomb Query API (creating a query returns an ID that you then run through the query results endpoint):
# Honeycomb Query API — find top failure-correlated dimensions
POST https://api.honeycomb.io/1/queries/{dataset}
{
"time_range": 604800,
"filters": [{"column": "test.passed", "op": "=", "value": false}],
"breakdowns": ["ci.runner", "db.version", "env.tier"],
"calculations": [
{"op": "COUNT"},
{"op": "P95", "column": "duration_ms"}
],
"orders": [{"op": "COUNT", "order": "descending"}],
"limit": 25
}
Wiring this query into a Slack alert makes it useful during triage: a bot can post the top correlated dimensions alongside the failing test name, so the on-call engineer sees "runner=ci-worker-07, db.version=postgres:15.1" before opening a single log file. That's the payoff — not the dashboard, but the pre-answered question. For teams dealing with failure clustering that obscures distinct root causes, the BubbleUp dimension ranking is especially valuable because it separates correlated failures by their actual predictive attributes rather than grouping them by error message alone.
Where Honeycomb Instrumentation Goes Wrong in CI
The most common mistake is emitting spans only for failing tests, treating Honeycomb like an error log. BubbleUp's statistical power comes from comparing the failure population against the passing population — without passing spans, the baseline doesn't exist and the ranked dimensions are meaningless noise. Instrument every test, every run. Honeycomb prices by event volume, so budget for passing spans rather than dropping them; without them, the comparison BubbleUp depends on does not exist.
A subtler problem is attribute cardinality on the wrong fields. Putting raw stack traces or full SQL queries in span attributes explodes cardinality without adding query value — put those in test.failure_msg truncated to 500 characters and log the full trace to Loki. Keep your high-cardinality attributes meaningful and bounded: runner ID, image tag, branch name, retry count. Teams also routinely forget to propagate the trace context from their CI orchestrator (GitHub Actions job ID, Argo Workflows workflow UID) into the span, which breaks the ability to correlate a test failure with the specific pipeline run that triggered it — a gap that makes systematic flaky-test root cause analysis much harder when you need to replay the exact environment.
Wide events for eval failures and agent runs
The BubbleUp workflow transfers directly to tests that call a model. The question changes from "which runner predicts this failure?" to "which prompt version, model version or tool predicts this bad answer?", and the method is the same: emit one wide event per sample, passing and failing, and let the comparison find the dimension.
For each eval sample or agent test run, add attributes such as these to the test span:
span.set_attribute("eval.case_id", case_id)
span.set_attribute("eval.sample", sample_index) # 0..N-1 for repeated runs
span.set_attribute("model.version", model_version)
span.set_attribute("prompt.version", prompt_version)
span.set_attribute("agent.steps", len(steps))
span.set_attribute("agent.tools_called", ",".join(sorted({s.tool for s in steps})))
span.set_attribute("judge.version", judge_version) # if an LLM grades the output
span.set_attribute("eval.passed", passed)
Because model-calling tests vary by design, a single failure means little. Run each case several times, select the failing samples in BubbleUp, and look at what over-indexes. If failures concentrate on one prompt.version, the last prompt edit is the suspect. If they concentrate on runs where agent.steps is high, the agent is looping. If they move with judge.version, check the judge before blaming the product.
Keep prompt text and model output out of span attributes. They can carry user data, and they are high-cardinality text that adds cost without helping BubbleUp. Store them in a masked store keyed by trace ID.
BubbleUp output is also good input for an LLM triage step, for the reason the myths section gives: the model then starts from "failures cluster on prompt version 14" rather than guessing from error text. Its summary is a proposal for the owner to confirm. For more on that failure mode, see how AI failure classifiers misread cascading failures.
Myths About Logs, Traces, and Failure Triage with AI
Myth 1: Loki (or any log aggregator) is sufficient for failure triage. Loki is excellent for full-text search once you have a hypothesis. It's poor at generating the hypothesis — "which dimension predicts this failure class?" requires structured GROUP BY across high-cardinality fields, which is exactly what Loki's label-based indexing is not designed for. Use both: Loki for the raw output, Honeycomb for the dimensional analysis. Myth 2: AI root-cause suggestion replaces structured tracing. LLM-based triage tools (ChatGPT, Claude integrations in CI) are useful for summarizing stack traces but often misfire on environment-driven failures because they pattern-match on error text, not on infrastructure dimensions. The BubbleUp approach surfaces "this runner is the problem" before the AI even sees the log — that pre-filtering is what makes AI-assisted triage accurate rather than confidently wrong.
Myth 3: Pass/fail rate is the primary signal worth tracking. A suite with a stable 98% pass rate can still have a P95 test duration that's drifting 40% week-over-week — a leading indicator of infrastructure degradation that won't show up as a failure until it's a CI timeout incident. Wide events capture duration as a first-class attribute, so you can alert on variance trends, not just binary outcomes. The failure rate number is a lagging indicator; the dimensional distribution of duration and retry count is where the early signal lives.
The pattern here — OTel spans per test, wide events in Honeycomb, BubbleUp for dimension ranking — is repeatable across any test framework that supports hooks (Pytest, JUnit, Playwright, k6). Start with 10 attributes per span, run for two weeks, and let the data tell you which dimensions matter before adding more. If you're building the surrounding infrastructure, the CI failure analysis dashboard patterns covered elsewhere on this site complement this approach well as the reporting layer on top of your trace data.
Note: This article is for informational purposes only and is not a substitute for professional advice. If you need guidance on specific situations described in this article, consider consulting a qualified professional.