Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: OtelRules initialized to wrong path
Browse files Browse the repository at this point in the history
y1yang0 committed Jan 23, 2025
1 parent 32923f4 commit 3e0e4c5
Showing 2 changed files with 11 additions and 7 deletions.
12 changes: 8 additions & 4 deletions tool/preprocess/preprocess.go
Original file line number Diff line number Diff line change
@@ -137,6 +137,10 @@ func (dp *DepProcessor) getGoModName() string {
return dp.moduleName
}

func (dp *DepProcessor) generatedOf(dir string) string {
return filepath.Join(dp.getGoModDir(), dir)
}

// runCmdOutput runs the command and returns its standard output. dir specifies
// the working directory of the command. If dir is the empty string, run runs
// the command in the calling process's current directory.
@@ -284,10 +288,10 @@ func (dp *DepProcessor) postProcess() {
}

// rm -rf otel_rules
_ = os.RemoveAll(OtelRules)
_ = os.RemoveAll(dp.generatedOf(OtelRules))

// rm -rf otel_pkgdep
_ = os.RemoveAll(OtelPkgDep)
_ = os.RemoveAll(dp.generatedOf(OtelPkgDep))

// Restore everything we have modified during instrumentation
_ = dp.restoreBackupFiles()
@@ -841,7 +845,7 @@ func (dp *DepProcessor) saveDebugFiles() {
dir := filepath.Join(util.GetTempBuildDir(), OtelRules)
err := os.MkdirAll(dir, os.ModePerm)
if err == nil {
util.CopyDir(OtelRules, dir)
util.CopyDir(dp.generatedOf(OtelRules), dir)
}
dir = filepath.Join(util.GetTempBuildDir(), OtelUser)
err = os.MkdirAll(dir, os.ModePerm)
@@ -867,7 +871,7 @@ func (dp *DepProcessor) setupDeps() error {
return err
}

// Run go mod tidy first to fetch all dependencies
// Run go mod t idy first to fetch all dependencies
err = dp.runModTidy()
if err != nil {
return err
6 changes: 3 additions & 3 deletions tool/preprocess/setup.go
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ func (dp *DepProcessor) copyRules() (err error) {
return nil
}
// Copy matched rules to ${GOMOD.DIR}/otel_rules
targetDir := filepath.Join(dp.getGoModDir(), OtelRules)
targetDir := dp.generatedOf(OtelRules)
// Find out which resource files we should add to project
for _, bundle := range dp.bundles {
for _, funcRules := range bundle.File2FuncRules {
@@ -310,7 +310,7 @@ func (dp *DepProcessor) initRules() (err error) {
c += "}\n"

// Write to ${GOMOD.DIR}/otel_rules/otel_setup_inst.go
initTarget := filepath.Join(dp.getGoModDir(), OtelRules, OtelSetupInst)
initTarget := dp.generatedOf(filepath.Join(OtelRules, OtelSetupInst))
_, err = util.WriteFile(initTarget, c)
if err != nil {
return err
@@ -381,7 +381,7 @@ func (dp *DepProcessor) rewriteRules() error {

func (dp *DepProcessor) setupOtelSDK() error {
// Copy otel_setup_sdk.go to ${GOMOD.DIR}/otel_rules
setupTarget := filepath.Join(dp.getGoModDir(), OtelRules, OtelSetupSDK)
setupTarget := dp.generatedOf(filepath.Join(OtelRules, OtelSetupSDK))
_, err := resource.CopyOtelSetupTo(OtelRules, setupTarget)
if err != nil {
return err

0 comments on commit 3e0e4c5

Please sign in to comment.