Skip to content

feat(metrics): added a gauge with version information - #2375

Merged
cstockton merged 2 commits into
masterfrom
cs/feat-version-metric
Feb 17, 2026
Merged

feat(metrics): added a gauge with version information#2375
cstockton merged 2 commits into
masterfrom
cs/feat-version-metric

Conversation

@cstockton

@cstocktoncstockton commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

This adds the 4 gauges seen below:

 # HELP global_auth_version_major Set to this auth servers major version number.
# TYPE global_auth_version_major gauge
global_auth_version_major{otel_scope_name="gotrue",otel_scope_version=""} 2
# HELP global_auth_version_minor Set to this auth servers minor version number.
# TYPE global_auth_version_minor gauge
global_auth_version_minor{otel_scope_name="gotrue",otel_scope_version=""} 187
# HELP global_auth_version_patch Set to this auth servers patch version number.
# TYPE global_auth_version_patch gauge
global_auth_version_patch{otel_scope_name="gotrue",otel_scope_version=""} 0
# HELP global_auth_version_rc Set to this auth servers rc version number.
# TYPE global_auth_version_rc gauge
global_auth_version_rc{otel_scope_name="gotrue",otel_scope_version=""} 5

@cstockton
cstockton requested a review from a team as a code ownerFebruary 13, 2026 21:55
@coderabbitai

coderabbitaiBot commented Feb 13, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉


📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Version metrics are now collected and exposed, providing detailed version component information (major, minor, patch, release candidate) through observability platforms.

Walkthrough

The changes introduce a version metrics initialization system to internal/utilities/version.go, which exports the Version variable and InitVersionMetrics function. InitVersionMetrics parses semantic version information into major, minor, patch, and release candidate components, then creates OpenTelemetry gauge metrics for each component with bounds validation. The ConfigureMetrics function in internal/observability/metrics.go now calls InitVersionMetrics during metric setup. Comprehensive tests validate the semantic version parsing across multiple format variations and the complete initialization flow.

Sequence Diagram

