Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
59c7f80
refactor(v2fix): enhance KnownChange interface with Clone method and …
darccio Feb 5, 2026
75644d6
feat(v2fix): implement golden file generation for analyzer suggested …
darccio Feb 5, 2026
e7eb887
test(v2fix): add V1Usage Clone stub for tests
darccio Feb 5, 2026
ea0f227
feat(v2fix): enhance probes with type alias/composite handling
darccio Feb 5, 2026
6a741f9
feat(v2fix): map v1 contrib imports to v2 layout
darccio Feb 5, 2026
efb0c1b
feat(v2fix): handle renamed AppSec login events
darccio Feb 5, 2026
9073652
feat(v2fix): warn when WithPrioritySampling is still referenced
darccio Feb 5, 2026
93de85c
feat(v2fix): warn on removed WithHTTPRoundTripper
darccio Feb 5, 2026
cfb8cdc
test(v2fix): add false-positive guard coverage
darccio Feb 5, 2026
5be42c8
feat(v2fix): add ChildOf → StartChild rewrite
darccio Feb 5, 2026
d28def9
test(v2fix): extend DDTrace type fixture coverage
darccio Feb 5, 2026
56c1318
feat(v2fix): cover RateRule in sampling fixes
darccio Feb 5, 2026
b81f38e
fix(v2fix): preserve original type qualifier and harden suggested fix…
darccio Feb 5, 2026
7bd0cfc
chore(v2fix): make format && make lint
darccio Feb 5, 2026
5203930
fix(v2fix): update ChildOf usage to StartChild
darccio Feb 10, 2026
5aebfa0
refactor(v2fix): rename getImportPathFromTypeExpr to importPathFromTy…
darccio Feb 10, 2026
6a4d4de
refactor(v2fix): rename getTypeFromTypeExpr to typeFromTypeExpr
darccio Feb 10, 2026
be46aac
refactor(v2fix): replace sort.SliceStable with slices.SortStableFunc …
darccio Feb 10, 2026
e14472f
refactor(v2fix): rename getTypeNameFromType to typeNameFromType
darccio Feb 10, 2026
1be8406
refactor(v2fix): add docs to context keys
darccio Feb 10, 2026
b286870
Merge remote-tracking branch 'origin' into dario.castane/ktlo/v2fix-f…
darccio Feb 10, 2026
01fc68d
fix(v2fix): restrict ChildOf→StartChild autofix to literal operation …
darccio Feb 11, 2026
20b4826
refactor(v2fix): extract and test import path rewriting logic
darccio Feb 11, 2026
2cbdd6d
refactor(v2fix): deduplicate type extraction and matching logic in pr…
darccio Feb 11, 2026
ee88b1f
fix(v2fix): disable autofix for appsec login event function renames
darccio Feb 12, 2026
586d638
fix(v2fix): avoid unnecessary mutation in contextHandler.Context()
darccio Feb 12, 2026
0414d3a
refactor(v2fix): optimize and simplify code generation in known_chang…
darccio Feb 12, 2026
543f1ff
refactor(v2fix): consolidate on exprToString and optimize SamplingRul…
darccio Feb 12, 2026
da5f7cc
refactor(v2fix): enhance golden_generator for multi-message support
darccio Feb 12, 2026
8bdace6
refactor(v2fix): improve diagnostic reporting structure
darccio Feb 12, 2026
84322c8
refactor(v2fix): update comments for clarity on ChildOf usage
darccio Feb 12, 2026
53a0011
Merge branch 'main' into dario.castane/ktlo/v2fix-for-automatic-campaign
darccio Feb 12, 2026
3c92d46
Merge branch 'main' into dario.castane/ktlo/v2fix-for-automatic-campaign
darccio Feb 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions tools/v2fix/_stage/appseclogin/appseclogin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2024 Datadog, Inc.

package main

import (
"context"

"gopkg.in/DataDog/dd-trace-go.v1/appsec"
)

