Skip to content

database_observability: Add pgsql engine version to connection_info #4099

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

rgeyer
Copy link
Contributor

@rgeyer rgeyer commented Jul 31, 2025

PR Description

More-or-less a mirror of #4097 to implement this same functionality for pgsql.

Notes to the Reviewer

The SHOW server_version is still fairly verbose, and provides not only the version, but also the OS flavor and build details (I.E. 17.2 (Debian 17.2-1.pgdg120+1)).

Do we care about the fine-grained detail, or do we only want the major version (17.2)?

My gut is to just parse this and drop everything after the major version number.

@gaantunes
Copy link
Contributor

I wonder why the version information includes build and os info... It might be important for debugging edge cases. Can we put it in a additional field.

@rgeyer
Copy link
Contributor Author

rgeyer commented Jul 31, 2025

I wonder why the version information includes build and os info... It might be important for debugging edge cases. Can we put it in a additional field.

Did do, it now produces a result like this..

database_observability_connection_info{db_instance_identifier="unknown", db_version="17.2", db_version_suffix="(Debian 17.2-1.pgdg120+1)", engine="postgres", instance="dbo11y", job="integrations/db-o11y", provider_name="unknown", provider_region="unknown"}


args.Registry.MustRegister(infoMetric)

return &ConnectionInfo{
DSN: args.DSN,
Registry: args.Registry,
DBVersion: args.DBVersion,
Copy link
Contributor

Choose a reason for hiding this comment

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

should we use the same engine terminology?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair play. Updated that as well. In MySQL we might consider renaming that in the explain plan schema as well.

@@ -58,6 +63,8 @@ func (c *ConnectionInfo) Start(ctx context.Context) error {
providerRegion = "unknown"
dbInstanceIdentifier = "unknown"
engine = "postgres"
engineVersion = "unknown"
engineVersionSuffix = "none"
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need the suffix for anything? If not I'd remove it for now (easier to add later when we need it)

Copy link
Contributor

Choose a reason for hiding this comment

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

I asked Ryan to put this up since it won't hurt and this info might be useful for debugging in the future.

Copy link
Contributor

Choose a reason for hiding this comment

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

I feel the opposite - let's not collect data we don't need. We can always add it later once we have a use for it.


matches := versionRegex.FindStringSubmatch(c.EngineVersion)
fmt.Println(matches)
if len(matches) > 1 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these be inclusive?

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.

3 participants