Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump rbspy v0.6.0 #237

Merged
merged 5 commits into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion examples/ruby/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ruby:2.7.1
FROM ruby:3.0.1

WORKDIR /usr/src/app

Expand Down
5 changes: 5 additions & 0 deletions pkg/agent/rbspy/placeholder.go
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
// +build !rbspy

package rbspy

// TODO: we should probably find a better way of setting this
var Blocking bool
9 changes: 8 additions & 1 deletion pkg/agent/rbspy/rbspy.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import (
// TODO: pass lower level structures between go and rust?
var bufferLength = 1024 * 64

// TODO: we should probably find a better way of setting this
var Blocking bool

type RbSpy struct {
dataBuf []byte
dataPtr unsafe.Pointer
Expand All @@ -41,7 +44,11 @@ func Start(pid int) (spy.Spy, error) {
// TODO: handle this better
time.Sleep(1 * time.Second)

r := C.rbspy_init(C.int(pid), errorPtr, C.int(bufferLength))
blocking := 0
if Blocking {
blocking = 1
}
r := C.rbspy_init(C.int(pid), C.int(blocking), errorPtr, C.int(bufferLength))

if r < 0 {
return nil, errors.New(string(errorBuf[:-r]))
Expand Down
2 changes: 2 additions & 0 deletions pkg/agent/target/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"time"

"github.com/mitchellh/go-ps"
"github.com/pyroscope-io/pyroscope/pkg/agent/rbspy"
"github.com/sirupsen/logrus"

"github.com/pyroscope-io/pyroscope/pkg/agent"
Expand Down Expand Up @@ -65,6 +66,7 @@ func (s *service) attach(ctx context.Context) {
func (s *service) wait(ctx context.Context) error {
// TODO: this is somewhat hacky, we need to find a better way to configure agents
pyspy.Blocking = s.target.PyspyBlocking
rbspy.Blocking = s.target.RbspyBlocking

session := agent.NewSession(s.sc, s.logger)
if err := session.Start(); err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/cli/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ var _ = Describe("flags", func() {
SampleRate: 0,
DetectSubprocesses: false,
PyspyBlocking: false,
RbspyBlocking: false,
},
}))
})
Expand Down
2 changes: 2 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type Target struct {

// Spy-specific settings.
PyspyBlocking bool `yaml:"pyspy-blocking"`
RbspyBlocking bool `yaml:"rbspy-blocking"`
}

type Server struct {
Expand Down Expand Up @@ -111,4 +112,5 @@ type Exec struct {
UserName string `def:"" desc:"starts process under specified user name"`
GroupName string `def:"" desc:"starts process under specified group name"`
PyspyBlocking bool `def:"false" desc:"enables blocking mode for pyspy"`
RbspyBlocking bool `def:"false" desc:"enables blocking mode for rbspy"`
}
2 changes: 2 additions & 0 deletions pkg/exec/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/mitchellh/go-ps"
"github.com/pyroscope-io/pyroscope/pkg/agent"
"github.com/pyroscope-io/pyroscope/pkg/agent/pyspy"
"github.com/pyroscope-io/pyroscope/pkg/agent/rbspy"
"github.com/pyroscope-io/pyroscope/pkg/agent/spy"
"github.com/pyroscope-io/pyroscope/pkg/agent/types"
"github.com/pyroscope-io/pyroscope/pkg/agent/upstream/remote"
Expand All @@ -39,6 +40,7 @@ func Cli(ctx context.Context, cfg *config.Exec, args []string) error {

// TODO: this is somewhat hacky, we need to find a better way to configure agents
pyspy.Blocking = cfg.PyspyBlocking
rbspy.Blocking = cfg.RbspyBlocking

spyName := cfg.SpyName
if spyName == "auto" {
Expand Down
Loading