Skip to content

feat: add Sequelize v6 integration#356

Open
jrothrock wants to merge 4 commits into
feat/bullmqfrom
feat/sequelize
Open

feat: add Sequelize v6 integration#356
jrothrock wants to merge 4 commits into
feat/bullmqfrom
feat/sequelize

Conversation

@jrothrock

@jrothrock jrothrock commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds auto-instrumentation for Sequelize v6 via RequireIntegration — zero config, no manual wrapping required
  • Patches Sequelize.prototype.query to wrap every query in a SQL/Query span
  • Captures db.statement, db.operation (SELECT, INSERT, UPDATE, DELETE, etc.), and db.model (table name) on each span
  • Three-tier table extraction: model instance → opts.tableNames → regex on SQL
  • Errors set error = "true" on the span
  • Adds ScoutContextName.DBOperation and ScoutContextName.DBModel enum values
  • Adds e2e test suite: findAll span, INSERT span, raw query span, error flag on failed query
  • Adds sequelize and pg-hstore to devDependencies

Supported versions

Sequelize v6 only (v7 is still in alpha).

How it compares to other APM providers

Provider Approach
OpenTelemetry Patches `Sequelize.prototype.query` — source
Datadog Patches `Sequelize.prototype.query` — source
Scout Patches `Sequelize.prototype.query` (same approach)

Test plan

  • `npm run build` passes
  • `npm run lint` passes
  • `npm run test-e2e` passes (includes new sequelize e2e tests)
  • Test app on port 4141 shows `SQL/Query` spans nested under `Controller/users` in Scout UI

🤖 Generated with Claude Code

jrothrock and others added 4 commits June 24, 2026 18:24
Patches Sequelize.prototype.query — the single funnel for all ORM
operations — to create SQL/Query spans, matching the OpenTelemetry
instrumentation-sequelize approach.

Context captured per query:
- db.statement: the SQL text
- db.operation: SELECT / INSERT / UPDATE / DELETE (from opts.type or regex)
- db.model: table name via 3-tier fallback (instance → tableNames → regex)
- error: "true" if the query throws

Adds ScoutContextName.DBOperation and ScoutContextName.DBModel to enum.
Adds sequelize e2e tests (findAll, create, raw query, error flag).
Supports sequelize v6.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Credits OpenTelemetry instrumentation-sequelize for the approach of
patching Sequelize.prototype.query and using opts.type for operation extraction.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant