jcrist commented on code in PR #45962:
URL: https://github.com/apache/airflow/pull/45962#discussion_r1928013996


##########
task_sdk/src/airflow/sdk/log.py:
##########
@@ -196,13 +196,11 @@ def logging_processors(
         else:
             exc_group_processor = None
 
-        encoder = msgspec.json.Encoder()
-
         def json_dumps(msg, default):
-            return encoder.encode(msg)
+            return orjson.dumps(msg, default=default)

Review Comment:
   Hi :wave:, `msgspec` author here. I found this issue due to [an automated 
email digest](https://github.com/jcrist/automations) I setup to see issues 
people are running into using `msgspec` in the wild.
   
   If this was the only usage y'all had of `msgspec`, no sense in keeping it 
around if you're also using `orjson`. Just wanted to clarify that this
   
   > This PR makes a very targeted change to swap out the msgspec encoder with 
the orjson library, which is also very fast but is a closer drop-in to Python's 
json library.
   
   isn't really an accurate portrayal of the issue. For serialization, 
`msgspec` and `orjson` have almost identical behavior; the issue here was you 
weren't plumbing the `default` argument through to msgspec before, but you are 
now to `orjson`. An equivalent fix using `msgspec` would be
   
   ```python
               return msgspec.json.encode(msg, enc_hook=default)
   ```
   
   The default hook used in `structlog` calls `repr` on unsupported types,  
which is why you're seeing pydantic classes handled once you plumbed that 
through.
   
   Again, no pressure to keep using `msgspec`, just trying to clear up an 
inaccuracy.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to