Skip to content

Commit

Permalink
Merge branch 'main' into make-sample-app-target
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias authored Jan 14, 2025
2 parents 9e0aa41 + 07f9b96 commit 3e7a455
Show file tree
Hide file tree
Showing 33 changed files with 97 additions and 98 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=$BUILDPLATFORM golang:1.23.4-bookworm@sha256:2e838582004fab0931693a3a84743ceccfbfeeafa8187e87291a1afea457ff7a AS base
FROM --platform=$BUILDPLATFORM golang:1.23.4-bookworm@sha256:e4906bc13f563c90ea22151e831cda45d58838f2bee18823f0bcc717464ccfe5 AS base

RUN apt-get update && apt-get install -y curl clang gcc llvm make libbpf-dev

Expand Down
2 changes: 1 addition & 1 deletion examples/httpPlusdb/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.23.4@sha256:7ea4c9dcb2b97ff8ee80a67db3d44f98c8ffa0d191399197007d8459c1453041
FROM golang:1.23.4@sha256:08e1417a41687ce17a8cfbf65285446a794ac5023635b848faf1c2ed1d7e475f
WORKDIR /app
COPY ./*.go .
RUN go mod init main
Expand Down
2 changes: 1 addition & 1 deletion examples/kafka-go/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.23.4@sha256:7ea4c9dcb2b97ff8ee80a67db3d44f98c8ffa0d191399197007d8459c1453041
FROM golang:1.23.4@sha256:08e1417a41687ce17a8cfbf65285446a794ac5023635b848faf1c2ed1d7e475f
WORKDIR /app
COPY . .
ARG BINARY_NAME
Expand Down
2 changes: 1 addition & 1 deletion examples/rolldice/frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.23@sha256:7ea4c9dcb2b97ff8ee80a67db3d44f98c8ffa0d191399197007d8459c1453041
FROM golang:1.23@sha256:08e1417a41687ce17a8cfbf65285446a794ac5023635b848faf1c2ed1d7e475f

WORKDIR /usr/src/user

Expand Down
2 changes: 1 addition & 1 deletion examples/rolldice/user/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.23@sha256:7ea4c9dcb2b97ff8ee80a67db3d44f98c8ffa0d191399197007d8459c1453041
FROM golang:1.23@sha256:08e1417a41687ce17a8cfbf65285446a794ac5023635b848faf1c2ed1d7e475f

WORKDIR /usr/src/user

Expand Down
2 changes: 1 addition & 1 deletion instrumentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func NewInstrumentation(ctx context.Context, opts ...InstrumentationOption) (*In
"target process analysis completed",
"pid", td.PID,
"go_version", td.GoVersion,
"dependencies", td.Libraries,
"dependencies", td.Modules,
"total_functions_found", len(td.Functions),
)
mngr.FilterUnusedProbes(td)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ type tracerIDContainsSchemaURL struct{}
var schemaAddedToTracerKeyVer = version.Must(version.NewVersion("1.28.0"))

func (c tracerIDContainsSchemaURL) InjectOption(td *process.TargetDetails) (inject.Option, error) {
ver, ok := td.Libraries["go.opentelemetry.io/otel"]
ver, ok := td.Modules["go.opentelemetry.io/otel"]
if !ok {
return nil, fmt.Errorf("unknown module version: %s", pkg)
}
Expand All @@ -270,7 +270,7 @@ var scopeAttributesAddedToTracerKeyVer = version.Must(version.NewVersion("1.32.0
type tracerIDContainsScopeAttributes struct{}

func (c tracerIDContainsScopeAttributes) InjectOption(td *process.TargetDetails) (inject.Option, error) {
ver, ok := td.Libraries["go.opentelemetry.io/otel"]
ver, ok := td.Modules["go.opentelemetry.io/otel"]
if !ok {
return nil, fmt.Errorf("unknown module version: %s", pkg)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var (
type writeStatusConst struct{}

func (w writeStatusConst) InjectOption(td *process.TargetDetails) (inject.Option, error) {
ver, ok := td.Libraries[pkg]
ver, ok := td.Modules[pkg]
if !ok {
return nil, fmt.Errorf("unknown module version: %s", pkg)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ type framePosConst struct{}
var paramChangeVer = version.Must(version.NewVersion("1.60.0"))

func (c framePosConst) InjectOption(td *process.TargetDetails) (inject.Option, error) {
ver, ok := td.Libraries[pkg]
ver, ok := td.Modules[pkg]
if !ok {
return nil, fmt.Errorf("unknown module version: %s", pkg)
}
Expand All @@ -223,7 +223,7 @@ var (
)

func (w serverAddrConst) InjectOption(td *process.TargetDetails) (inject.Option, error) {
ver, ok := td.Libraries[pkg]
ver, ok := td.Modules[pkg]
if !ok {
return nil, fmt.Errorf("unknown module version: %s", pkg)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/instrumentation/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (m *Manager) validateProbeDependents(id probe.ID, symbols []probe.FunctionS
}

func (m *Manager) registerProbe(p probe.Probe) error {
id := p.Manifest().Id
id := p.Manifest().ID
if _, exists := m.probes[id]; exists {
return fmt.Errorf("library %s registered twice, aborting", id)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/instrumentation/manager_load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestLoadProbes(t *testing.T) {
offsets[f.ModPath] = ver
}
}
t.Run(p.Manifest().Id.String(), func(t *testing.T) {
t.Run(p.Manifest().ID.String(), func(t *testing.T) {
testProbe, ok := p.(testutils.TestProbe)
assert.True(t, ok)
testutils.ProbesLoad(t, testProbe, offsets)
Expand Down
8 changes: 4 additions & 4 deletions internal/pkg/instrumentation/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestProbeFiltering(t *testing.T) {
PID: 1,
Functions: []*binary.Func{},
GoVersion: ver,
Libraries: map[string]*version.Version{},
Modules: map[string]*version.Version{},
AllocationDetails: nil,
}
m.FilterUnusedProbes(&td)
Expand All @@ -58,7 +58,7 @@ func TestProbeFiltering(t *testing.T) {
PID: 1,
Functions: httpFuncs,
GoVersion: ver,
Libraries: map[string]*version.Version{},
Modules: map[string]*version.Version{},
AllocationDetails: nil,
}
m.FilterUnusedProbes(&td)
Expand All @@ -77,7 +77,7 @@ func TestProbeFiltering(t *testing.T) {
PID: 1,
Functions: httpFuncs,
GoVersion: ver,
Libraries: map[string]*version.Version{},
Modules: map[string]*version.Version{},
AllocationDetails: nil,
}
m.FilterUnusedProbes(&td)
Expand All @@ -97,7 +97,7 @@ func TestProbeFiltering(t *testing.T) {
PID: 1,
Functions: httpFuncs,
GoVersion: ver,
Libraries: map[string]*version.Version{},
Modules: map[string]*version.Version{},
AllocationDetails: nil,
}
m.FilterUnusedProbes(&td)
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/instrumentation/probe/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type FunctionSymbol struct {
// Manifest contains information about a package being instrumented.
type Manifest struct {
// ID is a unique identifier for the probe.
Id ID
ID ID

// StructFields are the struct fields in an instrumented package that are
// used for instrumentation.
Expand Down Expand Up @@ -66,7 +66,7 @@ func NewManifest(id ID, structfields []structfield.ID, symbols []FunctionSymbol)
})

return Manifest{
Id: id,
ID: id,
StructFields: structfields,
Symbols: symbols,
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/instrumentation/probe/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestNewManifest(t *testing.T) {
[]FunctionSymbol{fs(d), fs(a), fs(c), fs(b)},
)
want := Manifest{
Id: ID{spanKind, pkg},
ID: ID{spanKind, pkg},
StructFields: []structfield.ID{sAAAA, sAAAB, sAAAC, sAABA, sAABB, sAABC, sABAA, sBAAA},
Symbols: []FunctionSymbol{fs(a), fs(b), fs(c), fs(d)},
}
Expand Down
6 changes: 3 additions & 3 deletions internal/pkg/instrumentation/probe/probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (i *Base[BPFObj, BPFEvent]) loadUprobes(exec *link.Executable, td *process.
for _, up := range i.Uprobes {
var skip bool
for _, pc := range up.PackageConstrainsts {
if pc.Constraints.Check(td.Libraries[pc.Package]) {
if pc.Constraints.Check(td.Modules[pc.Package]) {
continue
}

Expand Down Expand Up @@ -461,7 +461,7 @@ type StructFieldConst struct {
// version of the struct field module is known. If it is not, an error is
// returned.
func (c StructFieldConst) InjectOption(td *process.TargetDetails) (inject.Option, error) {
ver, ok := td.Libraries[c.Val.ModPath]
ver, ok := td.Modules[c.Val.ModPath]
if !ok {
return nil, fmt.Errorf("unknown module version: %s", c.Val.ModPath)
}
Expand All @@ -483,7 +483,7 @@ type StructFieldConstMinVersion struct {
// injected.
func (c StructFieldConstMinVersion) InjectOption(td *process.TargetDetails) (inject.Option, error) {
sf := c.StructField
ver, ok := td.Libraries[sf.Val.ModPath]
ver, ok := td.Modules[sf.Val.ModPath]
if !ok {
return nil, fmt.Errorf("unknown module version: %s", sf.Val.ModPath)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/instrumentation/testutils/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ func ProbesLoad(t *testing.T, p TestProbe, libs map[string]*version.Version) {
StartAddr: 140434497441792,
EndAddr: 140434497507328,
},
Libraries: map[string]*version.Version{
Modules: map[string]*version.Version{
"std": testGoVersion,
},
GoVersion: testGoVersion,
}
for k, v := range libs {
td.Libraries[k] = v
td.Modules[k] = v
}

err = bpffs.Mount(td)
Expand Down
3 changes: 1 addition & 2 deletions internal/pkg/process/allocate.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"runtime"

"go.opentelemetry.io/auto/internal/pkg/instrumentation/utils"
"go.opentelemetry.io/auto/internal/pkg/process/ptrace"
)

// AllocationDetails are the details about allocated memory.
Expand Down Expand Up @@ -61,7 +60,7 @@ func Allocate(logger *slog.Logger, pid int) (*AllocationDetails, error) {
func remoteAllocate(logger *slog.Logger, pid int, mapSize uint64) (uint64, error) {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
program, err := ptrace.NewTracedProgram(pid, logger)
program, err := newTracedProgram(pid, logger)
if err != nil {
return 0, err
}
Expand Down
8 changes: 4 additions & 4 deletions internal/pkg/process/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type TargetDetails struct {
PID int
Functions []*binary.Func
GoVersion *version.Version
Libraries map[string]*version.Version
Modules map[string]*version.Version
AllocationDetails *AllocationDetails
}

Expand Down Expand Up @@ -76,16 +76,16 @@ func (a *Analyzer) Analyze(pid int, relevantFuncs map[string]interface{}) (*Targ
return nil, err
}
result.GoVersion = goVersion
result.Libraries = make(map[string]*version.Version, len(a.BuildInfo.Deps)+1)
result.Modules = make(map[string]*version.Version, len(a.BuildInfo.Deps)+1)
for _, dep := range a.BuildInfo.Deps {
depVersion, err := version.NewVersion(dep.Version)
if err != nil {
a.logger.Error("parsing dependency version", "error", err, "dependency", dep)
continue
}
result.Libraries[dep.Path] = depVersion
result.Modules[dep.Path] = depVersion
}
result.Libraries["std"] = goVersion
result.Modules["std"] = goVersion

funcs, err := a.findFunctions(elfF, relevantFuncs)
if err != nil {
Expand Down
36 changes: 0 additions & 36 deletions internal/pkg/process/ptrace/ptrace_other.go

This file was deleted.

Loading

0 comments on commit 3e7a455

Please sign in to comment.