Skip to content

Conversation

@jtomaszewski
Copy link

Summary

  • Add skipConnectSpans configuration option to skip creating pg.connect and pg-pool.connect spans
  • Query spans and pool metrics are still recorded when this option is enabled

Background

The pg.connect and pg-pool.connect spans measure connection time but provide limited actionable insight in many scenarios:

  • They don't correlate to specific queries
  • Query spans already include total time (including connection wait)
  • High-traffic scenarios create many connect spans per request

Changes

  • Add skipConnectSpans?: boolean to PgInstrumentationConfig (default false)
  • Skip span creation in both _getClientConnectPatch() and _getPoolConnectPatch() when enabled
  • Still call _setPoolConnectEventListeners() to preserve pool metrics
  • Add tests verifying both span types are skipped and metrics are preserved
  • Update README with new option documentation

Test plan

  • Added unit tests for skipConnectSpans=true verifying no connect spans are created
  • Added test verifying pool metrics are still recorded when skipping spans
  • Verified existing tests still pass

🤖 Generated with Claude Code

Add a configuration option to skip creating `pg.connect` and `pg-pool.connect`
spans while preserving query spans and pool metrics. This helps reduce trace
noise in high-throughput scenarios where connection time is not of interest.

- Add `skipConnectSpans?: boolean` to PgInstrumentationConfig
- Skip span creation for both client and pool connect operations
- Still set up event listeners for pool metrics when skipping spans
- Add tests for new option
- Update README with new option documentation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
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.

2 participants