Skip to content

Commit 82ce174

Browse files
Bumps rbspy version to v0.6.0 (#237)
Co-authored-by: Dmitry Filimonov <dmitry@pyroscope.io>
1 parent 4382496 commit 82ce174

File tree

10 files changed

+518
-187
lines changed

10 files changed

+518
-187
lines changed

examples/ruby/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ruby:2.7.1
1+
FROM ruby:3.0.1
22

33
WORKDIR /usr/src/app
44

pkg/agent/rbspy/placeholder.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1+
// +build !rbspy
2+
13
package rbspy
4+
5+
// TODO: we should probably find a better way of setting this
6+
var Blocking bool

pkg/agent/rbspy/rbspy.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ import (
2020
// TODO: pass lower level structures between go and rust?
2121
var bufferLength = 1024 * 64
2222

23+
// TODO: we should probably find a better way of setting this
24+
var Blocking bool
25+
2326
type RbSpy struct {
2427
dataBuf []byte
2528
dataPtr unsafe.Pointer
@@ -41,7 +44,11 @@ func Start(pid int) (spy.Spy, error) {
4144
// TODO: handle this better
4245
time.Sleep(1 * time.Second)
4346

44-
r := C.rbspy_init(C.int(pid), errorPtr, C.int(bufferLength))
47+
blocking := 0
48+
if Blocking {
49+
blocking = 1
50+
}
51+
r := C.rbspy_init(C.int(pid), C.int(blocking), errorPtr, C.int(bufferLength))
4552

4653
if r < 0 {
4754
return nil, errors.New(string(errorBuf[:-r]))

pkg/agent/target/service.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"time"
88

99
"github.com/mitchellh/go-ps"
10+
"github.com/pyroscope-io/pyroscope/pkg/agent/rbspy"
1011
"github.com/sirupsen/logrus"
1112

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

6971
session := agent.NewSession(s.sc, s.logger)
7072
if err := session.Start(); err != nil {

pkg/cli/flags_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ var _ = Describe("flags", func() {
159159
SampleRate: 0,
160160
DetectSubprocesses: false,
161161
PyspyBlocking: false,
162+
RbspyBlocking: false,
162163
},
163164
}))
164165
})

pkg/config/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ type Target struct {
4141

4242
// Spy-specific settings.
4343
PyspyBlocking bool `yaml:"pyspy-blocking"`
44+
RbspyBlocking bool `yaml:"rbspy-blocking"`
4445
}
4546

4647
type Server struct {
@@ -111,4 +112,5 @@ type Exec struct {
111112
UserName string `def:"" desc:"starts process under specified user name"`
112113
GroupName string `def:"" desc:"starts process under specified group name"`
113114
PyspyBlocking bool `def:"false" desc:"enables blocking mode for pyspy"`
115+
RbspyBlocking bool `def:"false" desc:"enables blocking mode for rbspy"`
114116
}

pkg/exec/cli.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/mitchellh/go-ps"
1515
"github.com/pyroscope-io/pyroscope/pkg/agent"
1616
"github.com/pyroscope-io/pyroscope/pkg/agent/pyspy"
17+
"github.com/pyroscope-io/pyroscope/pkg/agent/rbspy"
1718
"github.com/pyroscope-io/pyroscope/pkg/agent/spy"
1819
"github.com/pyroscope-io/pyroscope/pkg/agent/types"
1920
"github.com/pyroscope-io/pyroscope/pkg/agent/upstream/remote"
@@ -39,6 +40,7 @@ func Cli(ctx context.Context, cfg *config.Exec, args []string) error {
3940

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

4345
spyName := cfg.SpyName
4446
if spyName == "auto" {

0 commit comments

Comments
 (0)