Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): Fix logging so that it shows properly on stackdriver #28777

Merged
merged 1 commit into from
Sep 22, 2021

Conversation

AniketDas-Tekky
Copy link
Contributor

Log messages were not showing up on stack driver because they were not in the correct format.

Log messages were not showing up on stack driver because they were not in the correct format.
@@ -176,9 +176,9 @@ def _create_api_access_log(self):
user=str(self.request.user),
token_type=token_name,
)
api_access_logger.info(log_metrics)
api_access_logger.info("api.access", extra=log_metrics)
except Exception:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where in the above do we expect it to error out? could we catch more specific exceptions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm catching a generic exception because I don't want API requests to fail because of any logging error. As for where it could error out, most likely trying to access data members that don't exist, or key errors.

@AniketDas-Tekky AniketDas-Tekky merged commit 82682bc into master Sep 22, 2021
@AniketDas-Tekky AniketDas-Tekky deleted the api-logging-iteration1 branch September 22, 2021 22:30
@github-actions github-actions bot locked and limited conversation to collaborators Oct 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants