Skip to content

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

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

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

Conversation

@cstockton
Copy link
Contributor

@cstockton cstockton commented Feb 13, 2026

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 owner February 13, 2026 21:55
@coderabbitai
Copy link

coderabbitai bot commented Feb 13, 2026

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 name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring 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 name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The 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.

Copy link

@coderabbitai coderabbitai bot left a comment

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
 		}

@jnschaeffer
Copy link
Contributor

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

@cstockton
Copy link
Contributor Author

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 cstockton force-pushed the cs/feat-version-metric branch from f670015 to 024b889 Compare February 17, 2026 13:21
@coveralls
Copy link

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 Coverage Covered Lines Changed/Added Lines %
internal/observability/metrics.go 0 3 0.0%
internal/utilities/version.go 61 71 85.92%
Totals Coverage Status
Change from base Build 22075658585: 0.05%
Covered Lines: 15002
Relevant Lines: 21717

💛 - Coveralls

@cstockton cstockton merged commit 911ad0b into master Feb 17, 2026
7 checks passed
@cstockton cstockton deleted the cs/feat-version-metric branch February 17, 2026 14:54
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.

4 participants

Comments