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

HH-199730 try use orjson for log dumps #663

Merged
merged 2 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions frontik/loggers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from logging.handlers import SysLogHandler
from typing import TYPE_CHECKING

import orjson
from tornado.log import LogFormatter

from frontik import request_context
Expand Down Expand Up @@ -90,6 +91,8 @@ def format(self, record):
if stack_trace:
json_message['exception'] = stack_trace

if options.log_use_orjson:
return orjson.dumps(json_message).decode("utf-8")
return json.dumps(json_message)

@staticmethod
Expand Down
1 change: 1 addition & 0 deletions frontik/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Options:

log_dir: str | None = None
log_level: str = 'info'
log_use_orjson: bool = True
Copy link
Contributor Author

Choose a reason for hiding this comment

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

типа чтобы не повторить ошибку и если че легко выключить

update_log_level_interval_in_seconds: int = 300
log_json: bool = True
log_text_format: str = '[%(process)s] %(asctime)s %(levelname)s %(name)s: %(message)s'
Expand Down
63 changes: 61 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jinja2 = '3.1.2'
lxml = '4.9.2'
pydantic = '^2.3.0'
tornado = '6.3.2'
orjson = '*'
http-client = {git = 'https://github.com/hhru/balancing-http-client.git', tag = '2.1.4'}
python-consul2-hh = {git = 'https://github.com/hhru/python-consul2', tag = 'v0.2.9'}
opentelemetry-sdk = '1.17.0'
Expand Down