getsentry / getsentry/sentry-ruby

Profiling Rake Tasks launched with Cron

Aperta
#2,238 16 commenti 0 reazioni 1 assegnatario Rivendicata da @sl0thentr0py Vedi su GitHub
Crons Feature Profiles Ruby
Lingua principale
Ruby
Stelle
987
Fork
541
Merge medio
17h 40m
PR unite (30g)
19

Descrizione

### Environment

SaaS (https://sentry.io/)

### What are you trying to accomplish?

I am trying to profile Ruby/Rails rake tasks that run with Cron so that I can have insight into their performance (slow queries, n+1 issues, etc) like I do with normal rails transactions. I use a cron file run rake tasks. Ex:
```
0 0,2,4,6,8,10,12,14,16,18,20,22 * * * /bin/bash -l -c 'cd /home/deploy/projectName/releases/20240... && RAILS_ENV=production RAILS_ENV=production bundle exec rake environment myraketasks:hello_workd --silent >> log/cron.log 2>> log/cron-error.log'
```

It seems that even if I put profile sampling to 100%, these rake tasks are never picked up and I have no visibility into how they're performing.

I've also tried manually starting a transaction within the rake task. This seems like it would be the right thing to do however database queries and profiling data is still not logged.

```
desc 'This is a sample rake task'
task :hello_world, [:force_staging, :mode] => :environment do |t, args|
transaction = Sentry.start_transaction(op: "hello_world")
...
do_work()
...
transaction.finish
end
```

### How are you getting stuck?

I'm not sure how to enable profiling for these rake tasks so that I can monitor their performance.

### Where in the product are you?

Performance

### Link

_No response_

### DSN

_No response_

### Version

_No response_

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.