Skip to content

Commit

Permalink
make sure to also check if there is user object on request in respons…
Browse files Browse the repository at this point in the history
…e hook
  • Loading branch information
ramonavic committed Sep 25, 2024
1 parent ce41e26 commit 057d5a5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/main/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,11 @@

# As required, the user id and name is attached to each request that is recorded as a span
def response_hook(span, request, response):
if span and span.is_recording() and request.user.is_authenticated:
span.set_attribute('user_id', request.user.id)
span.set_attribute('username', request.user.username)
if all([span, span.is_recording(), request.user, request.user.is_authenticated]):
span.set_attributes({
'user_id': request.user.id,
'username': request.user.username
})


# Logs and traces will be exported to Azure Application Insights
Expand Down

0 comments on commit 057d5a5

Please sign in to comment.