Logging
Default scopes
Web server scope
By default we set the global scope for sentry here.
It contains the general information such as the app mode name, the referer hostname, the current user id... See the ApplicationController to learn more about this.
Jobs scope
In the ApplicationJob parent class, we do also set the job_id in the scope here.
Specific scope
Following the same logic in the ApplicationController or the ApplicationJob, you can set more tags anywhere in your code that is used in jobs or controllers, here's an example:
class ProcessOrderService
def initialize(order, user)
@order = order
@user = user
end
def call
Sentry.configure_scope do |scope|
scope.set_tags(
service: 'ProcessOrderService',
order_id: @order.id.to_s, # Convert to string for Sentry
user_id: @user&.id&.to_s,
order_type: @order.type
)
end
# Your service logic here
@order.update(status: 'processed')
Rails.logger.info("Order #{@order.id} processed for user #{@user&.id}")
end
end
We can do the same in jobs.
Releases
Go to this URL to see new releases https://namtek-consulting-services.sentry.io/releases/. You can also view the introduced issues by a given release and the adoption rates.
Monitoring
You can monitor and search transactions (logs) in sentry at https://namtek-consulting-services.sentry.io/discover/results.
You have there 2 tabs:
- Errors: error events
- Transactions: all events
You can search by tags set in rails, as in the webserver here.
Here is an example where events (job runs/web requests) are filtered by tags: sentry.