Skip to content

Commit

Permalink
Bumps rbspy version to v0.6.0 (#237)
Browse files Browse the repository at this point in the history
Co-authored-by: Dmitry Filimonov <dmitry@pyroscope.io>
  • Loading branch information
kolesnikovae and petethepig authored Jun 17, 2021
1 parent 4382496 commit 82ce174
Show file tree
Hide file tree
Showing 10 changed files with 518 additions and 187 deletions.
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

0 comments on commit 82ce174

Please sign in to comment.