Skip to content

Instantly share code, notes, and snippets.

@mariocj89
mariocj89 / python-logging.md
Last active April 13, 2024 13:15
Understanding logging in Python

Logging trees

Introduction

When applications are running in production, they become black boxes that need to be traced and monitored. One of the simplest, yet main, ways to do so is logging. Logging allows us - at the time we develop our software - to instruct the program to emit information while the system is running that will be useful for us and our sysadmins.

@chmarr
chmarr / blocked.sql
Created November 5, 2015 18:30
PostgreSQL query to display blocked and blocking queries. Updated from PG Wiki.
SELECT blocked_locks.pid AS blocked_pid,
blocked_activity.usename AS blocked_user,
now() - blocked_activity.query_start
AS blocked_duration,
blocking_locks.pid AS blocking_pid,
blocking_activity.usename AS blocking_user,
now() - blocking_activity.query_start
AS blocking_duration,
blocked_activity.query AS blocked_statement,
blocking_activity.query AS blocking_statement