Skip to content

Commit 7243c41

Browse files
committed
more PR comments
1 parent 82ea8e1 commit 7243c41

File tree

5 files changed

+14
-4
lines changed

5 files changed

+14
-4
lines changed

coderd/pproflabel/pproflabel.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ const (
3232
// ServiceAgentMetricAggregator merges agent metrics and exports them in a
3333
// prometheus collector format.
3434
ServiceAgentMetricAggregator = "agent-metrics-aggregator"
35+
// ServiceTallymanPublisher publishes usage events to coder/tallyman.
36+
ServiceTallymanPublisher = "tallyman-publisher"
3537

3638
RequestTypeTag = "coder_request_type"
3739
)

coderd/rbac/roles.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ func ReloadBuiltinRoles(opts *RoleOptions) {
271271
// Workspace dormancy and workspace are omitted.
272272
// Workspace is specifically handled based on the opts.NoOwnerWorkspaceExec.
273273
// Owners cannot access other users' secrets.
274-
allPermsExcept(ResourceWorkspaceDormant, ResourcePrebuiltWorkspace, ResourceWorkspace, ResourceUserSecret),
274+
allPermsExcept(ResourceWorkspaceDormant, ResourcePrebuiltWorkspace, ResourceWorkspace, ResourceUserSecret, ResourceUsageEvent),
275275
// This adds back in the Workspace permissions.
276276
Permissions(map[string][]policy.Action{
277277
ResourceWorkspace.Type: ownerWorkspaceActions,

coderd/rbac/roles_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,8 +877,9 @@ func TestRolePermissions(t *testing.T) {
877877
Actions: []policy.Action{policy.ActionCreate, policy.ActionRead, policy.ActionUpdate},
878878
Resource: rbac.ResourceUsageEvent,
879879
AuthorizeMap: map[bool][]hasAuthSubjects{
880-
true: {owner},
880+
true: {},
881881
false: {
882+
owner,
882883
memberMe, orgMemberMe, otherOrgMember,
883884
orgAdmin, otherOrgAdmin,
884885
orgAuditor, otherOrgAuditor,

enterprise/coderd/usage/publisher.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"cdr.dev/slog"
1717
"github.com/coder/coder/v2/coderd/database"
1818
"github.com/coder/coder/v2/coderd/database/dbtime"
19+
"github.com/coder/coder/v2/coderd/pproflabel"
1920
agplusage "github.com/coder/coder/v2/coderd/usage"
2021
"github.com/coder/coder/v2/cryptorand"
2122
"github.com/coder/coder/v2/enterprise/coderd"
@@ -127,7 +128,8 @@ func PublisherWithInitialDelay(initialDelay time.Duration) TallymanPublisherOpti
127128

128129
// Start implements Publisher.
129130
func (p *tallymanPublisher) Start() error {
130-
deploymentID, err := p.db.GetDeploymentID(p.ctx)
131+
ctx := p.ctx
132+
deploymentID, err := p.db.GetDeploymentID(ctx)
131133
if err != nil {
132134
return xerrors.Errorf("get deployment ID: %w", err)
133135
}
@@ -147,7 +149,9 @@ func (p *tallymanPublisher) Start() error {
147149
p.initialDelay = tallymanPublishInitialMinimumDelay + time.Duration(plusDelay)
148150
}
149151

150-
go p.publishLoop(p.ctx, deploymentUUID)
152+
pproflabel.Go(ctx, pproflabel.Service(pproflabel.ServiceTallymanPublisher), func(ctx context.Context) {
153+
p.publishLoop(ctx, deploymentUUID)
154+
})
151155
return nil
152156
}
153157

enterprise/coderd/usage/publisher_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,9 @@ func TestPublisherTallymanError(t *testing.T) {
630630

631631
func jsoninate(t *testing.T, v any) string {
632632
t.Helper()
633+
if e, ok := v.(agplusage.Event); ok {
634+
v = e.Fields()
635+
}
633636
buf, err := json.Marshal(v)
634637
require.NoError(t, err)
635638
return string(buf)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy