- Notifications
You must be signed in to change notification settings - Fork1k
chore: wire up usage tracking for managed agents#19096
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
chore: wire up usage tracking for managed agents#19096
Conversation
deansheather commentedJul 30, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
This stack of pull requests is managed byGraphite. Learn more aboutstacking. |
6d0a33f
to89b1757
Compare89b1757
to397a84d
Comparee376311
to82ea8e1
ComparesidebarAppID= uuid.NullUUID{} | ||
} | ||
ifhasAITask { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Don't we only want to do this on START transitions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
You're right 🤦♂️ Added a test
Uh oh!
There was an error while loading.Please reload this page.
enterprise/coderd/usage/inserter.go Outdated
// Duplicate events are ignored by the query, so we don't need to check the | ||
// error. | ||
returntx.InsertUsageEvent(ctx, database.InsertUsageEventParams{ | ||
returntx.InsertUsageEvent(dbauthz.AsUsageTracker(ctx), database.InsertUsageEventParams{//nolint:gocritic // intentionally want to insert usage events |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
If we override the context this way it means that anything that can access the Inserter can create usage events, including totally unauthenticated API routes.
We need to let RBAC do its job and actually authorize the appropriaterbac.Subject
s. Right now the only legit caller is provisionerdserver, which already has it's own subject in dbauthz.go L189.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Fixed and enabled dbauthz in provisionerdserver tests too to ensure it's tested.
40d1681
to7c36cc0
Comparedca0890
to2529c80
Compare2529c80
toa25d856
Compare7c36cc0
toaf6661d
Compareaf6661d
to3aea6d1
CompareI added dbauthz to the provisionerdserver tests to ensure the permissions were correct. To do so I had to refactor a bunch of the tests since they didn't have many required DB resources (jobs are RBAC checked by their linked workspace build or template version). Also, I disabled the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LG, just mainly the comment on the dbauthz function for licenses.
What happens to these usage events if you run the enterprise coderd binary without a license? Or without the entitlement? Are all events still sent to Tallyman?
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
m["f"].Text.Matches("^As"), | ||
m["f"].Text.Matches("^As")&& | ||
// Ignore test usages of dbauthz contexts. | ||
!m.File().Name.Matches(`_test\.go$`), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
❤️
2d92d73
to29655e5
Comparedeansheather commentedAug 20, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Merge activity
|
6eb02d1
intomainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Wires up the usage collector and publisher to coderd.
Relates tocoder/internal#814