Skip to content

feat: add support for PGAPPNAME to set application name#6139

Merged
roji merged 1 commit into
npgsql:mainfrom
michael-todorovic:feat/pgappname
Jun 17, 2025
Merged

feat: add support for PGAPPNAME to set application name#6139
roji merged 1 commit into
npgsql:mainfrom
michael-todorovic:feat/pgappname

Conversation

@michael-todorovic

@michael-todorovic michael-todorovic commented Jun 17, 2025

Copy link
Copy Markdown
Contributor

This PR solves #6133

This is especially useful to automatically set the application name. For example, we'll use it in Kubernetes to push the pod name:

spec:
  template:
    spec:
      containers:
      - name: my-app
        env:
        - name: PGAPPNAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name

Related doc is at npgsql/doc#409

Signed-off-by: Michael Todorovic <michael.todorovic@outlook.com>

@vonzshik vonzshik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

{
const string testAppName = "MyTestApp";

// Note that the pool is unaware of the environment variable, so if a connection is

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, we have this with various other environment variables as well; modifying environment variables as they application is running is not supported in thaat sense.

@roji roji merged commit 317c4e3 into npgsql:main Jun 17, 2025
15 checks passed
@vonzshik vonzshik linked an issue Jun 18, 2025 that may be closed by this pull request
This was referenced Nov 23, 2025
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.

Support for libpq's PGAPPNAME

3 participants