Skip to content

feat(node): Add ClickHouse client OpenTelemetry instrumentation#18625

Open
mdhamed238 wants to merge 5 commits intogetsentry:developfrom
mdhamed238:feat/clickhouse-integration
Open

feat(node): Add ClickHouse client OpenTelemetry instrumentation#18625
mdhamed238 wants to merge 5 commits intogetsentry:developfrom
mdhamed238:feat/clickhouse-integration

Conversation

@mdhamed238
Copy link

@mdhamed238 mdhamed238 commented Dec 26, 2025

Implements OpenTelemetry instrumentation for the @clickhouse/client package to automatically trace database operations.

Changes

  • Add ClickHouse instrumentation that wraps query, insert, exec, and command methods
  • Emit spans with DB metadata (system, operation, statement), peer info (host/port), and execution stats (rows, bytes, elapsed time)
  • Support configurable query text sanitization via maxQueryLength and captureQueryText options
  • Support custom database name and peer overrides via dbName, peerName, and peerPort config
  • Add responseHook for custom span enrichment
  • Add comprehensive functional test suite covering all methods, config options, error handling, and SQL operation extraction

Checklist

  • Added tests (13 functional tests for ClickHouse instrumentation)
  • yarn lint passes
  • yarn test passes

Closes #15966

@github-actions
Copy link
Contributor

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you apply the label PR: no-auto-close I will leave it alone ... forever!

@github-actions
Copy link
Contributor

Closing due to inactivity after stale warning. Comment or reopen when ready to continue, and use PR: no-auto-close to opt out of automatic closure.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable autofix in the Cursor dashboard.

} catch {
// Silently ignore errors in stats extraction
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repetitive stat-handling code in addExecutionStats

Low Severity

The addExecutionStats function repeats the identical parseInt-then-setAttribute pattern seven times (one for each stat field). A data-driven approach—mapping summary keys to attribute constants and iterating—would reduce ~42 lines to ~10, making it easier to add new stats and ensuring any future fix to the parsing logic is applied consistently.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clickhouse instrumentation (@clickhouse/client)

2 participants