Integrate structlog with tenant_id and request_id context on every request #15
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
main.pyuseslogging.basicConfig()with a plain text format. Logs contain notenant_id,user_id, orrequest_id. Correlating a user-reported problem with a log entry is impossible.Required Actions
structlogtorequirements.txtrequest_id(UUID) per request and bindstenant_id,user_id,request_id,method,pathto the structlog context viastructlog.contextvars.bind_contextvars()logging.getLogger(__name__)calls withstructlog.get_logger()Acceptance Criteria
tenant_id,request_idLOG_FORMAT=json)grep tenant_idon any request log returns the correct tenant