Skip to content

Commit 6df6c75

Browse files
authored
Use orjson for log JSON serialization (#105)
Closes #102
1 parent 44a4439 commit 6df6c75

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

microbootstrap/instruments/logging_instrument.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import typing
66
import urllib.parse
77

8+
import orjson
89
import pydantic
910
import structlog
1011
import typing_extensions
@@ -81,7 +82,7 @@ def tracer_injection(_: WrappedLogger, __: str, event_dict: EventDict) -> EventD
8182
structlog.processors.format_exc_info,
8283
structlog.processors.UnicodeDecoder(),
8384
]
84-
DEFAULT_STRUCTLOG_FORMATTER_PROCESSOR: typing.Final = structlog.processors.JSONRenderer()
85+
DEFAULT_STRUCTLOG_FORMATTER_PROCESSOR: typing.Final = structlog.processors.JSONRenderer(serializer=orjson.dumps)
8586

8687

8788
class MemoryLoggerFactory(structlog.stdlib.LoggerFactory):

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ dependencies = [
5353
"opentelemetry-instrumentation-psycopg>=0.54b1",
5454
"opentelemetry-instrumentation-sqlalchemy>=0.54b1",
5555
"opentelemetry-instrumentation-asyncio>=0.54b1",
56+
"orjson>=3.10.18",
5657
]
5758
dynamic = ["version"]
5859
authors = [{ name = "community-of-python" }]

0 commit comments

Comments
 (0)