Skip to content

Add request info to custom_sampling_context in Rails middleware #1791

@linhmtran168

Description

@linhmtran168

For rack middleware, it's already implemented in #1749
But since the start_transaction is overridden in Rails middleware, so request info is not available in sampling context when using with Rails app

def start_transaction(env, scope)
sentry_trace = env["HTTP_SENTRY_TRACE"]
options = { name: scope.transaction_name, op: transaction_op }
if @assets_regex && scope.transaction_name.match?(@assets_regex)
options.merge!(sampled: false)
end
transaction = Sentry::Transaction.from_sentry_trace(sentry_trace, **options) if sentry_trace
Sentry.start_transaction(transaction: transaction, **options)

Metadata

Metadata

Assignees

No one assigned
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions