[test-improver] Improve tests for tracing span helpers#6651
Merged
lpcox merged 2 commits intoMay 29, 2026
Conversation
Cover RecordSpanError and RecordSpanErrorOnAll which had 0% and 100% coverage respectively, improving package coverage from 95.1% to 96.3%. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds focused unit tests for tracing span error helper behavior in internal/tracing, improving coverage around status/error propagation for OpenTelemetry spans.
Changes:
- Adds an in-memory span test helper for recording span output.
- Tests
RecordSpanErrorstatus/event behavior. - Tests
RecordSpanErrorOnAllfor zero, one, and multiple spans.
Show a summary per file
| File | Description |
|---|---|
internal/tracing/span_helpers_test.go |
Adds new tests for span error recording helper functions. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 1
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
Test Improvements: span_helpers_test.go
File Analyzed
internal/tracing/span_helpers_test.go(new file)internal/tracinginternal/tracing/span_helpers.goImprovements Made
1. Increased Coverage
✅ Added
TestRecordSpanError_SetsStatusAndRecordsEvent— verifiesRecordSpanErrorsets span status to Error, records the correct status description, and creates anexceptionevent with a stack trace✅ Added
TestRecordSpanErrorOnAll_RecordsOnAllSpans— verifiesRecordSpanErrorOnAllpropagates the error to every span in the variadic list✅ Added
TestRecordSpanErrorOnAll_NoSpans_DoesNotPanic— edge case: calling with no spans must not panic✅ Added
TestRecordSpanErrorOnAll_SingleSpan_BehavesLikeRecordSpanError— single-span call produces the same result as callingRecordSpanErrordirectlyPrevious Coverage (
RecordSpanErrorOnAll): 0.0%New Coverage (
RecordSpanErrorOnAll): 100.0%Package Coverage: 95.1% → 96.3% (+1.2%)
2. Better Testing Patterns
newRecordingSpantest helper witht.Helper()andt.Cleanup()for SDK tracer teardown — keeps individual tests concise and avoids resource leakstracetest.InMemoryExporter+sdktrace.NewSimpleSpanProcessorto record real span events without network or external dependenciesrequirefor critical setup assertions (span type assertion, slice lengths) andassertfor non-fatal checksTestFunctionName_Scenarionaming convention3. Cleaner & More Stable Tests
t.Cleanupshuts down the SDK tracer provider after each test — no global state leakTest Execution
Why These Changes?
RecordSpanErrorOnAllhad 0% coverage despite being a public utility used across the codebase (e.g. inunified.gofor tool-call error paths). The function is straightforward but important — a bug here would silently fail to mark spans as errors, hiding failures in distributed traces. The new tests confirm correct behavior on zero, one, and multiple spans, and validate that the underlyingRecordSpanErrorpath (status code, description, exception event) works as expected.Generated by Test Improver Workflow
Focuses on better patterns, increased coverage, and more stable tests
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
index.crates.ioSee Network Configuration for more information.