sequenceDiagram
actor ConfigureMetrics as metrics.ConfigureMetrics()
participant InitVersionMetrics as utilities.InitVersionMetrics()
participant ParseVersion as parseSemver()
participant InitMetrics as initMetrics()
participant Gauge as OTLP Gauges
ConfigureMetrics->>InitVersionMetrics: ctx
InitVersionMetrics->>ParseVersion: Version string
alt ParseVersion succeeds
ParseVersion-->>InitVersionMetrics: versionInfo{Major, Minor, Patch, RC}
else ParseVersion fails
ParseVersion-->>InitVersionMetrics: error (use empty versionInfo)
end
InitVersionMetrics->>InitMetrics: ctx, versionInfo
InitMetrics->>Gauge: Create & record major gauge
InitMetrics->>Gauge: Create & record minor gauge
InitMetrics->>Gauge: Create & record patch gauge
InitMetrics->>Gauge: Create & record rc gauge
Gauge-->>InitMetrics: errors (if any)
InitMetrics-->>InitVersionMetrics: aggregated errors
InitVersionMetrics-->>ConfigureMetrics: error
Loading
🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title accurately describes the main change: adding version information metrics. It directly reflects the core functionality introduced across the modified files.
Merge Conflict Detection✅ Passed✅ No merge conflicts detected when merging into master

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@cmd/root_cmd.go`:
- Around line 56-59: The call to utilities.InitVersionMetrics(ctx) is ignoring
its returned error when config.Metrics.Enabled is true; capture the error and
handle it instead of discarding it. Update the block that checks
config.Metrics.Enabled to call err := utilities.InitVersionMetrics(ctx), then if
err != nil either return or wrap the error from the enclosing function (or log
it and exit) so failures are visible; reference the symbols
config.Metrics.Enabled and utilities.InitVersionMetrics(ctx) when making the
change.
In `@internal/utilities/version.go`:
- Around line 23-33: initVersionMetrics currently swallows parseSemver errors
and always returns nil, which hides malformed versions; change it to capture the
parse error from parseSemver(ver), still call initMetrics(ctx, vi) using a
zeroed vi when parse fails, and then return the original parse error (or a
wrapped error) if parseSemver returned one while still returning any initMetrics
error if that fails; reference parseSemver, initMetrics, initVersionMetrics, and
versionInfo to locate the changes.
🧹 Nitpick comments (1)
internal/utilities/version_test.go (1)

141-148: Improve the error assertion message for debuggability.

The current t.Fatalf("exp ") is truncated, making failures hard to diagnose.

🛠️ Suggested fix
 if tc.err != "" {
if err == nil {
t.Fatal("exp non-nil err")
}
if exp, got := tc.err, err.Error(); !strings.Contains(got, exp) {
- t.Fatalf("exp ")+ t.Fatalf("exp error containing %q; got %q", exp, got)
}
continue
}

Comment threadcmd/root_cmd.go Outdated
Comment threadinternal/utilities/version.go
@jnschaeffer

Copy link
Copy Markdown
Contributor

Out of curiosity, why have different gauges for each version number rather than a single label with a version string?

@cstockton

Copy link
Copy Markdown
ContributorAuthor

Out of curiosity, why have different gauges for each version number rather than a single label with a version string?

I chose this because it sets maximum cardinality to 4 and I think it makes for better querying.

This adds the 4 gauges seen below:
# HELP global_auth_version_major Set to this auth servers major version number.
# TYPE global_auth_version_major gauge
global_auth_version_major{otel_scope_name="gotrue",otel_scope_version=""} 2
# HELP global_auth_version_minor Set to this auth servers minor version number.
# TYPE global_auth_version_minor gauge
global_auth_version_minor{otel_scope_name="gotrue",otel_scope_version=""} 187
# HELP global_auth_version_patch Set to this auth servers patch version number.
# TYPE global_auth_version_patch gauge
global_auth_version_patch{otel_scope_name="gotrue",otel_scope_version=""} 0
# HELP global_auth_version_rc Set to this auth servers rc version number.
# TYPE global_auth_version_rc gauge
global_auth_version_rc{otel_scope_name="gotrue",otel_scope_version=""} 5
@cstockton
cstocktonforce-pushed the cs/feat-version-metric branch from f670015 to 024b889CompareFebruary 17, 2026 13:21
@coveralls

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 22100400863

Details

  • 61 of 74(82.43%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.05%) to 69.08%

Changes Missing CoverageCovered LinesChanged/Added Lines%
internal/observability/metrics.go030.0%
internal/utilities/version.go617185.92%
TotalsCoverage Status
Change from base Build 22075658585:0.05%
Covered Lines:15002
Relevant Lines:21717

💛 - Coveralls

Comment threadinternal/utilities/version.go
@cstockton
cstockton merged commit 911ad0b into masterFeb 17, 2026
7 checks passed
@cstockton
cstockton deleted the cs/feat-version-metric branch February 17, 2026 14:54
cstockton pushed a commit that referenced this pull request Feb 24, 2026
🤖 I have created a release *beep* *boop*
---
##
[2.187.0](v2.186.0...v2.187.0)
(2026-02-23)
### Features
* add metadata field to all hooks
([#2365](#2365))
([c675749](c675749))
* check current password on change
([#2364](#2364))
([33b87ae](33b87ae))
* **indexworker:** add max users threshold for rollout
([#2374](#2374))
([a2066c6](a2066c6))
* **metrics:** added a gauge with version information
([#2375](#2375))
([911ad0b](911ad0b))
* support custom oauth & oidc providers
([#2357](#2357))
([53021f6](53021f6))
### Bug Fixes
* case-insensitive Bearer token scheme matching
([#2387](#2387))
([36d712d](36d712d))
* correctly parse JWT ValidMethods from env by enabling split_words
([#2334](#2334))
([a6076bc](a6076bc))
* flaky index worker test
([#2366](#2366))
([961a7e6](961a7e6))
* **hooks:** propagate error objects from hook calls
([#2380](#2380))
([3ca1e88](3ca1e88))
* session upgrade percentage should be based on session, not request
([#2371](#2371))
([510e68b](510e68b))
---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Co-authored-by: supabase-releaser[bot] <223506987+supabase-releaser[bot]@users.noreply.github.com>
Sign up for freeto 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.

4 participants

@cstockton@jnschaeffer@coveralls@fadymak