Skip to main content

Write sparkline graphs of CPU and memory usage to your logs.

Project description

sparkle_log

Write a spark line graph of CPU, Memory, etc to the python log

Install

pip install sparkle_log

Usage

This will write up to 15 log entries to your AWS Lambda log, one per minute. Very light-weight, cheap, immediately correlates to your other print statements and log entries.

If logging is less than INFO, then no data is collected.

As a decorator

import sparkle_log
import logging

logging.basicConfig(level=logging.INFO)


@sparkle_log.monitor_metrics_on_call(("cpu", "memory"), 60)
def handler_name(event, context) -> str:
    return "Hello world!"

As a context manager:

import time
import sparkle_log
import logging

logging.basicConfig(level=logging.INFO)


def handler_name(event, context) -> str:
    with sparkle_log.MetricsLoggingContext(metrics=("cpu", "memory"), interval=5):
        time.sleep(20)
        return "Hello world!"

Prior art

You could also use container insights or htop. This tool should provide the most value when the server is headless and you only have logging or no easy way to correlate log entries to graphs.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sparkle_log-0.1.0.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

sparkle_log-0.1.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file sparkle_log-0.1.0.tar.gz.

File metadata

  • Download URL: sparkle_log-0.1.0.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for sparkle_log-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3e4778ee7d9ab5e6ae53477634f17c2d90cf42450ff50b0d1e3b6f24d5ea9cf5
MD5 74e1cbf17d00c67a64ca1c9ef8d61896
BLAKE2b-256 bc210f164ba0337d6415b97455d2a0f12bba98f0931417b2a0d2d03d47d1ab77

See more details on using hashes here.

File details

Details for the file sparkle_log-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: sparkle_log-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for sparkle_log-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e03925ae2ace9a5cbe8e4f675d588435feca2e950cf9996d70786bd3f172f7e3
MD5 fc868f4db9c515bd47073a511e9319cd
BLAKE2b-256 43c5e4270b7f7ef1152d0432e30f3e3d2d8b6d29c6dbeb9d70e77d8f1199cf3c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page