feat(v2fix): expand analyzer coverage and harden suggested fix generation#4393
Open
feat(v2fix): expand analyzer coverage and harden suggested fix generation#4393
Conversation
…improve context handling This is needed to fix the race condition that exists on concurrent evaluations.
…fixes This update introduces functionality to generate and update golden files based on suggested fixes from the analyzer. It processes diagnostics, collects edits, and formats the output accordingly, ensuring proper handling of single and multiple messages. This enhancement improves the testing workflow for the v2fix package. The warning-only golden files are generated for consistency/documentation but aren't validated by analysistest.RunWithSuggestedFixes. This is expected behavior from the analysistest package - it only compares when there are actual text edits to apply.
The tests require V1Usage to satisfy the KnownChange interface, and adding Clone() to the test helper makes that contract explicit so test scaffolding stays aligned with production interface changes without altering runtime behavior.
This updates probe context plumbing to capture type expressions, import literals, and helper logic for aliases, composite types, and v1-path detection so analysis is more accurate (including ChildOf option extraction) and fixes can target precise source spans without misidentifying non‑v1 symbols.
This extends the v1 import rewrite to recognize contrib subpaths and translate them to the new contrib/.../v2 path while still handling core imports, ensuring fixes produce correct module paths for both patterns.
Adds the AppSecLoginEvents known change plus wiring in main and tests so v2fix can remap TrackUserLogin(Success|Failure)Event to the new TrackUserLogin(Success|Failure) APIs and keep the golden fixtures in sync; this keeps the AppSec migration path covered and avoids false positives against the renamed helpers.
Adds the DeprecatedWithPrioritySampling KnownChange plus new golden fixture/output to cover tracer.WithPrioritySampling so the checker can emit the “has been removed” warning (priority sampling is now default) without attempting any code changes, keeping migrations focused on the new semantics.
Adds the DeprecatedWithHTTPRoundTripper KnownChange, the associated golden fixture inputs/outputs, and registers it so v2fix can detect tracer.WithHTTPRoundTripper calls and emit the “has been removed; use WithHTTPClient instead” warning; this keeps the migration checker aware of the removed option instead of letting outdated code pass silently.
Added a falsepositive fixture and regression test that runs the WithServiceName, TraceID, WithDogstatsdAddress, and sampling rule rewrites against locally defined functions/types so that the checker proves it only flags dd-trace-go v1 symbols, preventing the migration tool from warning about unrelated code that happens to share names.
Adds the ChildOfStartChild known change along with its probe/test wiring so v2fix can rewrite tracer.StartSpan(..., tracer.ChildOf(...)) into the new parent.StartChild(...) pattern, keeping option plumbing and test coverage aligned with the migration guidance.
Added composite-type cases plus the N constant to the ddtracetypes stage fixtures and taught DDTraceTypes to preserve pointer/slice/array prefixes, skip fixes when array lengths can’t be rendered, and exclude SpanContext even when wrapped so the migration checker can diagnose the expanded scenarios without corrupting the source representation.
Added a RateRule exercise to the samplingrules fixture and refreshed its golden output to show the expected tracer.Rule{…} literal, while updating DeprecatedSamplingRules to require the v1 package path, keep argument-length guards, and qualify the emitted Rule literal with the package prefix so the fixer now safely rewrites every deprecated constructor (including RateRule) into the new struct form without touching non-dd-trace-go symbols.
… generation Use the stored type expression string to keep the original qualifier/alias in struct pointer fixes, fall back to derived types when missing, guard against non-selector calls, and reuse the package prefix helper while tightening argument checks so generated edits are safer and more accurate.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files🚀 New features to boost your workflow:
|
BenchmarksBenchmark execution time: 2026-02-05 18:26:31 Comparing candidate commit 7bd0cfc in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 156 metrics, 8 unstable metrics. |
hannahkm
approved these changes
Feb 5, 2026
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.
What does this PR do?
KnownChangebehaviorMotivation
We want to broaden automated migration support for
dd-trace-gov2 by capturing more v1 API changes and ensuring suggested fixes are precise, stable, and safe. The added rewrites, warnings, and import mappings reduce manual migration effort, while the improved probe/type handling and stronger tests prevent false positives and regressions.This has been implemented while testing the automatic campaigner for internal migration to deprecate v1.
Reviewer's Checklist
./scripts/lint.shlocally.Unsure? Have a question? Request a review!