sql-pg: trace each connection attempt, with why it failed

オープン
#10,951 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
typescript
領域
observability

調査の方向性

Start by reading the existing db.connect span behavior in @effect/sql-pg and the PgConnection connection-attempt flow. Check how password resolution, timeout, authentication, interruption, and ReadyForQuery are handled, then compare the proposed span and failure categories with project conventions. Done means the maintainers agree on the API shape and a PR covers per-attempt tracing without changing pool behavior.

索引モデルが issue の本文から書いたものです。

説明

Note: everything below was written by an AI agent working on the author's behalf and may not have been reviewed by a human.

This is AI-generated; I don't have strong opinions on the API or developer experience and am glad to take whatever shape you prefer, but I do need the functionality.

Problem

With SpanPropagationEnabled, @effect/sql-pg adds a db.connect child span to a statement that waited for a new session (#8676), covering the part of the connect it waited for. A connection attempt has no span of its own, so these are invisible in a trace:

  • an attempt that fails, and why: a timeout, a refused or unreachable host, an authentication failure, or something else;
  • an attempt that no statement waited for, such as one the pool opens ahead of demand;
  • how long password resolution, the TCP/TLS connect and authentication took, until ReadyForQuery.

On serverless Postgres behind a proxy, failed and slow connects are exactly what I need to see when the first query of a request is slow.

What I do today

I carry a patch to PgConnection that wraps each connection attempt in a client span, sql.connect:

  • It covers password resolution, the driver's connect and authentication, and connectTimeout, and ends at ReadyForQuery, or on failure or interruption. The timeout runs inside the span, so a timed-out attempt fails its span instead of ending OK.
  • It records db.connect.attempt and, on failure, db.connect.failure: timeout, refused (the socket never connected, or the server refused the startup for a reason other than authentication), auth (SQLSTATE class 28, or no password), or other. The category comes from when the attempt failed, not from the socket error's text, because some runtimes give a refused connection no error code.
  • It records no URL, credentials or query text. An attempt its caller interrupts records no failure.
  • Pool behaviour (lazy acquisition, reuse, idle release) is unchanged, and it opens no connection to measure one.

Questions

  1. Would you take a per-attempt span in @effect/sql-pg, alongside the existing db.connect?
  2. Are a span name sql.connect and the attributes db.connect.attempt / db.connect.failure acceptable, or would you rather follow another convention?

I can open a PR once the shape is agreed.

主要言語
TypeScript
スター
16.7k
フォーク
808
平均マージ
21時間 22分
マージ済み PR(30日)
486

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Effect-TS/effect のほかの issue

Effect-TS/effect の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。