sentry-ruby icon indicating copy to clipboard operation
sentry-ruby copied to clipboard

Map `trilogy` database adapter to `mysql` for Query Insights compatibility

Open krismichalski opened this issue 6 months ago • 0 comments

Description

When using trilogy adapter in Rails app, Query Insights view in Sentry did not show any data.

The problem is that trilogy is not in the allowed system db name list: https://github.com/getsentry/semantic-conventions/blob/main/docs/attributes-registry/db.md despite being just a different MySQL adapter, and hence does not meet the criteria for span eligibility: https://docs.sentry.io/product/insights/backend/queries/#span-eligibility

The simple fix is to just map trilogy to mysql for the db system name.

Current Behavior

No query data is displayed because trilogy is not recognized as a valid database system.

Expected Behavior

Query data from trilogy adapter should appear in Sentry's Query Insights view, similar to other MySQL adapters.

Alternative solution (how I tested it worked)

The same result can be achieved using before_send_transaction:

# Workaround: Map trilogy spans to mysql for Sentry compatibility
config.before_send_transaction = lambda do |event, _hint|
  event.spans.select { |span| span[:op].start_with?("db.") }.each do |span|
    span[:data]["db.system"] = "mysql" if span[:data]&.fetch("db.system", nil) == "trilogy"
  end
end

krismichalski avatar Jun 24 '25 10:06 krismichalski