Skip to content

STO-533: Convert littdb to use otel#3466

Open
cody-littley wants to merge 1 commit into
mainfrom
cjl/litt-better-metrics
Open

STO-533: Convert littdb to use otel#3466
cody-littley wants to merge 1 commit into
mainfrom
cjl/litt-better-metrics

Conversation

@cody-littley
Copy link
Copy Markdown
Contributor

Describe your changes and provide context

LittDB's original metrics stack uses the prometheus APIs. Convert instead to using OTEL APIs.

Testing performed to validate your change

unit tests

@cursor
Copy link
Copy Markdown

cursor Bot commented May 19, 2026

PR Summary

Medium Risk
Switches LittDB metrics to the global OTel MeterProvider and changes startup/shutdown behavior for metrics export and serving, which could impact existing metrics names/labels and lifecycle in production.

Overview
LittDB metrics are migrated from Prometheus client types to OpenTelemetry instruments. LittDBMetrics and cache metrics now use OTel counters/gauges/histograms, record latencies in seconds with shared bucket boundaries, and tag per-table/per-cache series via OTel attributes.

Metrics wiring is simplified around a global OTel provider. buildMetrics now calls commonmetrics.SetupOtelPrometheus() and starts the /metrics HTTP server unconditionally when MetricsEnabled is true, returning a provider shutdown function that db.gatherMetrics invokes on teardown; config options for custom Prometheus registry/namespace are removed.

Reviewed by Cursor Bugbot for commit be9328d. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions
Copy link
Copy Markdown

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedMay 19, 2026, 6:53 PM

@github-actions
Copy link
Copy Markdown

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedMay 19, 2026, 6:53 PM

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit be9328d. Configure here.

logger.Info("Starting metrics server", "port", config.MetricsPort)
commonmetrics.StartMetricsServer(config.CTX, reg, addr)

return metrics.NewLittDBMetrics(), shutdown
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Metrics HTTP server leaks after DB close

Medium Severity

The metrics HTTP server started by commonmetrics.StartMetricsServer is never shut down when db.Close() is called. The old code deferred d.metricsServer.Close() inside gatherMetrics, but the new code only defers d.metricsShutdown (the OTel provider.Shutdown), which flushes the meter provider without stopping the HTTP listener. The server only terminates when config.CTX is cancelled, and the default context is context.Background(), which is never cancelled. This leaks a goroutine and a bound TCP port after every Close() call.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit be9328d. Configure here.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

❌ Patch coverage is 6.66667% with 154 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.98%. Comparing base (f87766f) to head (be9328d).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
sei-db/db_engine/litt/metrics/littdb_metrics.go 0.00% 107 Missing ⚠️
sei-db/db_engine/litt/util/cache_metrics.go 0.00% 31 Missing ⚠️
sei-db/db_engine/litt/littbuilder/build_utils.go 0.00% 9 Missing ⚠️
sei-db/db_engine/litt/littbuilder/db_impl.go 64.70% 6 Missing ⚠️
sei-db/db_engine/litt/littdb_config.go 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3466      +/-   ##
==========================================
+ Coverage   58.96%   58.98%   +0.02%     
==========================================
  Files        2185     2185              
  Lines      181869   181796      -73     
==========================================
- Hits       107240   107238       -2     
+ Misses      65024    64953      -71     
  Partials     9605     9605              
Flag Coverage Δ
sei-chain-pr 42.77% <6.66%> (?)
sei-db 70.41% <ø> (-0.22%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
sei-db/db_engine/litt/littdb_config.go 55.55% <0.00%> (-0.70%) ⬇️
sei-db/db_engine/litt/littbuilder/db_impl.go 54.90% <64.70%> (-0.73%) ⬇️
sei-db/db_engine/litt/littbuilder/build_utils.go 50.00% <0.00%> (+5.70%) ⬆️
sei-db/db_engine/litt/util/cache_metrics.go 17.64% <0.00%> (+3.36%) ⬆️
sei-db/db_engine/litt/metrics/littdb_metrics.go 3.38% <0.00%> (+0.68%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant