Skip to content

fix(database_observability.postgres): Correctly handle dsn with unix sockets#6030

Open
k3-cat wants to merge 2 commits intografana:mainfrom
k3-cat:fix-o11y-postgres-dsn-parser-for-unix-sockets
Open

fix(database_observability.postgres): Correctly handle dsn with unix sockets#6030
k3-cat wants to merge 2 commits intografana:mainfrom
k3-cat:fix-o11y-postgres-dsn-parser-for-unix-sockets

Conversation

@k3-cat
Copy link
Copy Markdown

@k3-cat k3-cat commented Apr 10, 2026

Brief description of Pull Request

Fixes dsnParseRegex so that replaceDatabaseNameInDSN can properly handle dsn with unix sockets, instead of treating the final part of sockets path as dbname.

Pull Request Details

Current behaviour image
  • Thus, alloy will try to connect /run/{dbname}/.s.PGSQL.5432 and produce error: dial unix /run/{dbname}/.s.PGSQL.5432: connect: no such file or directory
Fixed behaviour image

Although simply replace the .+ in matching group 1 with .*? or [^?]* can solve this issue as well, the current approach provides better robustness for future changes and edge cases (eg. unescaped spaces present in dsn).

Issue(s) fixed by this Pull Request

nil

Notes to the Reviewer

  • matching group 3 is also rewired for better readability (as .* would match \?? anyway) and robustness under edge cases
  • $ in matching group 3 is dropped intentionally, as this can generally improve the performance sightly

PR Checklist

  • Documentation added (maybe not applicable?)
  • Tests updated
  • Config converters updated (not applicable)

@k3-cat k3-cat requested a review from a team as a code owner April 10, 2026 08:19
@cla-assistant
Copy link
Copy Markdown

cla-assistant bot commented Apr 10, 2026

CLA assistant check
All committers have signed the CLA.

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