Skip to content

Commit ec65c55

Browse files
authored
Make --request-info an argument (#2)
* Make phpspy --requestinfo an (optional) argument to phpScope * Fix PhpspyRequestInfo arg * Fix --requestinfo arg
1 parent e3ab402 commit ec65c55

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

collector/phpspy.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ func New(cfg *config.Config) *PhpSpy {
2525
// Returns a channel that will receive parsed traces and any error that occurred
2626
func (ps *PhpSpy) Start() (<-chan *Trace, error) {
2727
// Construct phpspy command with configuration parameters
28-
cmd := exec.Command("sh", "-c", fmt.Sprintf("phpspy --rate-hz=%d --pgrep='-x \"(php-fpm.*|^php$)\"' --buffer-size=%d --max-depth=%d --threads=%d --request-info=qcup",
28+
cmd := exec.Command("sh", "-c", fmt.Sprintf("phpspy --rate-hz=%d --pgrep='-x \"(php-fpm.*|^php$)\"' --buffer-size=%d --max-depth=%d --threads=%d --request-info=%s",
2929
ps.config.RateHz,
3030
ps.config.PhpspyBufferSize,
3131
ps.config.PhpspyMaxDepth,
32-
ps.config.PhpspyThreads))
32+
ps.config.PhpspyThreads,
33+
ps.config.PhpspyRequestInfo))
3334

3435
stdout, err := cmd.StdoutPipe()
3536
if err != nil {

config/config.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,31 @@ type Config struct {
88
AppName string
99
Tags map[string]string
1010
Debug bool
11-
11+
1212
// Profiling settings
1313
RateHz int
1414
Interval float64
1515
BatchLimit int
1616
ConcurrentLimit int
1717
ExcludePattern string
18-
18+
1919
// PHP-specific settings
20-
PhpspyBufferSize int
21-
PhpspyMaxDepth int
22-
PhpspyThreads int
20+
PhpspyBufferSize int
21+
PhpspyMaxDepth int
22+
PhpspyThreads int
23+
PhpspyRequestInfo string
2324
}
2425

2526
// NewDefault returns a new default config
2627
func NewDefault() *Config {
2728
return &Config{
28-
RateHz: 400,
29-
Interval: 0.1,
30-
BatchLimit: 50000,
31-
ConcurrentLimit: 1,
32-
PhpspyBufferSize: 131072,
33-
PhpspyMaxDepth: -1,
34-
PhpspyThreads: 64,
29+
RateHz: 400,
30+
Interval: 0.1,
31+
BatchLimit: 50000,
32+
ConcurrentLimit: 1,
33+
PhpspyBufferSize: 131072,
34+
PhpspyMaxDepth: -1,
35+
PhpspyThreads: 64,
36+
PhpspyRequestInfo: "qcup",
3537
}
36-
}
38+
}

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ func main() {
7171
flag.IntVar(&cfg.PhpspyBufferSize, "phpspyBufferSize", cfg.PhpspyBufferSize, "Size of phpspy's internal buffer")
7272
flag.IntVar(&cfg.PhpspyMaxDepth, "phpspyMaxDepth", cfg.PhpspyMaxDepth, "Maximum stack trace depth")
7373
flag.IntVar(&cfg.PhpspyThreads, "phpspyThreads", cfg.PhpspyThreads, "Number of phpspy worker threads")
74+
flag.StringVar(&cfg.PhpspyRequestInfo, "phpspyRequestInfo", cfg.PhpspyRequestInfo, "Request info to include in traces")
7475

7576
flag.BoolVar(&cfg.Debug, "debug", false, "Enable debug logging")
7677

0 commit comments

Comments
 (0)