v4.5.1
Thisupdate refactors the logging system to improve compatibility with Datadog by injecting trace and span IDs directly into log records and updating the JSON log format. It introduces a dedicated filter for Datadog trace injection, modernizes the JSON formatter to surface Datadog correlation fields at the top level, and updates the logger to automatically attach the new filter when Datadog tracing is enabled. Tests are updated to validate the new structure.
Datadog Trace Injection & Logging Integration
- Added a new
DatadogTraceInjectionFilterinWrenchCL/_Internal/Logging/DatadogTraceInjectionFilter.pythat injectsdd.trace_idanddd.span_idfields into every log record, using the Datadog tracer if available. - Updated
cLogger.pyto automatically attach theDatadogTraceInjectionFilterto all handlers when Datadog tracing is enabled, ensuring trace/span IDs are present in logs.
JSON Log Formatter Modernization
- Refactored
JSONLogFormatterinFormatters.pyto surfaceservice,env,version,dd.trace_id, anddd.span_idas top-level fields in the JSON output, making logs Datadog-friendly and preserving existing context/exception structure. - Improved context extraction logic in the formatter for more robust harvesting of user, organization, and service identifiers from context variables.
Testing Updates
- Modified tests in
test_logger_json_mode.pyto assert the presence of top-level Datadog correlation fields (service,version,env,dd.trace_id,dd.span_id) instead of the previous nested structure.