Monitor custom metrics in Python with our lightweight library.
Custom metrics allow you to track specific aspects of your application, such as performance or user behavior. Watchlog's Python library makes this effortless with just a few lines of code.
Use the watchlog-python
library to send custom metrics. Install the package and use methods like increment
, decrement
, gauge
, percentage
, or systembyte
to monitor your app.
from watchlog import Watchlog
watchlog_instance = Watchlog()
# Increment the specified metric by the given value (default is 1)
watchlog_instance.increment('page_views', 10)
# Decrement the specified metric by the given value (default is 1)
watchlog_instance.decrement('items_in_cart', 2)
# Set the specified metric to the given value
watchlog_instance.gauge('current_temperature', 22.5)
# Set the specified metric to a percentage value (0 to 100)
watchlog_instance.percentage('completion_rate', 85)
# Log a system byte metric
watchlog_instance.systembyte('memory_usage', 1024) # Example: 1024 bytes
To begin, install the library with pip install watchlog-python
and integrate it using the examples above. Refer to our documentation for detailed setup instructions.