Skip to content

Commit e8ddca3

Browse files
docs(customer): simplify comments added on this branch
Trim redundant clauses in two comments (governance namespace-scale benchmark doc, bulk usage-attribution created_at-guard note) that restated the same point twice or over-qualified it. No behavior change.
1 parent 5a763e2 commit e8ddca3

2 files changed

Lines changed: 20 additions & 24 deletions

File tree

e2e/governance_bench_namespace_test.go

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,21 @@ const (
2525
// size on governance query latency, independent of the customers/features axes
2626
// BenchmarkGovernanceQuery already covers. It fixes a small, constant query
2727
// load (100 customers, matching the OAS customer-key cap, x 1 feature) so the
28-
// entitlement GetAccess fan-out cost — the dominant cost per
29-
// BenchmarkGovernanceQuery's doc comment — stays flat across sub-benchmarks,
30-
// and varies only how many OTHER customers/subjects exist in the namespace
31-
// (decoys, never queried, seeded directly via SQL for speed, not HTTP).
28+
// entitlement GetAccess fan-out cost stays flat across sub-benchmarks, and
29+
// varies only how many other (never-queried) customers/subjects exist in the
30+
// namespace.
3231
//
33-
// This targets the customer usage-attribution resolution path specifically:
34-
// pre-UNION-ALL, a large decoy count made GetCustomersByUsageAttribution
35-
// seq-scan the customers table (see #4684 and the follow-up bulk fix); this
36-
// benchmark shows whether decoy count still moves total request latency
37-
// post-fix. Decoy counts accumulate across sub-benchmarks (0 -> 10k -> N), so
38-
// each step only seeds the incremental delta.
32+
// This targets the customer usage-attribution resolution path: pre-UNION-ALL,
33+
// a large decoy count made GetCustomersByUsageAttribution seq-scan the
34+
// customers table (see #4684 and the follow-up bulk fix); this benchmark shows
35+
// whether decoy count still moves total request latency post-fix. Decoy
36+
// counts accumulate across sub-benchmarks (0 -> 10k -> N), so each step only
37+
// seeds the incremental delta.
3938
//
40-
// Requires direct Postgres access alongside OPENMETER_ADDRESS (see
41-
// initE2EPostgresPool) — creating decoys over HTTP would dominate the
42-
// benchmark's own setup time long before showing anything about the query
43-
// path. Set GOV_BENCH_NAMESPACE_DECOYS to change the top decoy count from the
44-
// default 100,000.
39+
// Decoys are seeded directly via SQL (not HTTP, which would dominate setup
40+
// time) and require direct Postgres access alongside OPENMETER_ADDRESS (see
41+
// initE2EPostgresPool). Set GOV_BENCH_NAMESPACE_DECOYS to change the top
42+
// decoy count from the default 100,000.
4543
func BenchmarkGovernanceQueryNamespaceScale(b *testing.B) {
4644
client := initClient(b)
4745
v3 := newV3Client(b)

openmeter/customer/adapter/customer.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -681,15 +681,13 @@ func (a *adapter) GetCustomersByUsageAttribution(ctx context.Context, input cust
681681
return entutils.TransactingRepo(ctx, a, func(ctx context.Context, repo *adapter) ([]customer.Customer, error) {
682682
now := clock.Now().UTC()
683683

684-
// No CreatedAtLTE(now) guard here or in WithSubjects below, deliberately: this keeps the
685-
// candidate predicate and the eager-loaded subject list in agreement (both consider every
686-
// subject regardless of created_at), matching the single-key
687-
// customerMatchesUsageAttributionKey, which has never had this guard. created_at is
688-
// server-assigned, immutable, and never caller-supplied (see the ResourceMixin/
689-
// CustomerSubjects schema), so a future-created subject cannot occur in production; adding
690-
// the guard to only one of the two paths (candidate query vs. eager load) would instead
691-
// introduce a real, batch-composition-dependent resolution bug in the caller's per-key
692-
// precedence logic for a case that can't happen.
684+
// Deliberately no CreatedAtLTE(now) guard here or in WithSubjects below: this keeps the
685+
// candidate predicate and the eager-loaded subject list in agreement, matching the single-key
686+
// customerMatchesUsageAttributionKey, which never had this guard either. created_at is
687+
// server-assigned and immutable (see ResourceMixin/CustomerSubjects schema), so a
688+
// future-created subject can't occur in production — guarding only one of the two paths
689+
// would instead cause a real, batch-composition-dependent resolution bug for a case that
690+
// can't happen.
693691
query := repo.db.Customer.Query().
694692
Where(
695693
customerdb.Namespace(input.Namespace),

0 commit comments

Comments
 (0)