Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
77fa95c
Reorganize nrslog integration into self-contained package
mirackara Mar 3, 2026
911d089
Reorganize nrmysql integration into self-contained package
mirackara Mar 3, 2026
1934473
Reorganize nrgochi integration into self-contained package
mirackara Mar 3, 2026
e1f5e7d
Reorganize nrgin integration into self-contained package
mirackara Mar 3, 2026
0ba3389
Reorganize nrgrpc integration into self-contained package
mirackara Mar 3, 2026
a219420
Reorganize nragent integration into self-contained package
mirackara Mar 3, 2026
98dd48f
Reorganize nrnethttp integration into self-contained package
mirackara Mar 3, 2026
89f7ded
Complete integration reorganization cleanup
mirackara Mar 3, 2026
49fbac5
Fix double-nested example directory structure
mirackara Mar 3, 2026
d09caf4
Restore test files to proper locations after accidental deletion
mirackara Mar 3, 2026
775fbc5
Export test helpers and fix parser tests
mirackara Mar 3, 2026
7deb8ab
Fix integration tests - Part 1: nragent and nrgin tests now compile
mirackara Mar 3, 2026
f041383
Fix integration tests - Part 2: nrgochi and partial nrgrpc
mirackara Mar 3, 2026
f39ef8d
Refactor tests and internal methods for gRPC instrumentation
mirackara Mar 3, 2026
9a5d19d
fix: add back gin/mysql tests
mirackara Mar 4, 2026
01a1afc
feat: add go.mod and go.sum for nrgin, nrmysql, and nrnethttp integra…
mirackara Mar 4, 2026
acfde03
Restore existing gin examples
mirackara Mar 4, 2026
945ff31
minor fixes and revert existing naming conventions
mirackara Mar 4, 2026
011dc92
fix: correct function naming conventions in test files
mirackara Mar 4, 2026
0516d5c
fix: correct function naming conventions in transaction tests
mirackara Mar 4, 2026
dd65773
fix: correct function naming conventions in nragent tests
mirackara Mar 4, 2026
3cde296
refactor: rename end-to-end-tests to validation-tests
mirackara Mar 4, 2026
36710b9
remove accidental guide/readme additions
mirackara Mar 4, 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
4 changes: 2 additions & 2 deletions .github/workflows/end_to_end_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
- name: Run end to end tests
run: ./end-to-end-tests/testrunner --no-clean
- name: Run validation tests
run: ./validation-tests/testrunner --no-clean
50 changes: 48 additions & 2 deletions cmd/instrument.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ import (
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/dave/dst/decorator"
"github.com/newrelic/go-easy-instrumentation/integrations/nragent"
"github.com/newrelic/go-easy-instrumentation/integrations/nrgin"
"github.com/newrelic/go-easy-instrumentation/integrations/nrgochi"
"github.com/newrelic/go-easy-instrumentation/integrations/nrgrpc"
"github.com/newrelic/go-easy-instrumentation/integrations/nrnethttp"
"github.com/newrelic/go-easy-instrumentation/integrations/nrslog"
"github.com/newrelic/go-easy-instrumentation/internal/comment"
"github.com/newrelic/go-easy-instrumentation/parser"
"github.com/spf13/cobra"
Expand All @@ -27,6 +33,44 @@ const (
defaultDiffFileName = "new-relic-instrumentation.diff"
)

// registerIntegrations registers all integration tracing functions with the manager
// in the correct order (order matters for instrumentation!)
func registerIntegrations(manager *parser.InstrumentationManager) {
// Pre-instrumentation scanning phase (ORDER PRESERVED)
manager.LoadPreInstrumentationTracingFunctions(
parser.DetectTransactions,
parser.DetectErrors,
nrnethttp.DetectWrappedRoutes,
)

// Stateless tracing functions (ORDER PRESERVED)
manager.LoadStatelessTracingFunctions(
nragent.InstrumentMain,
nrnethttp.InstrumentHandleFunction,
nrnethttp.InstrumentHttpClient,
nrnethttp.CannotInstrumentHttpMethod,
nrgrpc.InstrumentGrpcDial,
nrgin.InstrumentGinFunction,
nrgrpc.InstrumentGrpcServerMethod,
nrslog.InstrumentSlogHandler,
)

// Stateful tracing functions (ORDER PRESERVED)
manager.LoadStatefulTracingFunctions(
nrnethttp.ExternalHttpCall,
nrnethttp.WrapNestedHandleFunction,
nrgrpc.InstrumentGrpcServer,
nrgin.InstrumentGinMiddleware,
nrgochi.InstrumentChiMiddleware,
nrgochi.InstrumentChiRouterLiteral,
)

// Fact discovery functions
manager.LoadDependencyScans(
nrgrpc.FindGrpcServerObject,
)
}

var (
diffFile string
excludeDirs string
Expand Down Expand Up @@ -177,12 +221,14 @@ func instrumentPackages(packagePath string, patterns []string, outputFile string

manager := parser.NewInstrumentationManager(pkgs, defaultAppName, defaultAgentVariableName, outputFile, packagePath)

// Register all integrations
registerIntegrations(manager)

steps := []struct {
desc string
fn func() error
}{
{"Creating diff file", manager.CreateDiffFile},
{"Detecting dependencies", manager.DetectDependencyIntegrations},
{"Tracing package calls", manager.TracePackageCalls},
{"Scanning application", manager.ScanApplication},
{"Instrumenting application", manager.InstrumentApplication},
Expand Down Expand Up @@ -229,7 +275,7 @@ func runTUIMode(packagePath string, patterns []string, outputFile string) {
fn func() error
}{
{"Creating diff file", manager.CreateDiffFile},
{"Detecting dependencies", manager.DetectDependencyIntegrations},
{"Detecting dependencies", func() error { registerIntegrations(manager); return nil }},
{"Tracing package calls", manager.TracePackageCalls},
{"Scanning application", manager.ScanApplication},
{"Instrumenting application", manager.InstrumentApplication},
Expand Down
6 changes: 3 additions & 3 deletions cmd/instrument_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func TestWaitForNext(t *testing.T) {
// Integration tests for instrumentPackages

func TestInstrumentPackages_BasicGin(t *testing.T) {
packagePath := filepath.Join("..", "end-to-end-tests", "gin-examples", "basic")
packagePath := filepath.Join("..", "validation-tests", "gin-examples", "basic")
if _, err := os.Stat(packagePath); err != nil {
t.Skipf("test fixture not found: %v", err)
}
Expand All @@ -332,7 +332,7 @@ func TestInstrumentPackages_BasicGin(t *testing.T) {
}

func TestInstrumentPackages_HttpApp(t *testing.T) {
packagePath := filepath.Join("..", "end-to-end-tests", "http-app")
packagePath := filepath.Join("..", "validation-tests", "http-app")
if _, err := os.Stat(packagePath); err != nil {
t.Skipf("test fixture not found: %v", err)
}
Expand All @@ -354,7 +354,7 @@ func TestInstrumentPackages_HttpApp(t *testing.T) {
}

func TestInstrumentPackages_CustomPatterns(t *testing.T) {
packagePath := filepath.Join("..", "end-to-end-tests", "gin-examples", "basic")
packagePath := filepath.Join("..", "validation-tests", "gin-examples", "basic")
if _, err := os.Stat(packagePath); err != nil {
t.Skipf("test fixture not found: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/interactive.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func scanGoFiles(root string, excludedDirs []string) ([]string, error) {
base := info.Name()
for _, excluded := range excludedDirs {
// Simple check: if directory name matches excluded name exacty
// Or if path contains it? User asked to "exclude folders like end-to-end-tests".
// Or if path contains it? User asked to "exclude folders like validation-tests".
// Let's do a strict component match to be safe, or just check if it matches the name.
if base == excluded {
return filepath.SkipDir
Expand Down
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ coverage:
precision: 2

ignore:
- end-to-end-tests/**
- validation-tests/**

component_management:
individual_components:
Expand Down
20 changes: 0 additions & 20 deletions end-to-end-tests/http-app/go.mod

This file was deleted.

24 changes: 0 additions & 24 deletions end-to-end-tests/http-app/go.sum

This file was deleted.

3 changes: 0 additions & 3 deletions end-to-end-tests/mysql/go.mod

This file was deleted.

Empty file removed end-to-end-tests/mysql/go.sum
Empty file.
44 changes: 0 additions & 44 deletions end-to-end-tests/testcases.json

This file was deleted.

11 changes: 4 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ go 1.24.0
toolchain go1.24.11

require (
github.com/charmbracelet/bubbles v0.21.0
github.com/charmbracelet/bubbletea v1.3.10
github.com/charmbracelet/lipgloss v1.1.0
github.com/dave/dst v0.27.3
github.com/newrelic/go-agent/v3 v3.42.0
github.com/sourcegraph/go-diff-patch v0.0.0-20240223163233-798fd1e94a8e
github.com/spf13/cobra v1.8.1
github.com/stretchr/testify v1.10.0
golang.org/x/term v0.30.0
golang.org/x/tools v0.28.0
)

require golang.org/x/sync v0.12.0 // indirect

require (
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/bubbles v0.21.0 // indirect
github.com/charmbracelet/bubbletea v1.3.10 // indirect
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
github.com/charmbracelet/harmonica v0.2.0 // indirect
github.com/charmbracelet/lipgloss v1.1.0 // indirect
github.com/charmbracelet/x/ansi v0.10.1 // indirect
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect
github.com/charmbracelet/x/term v0.2.1 // indirect
Expand All @@ -33,20 +33,17 @@ require (
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/termenv v0.16.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rogpeppe/go-internal v1.13.1 // indirect
github.com/schollz/progressbar/v3 v3.19.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/net v0.38.0 // indirect
golang.org/x/sys v0.36.0 // indirect
golang.org/x/term v0.30.0 // indirect
golang.org/x/text v0.23.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/grpc v1.65.0 // indirect
Expand Down
18 changes: 2 additions & 16 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ github.com/charmbracelet/bubbletea v1.3.10 h1:otUDHWMMzQSB0Pkc87rm691KZ3SWa4KUlv
github.com/charmbracelet/bubbletea v1.3.10/go.mod h1:ORQfo0fk8U+po9VaNvnV95UPWA1BitP1E0N6xJPlHr4=
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs=
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk=
github.com/charmbracelet/harmonica v0.2.0 h1:8NxJWRWg/bzKqqEaaeFNipOu77YR5t8aSwG4pgaUBiQ=
github.com/charmbracelet/harmonica v0.2.0/go.mod h1:KSri/1RMQOZLbw7AHqgcBycp8pgJnQMYYT8QZRqZ1Ao=
github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY=
github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30=
github.com/charmbracelet/x/ansi v0.10.1 h1:rL3Koar5XvX0pHGfovN03f5cxLbCF2YvLeyz7D2jVDQ=
Expand All @@ -26,8 +24,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
Expand All @@ -47,22 +43,14 @@ github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2J
github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ=
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw=
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI=
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo=
github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
github.com/newrelic/go-agent/v3 v3.40.1 h1:8nb4R252Fpuc3oySvlHpDwqySqaPWL5nf7ZVEhqtUeA=
github.com/newrelic/go-agent/v3 v3.40.1/go.mod h1:X0TLXDo+ttefTIue1V96Y5seb8H6wqf6uUq4UpPsYj8=
github.com/newrelic/go-agent/v3 v3.42.0 h1:aA2Ea1RT5eD59LtOS1KGFXSmaDs6kM3Jeqo7PpuQoFQ=
github.com/newrelic/go-agent/v3 v3.42.0/go.mod h1:sCgxDCVydoKD/C4S8BFxDtmFHvdWHtaIz/a3kiyNB/k=
github.com/newrelic/go-agent/v3 v3.42.0 h1:aA2Ea1RT5eD59LtOS1KGFXSmaDs6kM3Jeqo7PpuQoFQ=
github.com/newrelic/go-agent/v3 v3.42.0/go.mod h1:sCgxDCVydoKD/C4S8BFxDtmFHvdWHtaIz/a3kiyNB/k=
github.com/newrelic/go-agent/v3/integrations/nrmysql v1.2.2 h1:JtaJdL4y1hj5mH0JA2XIIIZtOsivsCmG0wsp3cGtoNo=
github.com/newrelic/go-agent/v3/integrations/nrmysql v1.2.2/go.mod h1:0JZ1gqlaBi9FUrQsg9LLZR357oDH4fGYYTbQQPhOd8o=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand All @@ -73,8 +61,6 @@ github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/f
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/schollz/progressbar/v3 v3.19.0 h1:Ea18xuIRQXLAUidVDox3AbwfUhD0/1IvohyTutOIFoc=
github.com/schollz/progressbar/v3 v3.19.0/go.mod h1:IsO3lpbaGuzh8zIMzgY3+J8l4C8GjO0Y9S69eFvNsec=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/sourcegraph/go-diff-patch v0.0.0-20240223163233-798fd1e94a8e h1:H+jDTUeF+SVd4ApwnSFoew8ZwGNRfgb9EsZc7LcocAg=
Expand All @@ -87,6 +73,8 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561 h1:MDc5xs78ZrZr3HMQugiXOAkSZtfTpbJLDr/lwfgO53E=
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
Expand All @@ -95,8 +83,6 @@ golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw=
golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y=
Expand Down
Loading
Loading