Closed
Description
From AsyncBoundLogger
's docstring (FYI, the warning is not rendered on the API reference page):
.. warning: Since the processor pipeline runs in a separate thread,
`structlog.contextvars.merge_contextvars` does **nothing** and should
be removed from you processor chain.
Following the aforementioned warning, if I remove structlog.contextvars.merge_contextvars
from my processor chain, none of the context variables (added using structlog.contextvars.bind_contextvars
) are displayed in the log records. Only if I add it to the processor chain, context variables are displayed. Am I doing something wrong?
My structlog
related code:
shared_processors: List[structlog.types.Processor] = [
structlog.stdlib.add_logger_name,
structlog.stdlib.add_log_level,
add_request_id, # Custom processor to add request ID to `event_dict` using `starlette_context`
structlog.processors.TimeStamper(fmt="iso", utc=True),
structlog.processors.StackInfoRenderer(),
structlog.processors.format_exc_info,
]
structlog.configure(
processors=[
# structlog.contextvars.merge_contextvars,
structlog.stdlib.filter_by_level,
*shared_processors,
structlog.stdlib.PositionalArgumentsFormatter(),
structlog.stdlib.ProcessorFormatter.wrap_for_formatter,
],
context_class=dict,
logger_factory=structlog.stdlib.LoggerFactory(),
wrapper_class=structlog.stdlib.AsyncBoundLogger,
cache_logger_on_first_use=True,
)
Python version: 3.9.6
structlog
version: 21.1.0
If any more info is required from my end, let me know, I'll provide it.
Metadata
Metadata
Assignees
Labels
No labels