getsentry / getsentry/sentry-ruby

Profiling Rake Tasks launched with Cron

Abierto
#2,238 16 comentarios 0 reacciones 1 asignado Reclamado por @sl0thentr0py Ver en GitHub
Crons Feature Profiles Ruby
Lenguaje dominante
Ruby
Estrellas
987
Forks
541
Merge medio
17 h 40 min
PR fusionados (30 d)
19

Descripción

### 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_

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.