Title: fix(coderd/externalauth/gitprovider): add observability to the response cache · Issue #28140 · coder/coder · GitHub
Open Graph Title: fix(coderd/externalauth/gitprovider): add observability to the response cache · Issue #28140 · coder/coder
X Title: fix(coderd/externalauth/gitprovider): add observability to the response cache · Issue #28140 · coder/coder
Description: Follow-up from #27711 (CRF-12). Problem The ETag response cache in coderd/externalauth/gitprovider/conditional.go emits no signal: no hit, miss, or eviction counter, and no log. A 0% hit rate is indistinguishable from a healthy cache fro...
Open Graph Description: Follow-up from #27711 (CRF-12). Problem The ETag response cache in coderd/externalauth/gitprovider/conditional.go emits no signal: no hit, miss, or eviction counter, and no log. A 0% hit rate is in...
X Description: Follow-up from #27711 (CRF-12). Problem The ETag response cache in coderd/externalauth/gitprovider/conditional.go emits no signal: no hit, miss, or eviction counter, and no log. A 0% hit rate is in...
Opengraph URL: https://github.com/coder/coder/issues/28140
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"fix(coderd/externalauth/gitprovider): add observability to the response cache","articleBody":"Follow-up from #27711 (CRF-12).\n\n## Problem\n\nThe ETag response cache in `coderd/externalauth/gitprovider/conditional.go` emits no signal: no hit, miss, or eviction counter, and no log. A 0% hit rate is indistinguishable from a healthy cache from the outside.\n\nThe motivating evidence is #27711 itself: the cache shipped broken at a 0% hit rate, ran in production, and was found by reading code rather than by any signal. Every way the cache can silently return to that state looks identical from outside:\n\n- An empty `ETag` header from a GHE instance (`store` drops those at `conditional.go`)\n- Eviction thrash past the 2048-entry ceiling (CRF-11)\n- Token churn changing every cache key\n\nThe symptom arrives later as a user's GitHub token hitting the 5000/hour primary rate limit and PR status going stale, with nothing to grep server-side.\n\n## Proposed fix\n\nTwo counters in `load` (hit, miss), one on the 304 branch, and a Debug log on eviction. The full fix is putting the poll client behind the same instrumentation as `coderd/promoauth`, which already instruments external OAuth2 traffic precisely because those calls count against provider rate limits.\n\n## Hidden cost: the plumbing dominates\n\nThe cache is constructed inside `newGitHub()`, called from `Config.Git()`, called from `exp_chats.go`. None of those have access to a `prometheus.Registerer` today. The repo convention (and `promoauth` proves it) is injected registries, not `promauto` defaults.\n\nSo the real work is:\n\n1. Thread a `prometheus.Registerer` through `ConvertConfig` -> `Config` -> `gitprovider.New` (a signature change, or a new `Option` like `WithMetrics` alongside the existing `WithClock`).\n2. Define and register the counters.\n3. Tests need a real registry (the `testutil/promhelp` pattern).\n\nThe counter definitions themselves are ~10 lines; the threading and tests are ~90-130 of the ~100-140 total. This is why it was deferred rather than folded into #27711: the plumbing is most of it, and none of it was necessary for the cache fix to be correct.\n\n## Counter-arguments for deferring\n\n- The cache is now heavily tested in #27711; five tests pin its invariants. The specific bug that motivated it (cache discarded every poll) cannot silently recur.\n- The remaining failure modes (empty ETag, eviction thrash, token churn) are degraded hit rates, not silent data loss.\n\nThis is best done as a focused follow-up while the cache code is fresh and the design settled.\n\n> 🤖 Generated by Coder Agents on behalf of @johnstcn.","author":{"url":"https://github.com/johnstcn","@type":"Person","name":"johnstcn"},"datePublished":"2026-08-13T17:37:01Z","url":"https://github.com/coder/coder/issues/28140"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ff798348-7b87-51ae-9b20-084ad15ef937 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8946:26F6D6:E3764:139935:6B04B0AC |
| html-safe-nonce | 0986859a7ab245665ce4c8ccd6f8ae53ab947032f98960cef857ec8522bbc80e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OTQ2OjI2RjZENjpFMzc2NDoxMzk5MzU6NkIwNEIwQUMiLCJ2aXNpdG9yX2lkIjoiNjMyNzQxODEyMzc0MjEzMDM0OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 989e73e1204cf06d236f35c9a577b29827e6b1e1675874de75c7f8cdc052d5bf |
| hovercard-subject-tag | issue:5144128969 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/coder/coder/28140/issue_layout |
| twitter:image | https://opengraph.githubassets.com/417ef786e3f8262deb130af4eb00a5eb2ee817bb4263cec7f1bf8f1029ca23d1/coder/coder/issues/28140 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/417ef786e3f8262deb130af4eb00a5eb2ee817bb4263cec7f1bf8f1029ca23d1/coder/coder/issues/28140 |
| og:image:alt | Follow-up from #27711 (CRF-12). Problem The ETag response cache in coderd/externalauth/gitprovider/conditional.go emits no signal: no hit, miss, or eviction counter, and no log. A 0% hit rate is in... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | johnstcn |
| hostname | github.com |
| expected-hostname | github.com |
| None | f1d110ea058a0915c1d8aa3fc2069fa15801e128f591e5762525abe77490ecb1 |
| turbo-cache-control | no-preview |
| go-import | github.com/coder/coder git https://github.com/coder/coder.git |
| octolytics-dimension-user_id | 95932066 |
| octolytics-dimension-user_login | coder |
| octolytics-dimension-repository_id | 440752086 |
| octolytics-dimension-repository_nwo | coder/coder |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 440752086 |
| octolytics-dimension-repository_network_root_nwo | coder/coder |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ffa22a65e4c46d376940fe34b05e6a7e9c7fdb9b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width