func main() {
ctx := context.Background()

// Login success event
appsec.TrackUserLoginSuccessEvent(ctx, "user123", nil) // want `appsec login event functions have been renamed`

// Login failure event
appsec.TrackUserLoginFailureEvent(ctx, "user123", false, nil) // want `appsec login event functions have been renamed`
}
23 changes: 23 additions & 0 deletions tools/v2fix/_stage/appseclogin/appseclogin.go.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
-- appsec login event functions have been renamed (remove 'Event' suffix) --
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2024 Datadog, Inc.

package main

import (
"context"

"gopkg.in/DataDog/dd-trace-go.v1/appsec"
)

func main() {
ctx := context.Background()

// Login success event
appsec.TrackUserLoginSuccess(ctx, "user123", nil) // want `appsec login event functions have been renamed`

// Login failure event
appsec.TrackUserLoginFailure(ctx, "user123", false, nil) // want `appsec login event functions have been renamed`
}
39 changes: 39 additions & 0 deletions tools/v2fix/_stage/childof/childof.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2024 Datadog, Inc.

package main

import (
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
)

func main() {
tracer.Start()
defer tracer.Stop()

parent := tracer.StartSpan("parent")
defer parent.Finish()

extraOpt := tracer.ResourceName("resource")

// Simple ChildOf usage
child := tracer.StartSpan("child", tracer.ChildOf(parent.Context())) // want `use StartChild instead of StartSpan with ChildOf`
defer child.Finish()

// ChildOf with additional options
child2 := tracer.StartSpan("child2", tracer.ChildOf(parent.Context()), tracer.ResourceName("resource")) // want `use StartChild instead of StartSpan with ChildOf`
defer child2.Finish()

// ChildOf with non-call option (variable)
child3 := tracer.StartSpan("child3", tracer.ChildOf(parent.Context()), extraOpt) // want `use StartChild instead of StartSpan with ChildOf`
defer child3.Finish()

// ChildOf passed via variadic (ellipsis applies to ChildOf itself) - should not be rewritten
parentOpts := []tracer.StartSpanOption{
tracer.ChildOf(parent.Context()),
}
child4 := tracer.StartSpan("child4", parentOpts...)
defer child4.Finish()
}
40 changes: 40 additions & 0 deletions tools/v2fix/_stage/childof/childof.go.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
-- use StartChild instead of StartSpan with ChildOf --
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2024 Datadog, Inc.

package main

import (
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
)

func main() {
tracer.Start()
defer tracer.Stop()

parent := tracer.StartSpan("parent")
defer parent.Finish()

extraOpt := tracer.ResourceName("resource")

// Simple ChildOf usage
child := parent.StartChild("child") // want `use StartChild instead of StartSpan with ChildOf`
defer child.Finish()

// ChildOf with additional options
child2 := parent.StartChild("child2", tracer.ResourceName("resource")) // want `use StartChild instead of StartSpan with ChildOf`
defer child2.Finish()

// ChildOf with non-call option (variable)
child3 := parent.StartChild("child3", extraOpt) // want `use StartChild instead of StartSpan with ChildOf`
defer child3.Finish()

// ChildOf passed via variadic (ellipsis applies to ChildOf itself) - should not be rewritten
parentOpts := []tracer.StartSpanOption{
tracer.ChildOf(parent.Context()),
}
child4 := tracer.StartSpan("child4", parentOpts...)
defer child4.Finish()
}
21 changes: 21 additions & 0 deletions tools/v2fix/_stage/ddtracetypes/ddtracetypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace"
)

const N = 2

func main() {
var (
_ ddtrace.FinishConfig // want `the declared type is in the ddtrace/tracer package now`
Expand All @@ -23,8 +25,27 @@ func main() {
_ ddtrace.StartSpanOption // want `the declared type is in the ddtrace/tracer package now`
_ ddtrace.Tracer // want `the declared type is in the ddtrace/tracer package now`
_ time.Time

// Composite type tests: pointer, slice, array
_ *ddtrace.Span // want `the declared type is in the ddtrace/tracer package now`
_ []ddtrace.Span // want `the declared type is in the ddtrace/tracer package now`
_ [3]ddtrace.SpanLink // want `the declared type is in the ddtrace/tracer package now`

// Non-literal array length: diagnostic emitted but no fix (preserves original formatting)
_ [N + 1]ddtrace.Span // want `the declared type is in the ddtrace/tracer package now`

// Composite SpanContext types should NOT be migrated (exclusion applies to unwrapped base type)
_ *ddtrace.SpanContext
_ []ddtrace.SpanContext
_ [2]ddtrace.SpanContext
)
}

func spanConsumer(_ ddtrace.Span) { // want `the declared type is in the ddtrace/tracer package now`
}

func pointerConsumer(_ *ddtrace.Span) { // want `the declared type is in the ddtrace/tracer package now`
}

func sliceConsumer(_ []ddtrace.Span) { // want `the declared type is in the ddtrace/tracer package now`
}
21 changes: 21 additions & 0 deletions tools/v2fix/_stage/ddtracetypes/ddtracetypes.go.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace"
)

const N = 2

func main() {
var (
_ tracer.FinishConfig // want `the declared type is in the ddtrace/tracer package now`
Expand All @@ -24,8 +26,27 @@ func main() {
_ tracer.StartSpanOption // want `the declared type is in the ddtrace/tracer package now`
_ tracer.Tracer // want `the declared type is in the ddtrace/tracer package now`
_ time.Time

// Composite type tests: pointer, slice, array
_ *tracer.Span // want `the declared type is in the ddtrace/tracer package now`
_ []tracer.Span // want `the declared type is in the ddtrace/tracer package now`
_ [3]tracer.SpanLink // want `the declared type is in the ddtrace/tracer package now`

// Non-literal array length: diagnostic emitted but no fix (preserves original formatting)
_ [N + 1]ddtrace.Span // want `the declared type is in the ddtrace/tracer package now`

// Composite SpanContext types should NOT be migrated (exclusion applies to unwrapped base type)
_ *ddtrace.SpanContext
_ []ddtrace.SpanContext
_ [2]ddtrace.SpanContext
)
}

func spanConsumer(_ tracer.Span) { // want `the declared type is in the ddtrace/tracer package now`
}

func pointerConsumer(_ *tracer.Span) { // want `the declared type is in the ddtrace/tracer package now`
}

func sliceConsumer(_ []tracer.Span) { // want `the declared type is in the ddtrace/tracer package now`
}
40 changes: 40 additions & 0 deletions tools/v2fix/_stage/falsepositive/falsepositive.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2023 Datadog, Inc.

// This test verifies that functions with the same names as dd-trace-go v1 functions
// but from different packages are NOT flagged for migration.
package main

// Local type and function definitions that shadow dd-trace-go names
type Span struct {
Name string
}

func WithServiceName(name string) string {
return name
}

func TraceID() uint64 {
return 0
}

func WithDogstatsdAddress(addr string) string {
return addr
}

func ServiceRule(service string, rate float64) string {
return service
}

func main() {
// These should NOT be flagged - they're local functions, not from dd-trace-go v1
_ = WithServiceName("test")
_ = TraceID()
_ = WithDogstatsdAddress("localhost:8125")
_ = ServiceRule("myservice", 0.5)

// Local type should NOT be flagged
var _ Span
}
19 changes: 19 additions & 0 deletions tools/v2fix/_stage/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tools/v2fix/_stage/samplingrules/samplingrules.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func tags() map[string]string {
func main() {
_ = tracer.ServiceRule("test-service", 1.0) // want `a deprecated sampling rule constructor function should be replaced with a tracer.Rule{...} struct literal`
_ = tracer.NameRule("http.request", 1.0) // want `a deprecated sampling rule constructor function should be replaced with a tracer.Rule{...} struct literal`
_ = tracer.RateRule(0.5) // want `a deprecated sampling rule constructor function should be replaced with a tracer.Rule{...} struct literal`
_ = tracer.NameServiceRule("http.request", "test-service", 1.0) // want `a deprecated sampling rule constructor function should be replaced with a tracer.Rule{...} struct literal`
_ = tracer.NameServiceRule("http.*", "test-*", 1.0) // want `a deprecated sampling rule constructor function should be replaced with a tracer.Rule{...} struct literal`
_ = tracer.ServiceRule("other-service-1", 0.0) // want `a deprecated sampling rule constructor function should be replaced with a tracer.Rule{...} struct literal`
Expand Down
Loading
Loading