Skip to content

Commit 2330dfa

Browse files
Update metrics group ID in BES after auth. (#11435)
Fixes buildbuddy-io/buildbuddy-internal#6731
1 parent 69caea2 commit 2330dfa

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

server/build_event_protocol/build_event_handler/build_event_handler.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,12 @@ func (b *BuildEventHandler) OpenChannel(ctx context.Context, iid string) (interf
199199
logWriter: nil,
200200
onClose: onClose,
201201
attempt: 1,
202-
groupIDForMetrics: b.getGroupIDForMetrics(ctx),
202+
groupIDForMetrics: getGroupIDForMetrics(ctx, b.env),
203203
}, nil
204204
}
205205

206-
func (b *BuildEventHandler) getGroupIDForMetrics(ctx context.Context) string {
207-
userInfo, err := b.env.GetAuthenticator().AuthenticatedUser(ctx)
206+
func getGroupIDForMetrics(ctx context.Context, env environment.Env) string {
207+
userInfo, err := env.GetAuthenticator().AuthenticatedUser(ctx)
208208
if err != nil {
209209
return interfaces.AuthAnonymousUser
210210
}
@@ -1165,6 +1165,7 @@ func (e *EventChannel) authenticateEvent(bazelBuildEvent *build_event_stream.Bui
11651165
return false, nil
11661166
}
11671167
e.ctx = auth.AuthContextFromAPIKey(e.ctx, apiKey)
1168+
e.groupIDForMetrics = getGroupIDForMetrics(e.ctx, e.env)
11681169
authError := e.ctx.Value(interfaces.AuthContextUserErrorKey)
11691170
if authError != nil {
11701171
if err, ok := authError.(error); ok {

0 commit comments

Comments
 (0)