Skip to content

Commit

Permalink
Add parseGoVersion to support versions with GOEXPERIMENT (#813)
Browse files Browse the repository at this point in the history
* Add parseGoVersion to support versions with GOEXPERIMENT

* changelog
  • Loading branch information
RonFed authored May 3, 2024
1 parent 88e2702 commit a0b4439
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The `http.route` attribute is included and the span name updated to use this inf
- Don't set empty URL path in HTTP client probe. ([#810](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/810))
- Don't fail HTTP client probe attribute resolution on empty URL path. ([#810](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/810))
- Extract `process.runtime.version` and `process.runtime.name` from instrumented process. ([#811](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/811))
- Support Go versions from apps defining GOEXPERIMENT. ([#813](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/813))

## [v0.12.0-alpha] - 2024-04-10

Expand Down
2 changes: 1 addition & 1 deletion instrumentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func (c instConfig) tracerProvider(bi *buildinfo.BuildInfo) *trace.TracerProvide
}

func (c instConfig) res(bi *buildinfo.BuildInfo) *resource.Resource {
runVer := strings.ReplaceAll(bi.GoVersion, "go", "")
runVer := bi.GoVersion

var compiler string

Expand Down
13 changes: 12 additions & 1 deletion internal/pkg/process/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (a *Analyzer) Analyze(pid int, relevantFuncs map[string]interface{}) (*Targ
return nil, err
}

goVersion, err := version.NewVersion(strings.ReplaceAll(a.BuildInfo.GoVersion, "go", ""))
goVersion, err := version.NewVersion(a.BuildInfo.GoVersion)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -126,10 +126,21 @@ func (a *Analyzer) SetBuildInfo(pid int) error {
return err
}

bi.GoVersion = parseGoVersion(bi.GoVersion)

a.BuildInfo = bi
return nil
}

func parseGoVersion(vers string) string {
vers = strings.ReplaceAll(vers, "go", "")
// Trims GOEXPERIMENT version suffix if present.
if idx := strings.Index(vers, " X:"); idx > 0 {
vers = vers[:idx]
}
return vers
}

func (a *Analyzer) findFunctions(elfF *elf.File, relevantFuncs map[string]interface{}) ([]*binary.Func, error) {
result, err := binary.FindFunctionsUnStripped(elfF, relevantFuncs)
if err != nil {
Expand Down

0 comments on commit a0b4439

Please sign in to comment.