Skip to content

Commit

Permalink
collab: Add is_staff to spans (#16389)
Browse files Browse the repository at this point in the history
This PR adds the `is_staff` field to our LLM spans so that we can
distinguish between staff and non-staff traffic.

Release Notes:

- N/A
  • Loading branch information
maxdeviant authored Aug 16, 2024
1 parent 1b1070e commit 3d997e5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion crates/collab/src/llm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ async fn validate_api_token<B>(mut req: Request<B>, next: Next<B>) -> impl IntoR
tracing::Span::current()
.record("user_id", claims.user_id)
.record("login", claims.github_user_login.clone())
.record("authn.jti", &claims.jti);
.record("authn.jti", &claims.jti)
.record("is_staff", &claims.is_staff);

req.extensions_mut().insert(claims);
Ok::<_, Error>(next.run(req).await.into_response())
Expand Down Expand Up @@ -558,6 +559,7 @@ impl<S> Drop for TokenCountingStream<S> {
user_id = claims.user_id,
login = claims.github_user_login,
authn.jti = claims.jti,
is_staff = claims.is_staff,
requests_this_minute = usage.requests_this_minute,
tokens_this_minute = usage.tokens_this_minute,
);
Expand Down
3 changes: 2 additions & 1 deletion crates/collab/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ async fn main() -> Result<()> {
matched_path,
user_id = tracing::field::Empty,
login = tracing::field::Empty,
authn.jti = tracing::field::Empty
authn.jti = tracing::field::Empty,
is_staff = tracing::field::Empty
)
})
.on_response(
Expand Down

0 comments on commit 3d997e5

Please sign in to comment.