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

feat: Issue 166 json formatted logs #3376

Merged

Conversation

masmontanas
Copy link
Contributor

@masmontanas masmontanas commented Feb 4, 2024

Thanks for submitting a PR! Please check the boxes below:

  • I have run pre-commit to check linting
  • I have added information to docs/ if required so people know about the feature!
  • I have filled in the "Changes" section below?
  • I have filled in the "How did you test this code" section below?
  • I have used a Conventional Commit title for this Pull Request

Changes

Extending logging.Formatter with a custom class for json formatted messages. Unfortunately specifying json format as a string in the LOGGING dictionary presented a corner-case with the axes module (which returns a dictionary [with double-quoted values] with request information). Traditional string formatting tokens also had to be replaced with '{}' since the tokens were not being interpolated properly after the logging formatter was added.

How did you test this code?

  1. Build flagsmith:local container locally.
  2. Update docker-compose.yaml to use flagsmith:local container.
  3. Update environment variables in docker-compose file to include LOG_FORMAT: json
  4. Basic local testing through the UI to ensure logs were properly formatted.

Copy link

vercel bot commented Feb 4, 2024

Someone is attempting to deploy a commit to the Flagsmith Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

vercel bot commented Feb 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 13, 2024 5:32pm

@masmontanas masmontanas changed the title Issue 166 json formatted logs feat: Issue 166 json formatted logs Feb 4, 2024
Copy link
Contributor

github-actions bot commented Feb 5, 2024

Uffizzi Preview deployment-45852 was deleted.

Copy link
Contributor

@matthewelwell matthewelwell left a comment

Choose a reason for hiding this comment

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

Hi @masmontanas, thanks for this PR, it looks really good on the whole! I've added a few minor comments but I think we can get this merged very soon for sure.

@codecov-commenter
Copy link

codecov-commenter commented Feb 5, 2024

Codecov Report

Attention: Patch coverage is 95.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 95.91%. Comparing base (da21b8c) to head (d7a0746).
Report is 921 commits behind head on main.

Files with missing lines Patch % Lines
api/util/logging.py 81.81% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3376      +/-   ##
==========================================
- Coverage   95.93%   95.91%   -0.03%     
==========================================
  Files        1077     1083       +6     
  Lines       32950    33612     +662     
==========================================
+ Hits        31612    32240     +628     
- Misses       1338     1372      +34     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@masmontanas
Copy link
Contributor Author

Hi @matthewelwell , required updates are ready for review. Thank you.

@masmontanas
Copy link
Contributor Author

Hi @matthewelwell , I saw that e2e tests failed but doesn't seem to be related -- anything needed from my end?

Copy link
Member

@khvn26 khvn26 left a comment

Choose a reason for hiding this comment

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

I'm approving this, but we need to be conscious that, from observability perspective, it isn't a great solution.

We need to evaluate integrating something like https://django-structlog.readthedocs.io/en/latest/ so Flagsmith provides truly insightful structured logs in the future.

@matthewelwell
Copy link
Contributor

@masmontanas I've approved, but it looks like you have some legit test failures to resolve.

@masmontanas
Copy link
Contributor Author

Fixed unit test issue.

@matthewelwell
Copy link
Contributor

thanks again @masmontanas !

Merged via the queue into Flagsmith:main with commit c666d29 Feb 14, 2024
20 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issue related to the REST API docs Documentation updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants