{"id":23395961,"url":"https://github.com/matthewdeanmartin/sparkle_log","last_synced_at":"2026-02-04T00:03:15.459Z","repository":{"id":235635103,"uuid":"790825643","full_name":"matthewdeanmartin/sparkle_log","owner":"matthewdeanmartin","description":"Write a spark line graph of CPU, Memory, etc to the python log","archived":false,"fork":false,"pushed_at":"2026-01-13T23:49:14.000Z","size":645,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-14T01:32:28.310Z","etag":null,"topics":["cpu","data-visualization","logging","memory","performance-monitoring","python","sparkline"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matthewdeanmartin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-04-23T15:45:12.000Z","updated_at":"2026-01-13T23:49:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"0693f026-29e4-40ff-9af4-48f0dd55060d","html_url":"https://github.com/matthewdeanmartin/sparkle_log","commit_stats":null,"previous_names":["matthewdeanmartin/sparkle_log"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/matthewdeanmartin/sparkle_log","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewdeanmartin%2Fsparkle_log","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewdeanmartin%2Fsparkle_log/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewdeanmartin%2Fsparkle_log/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewdeanmartin%2Fsparkle_log/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matthewdeanmartin","download_url":"https://codeload.github.com/matthewdeanmartin/sparkle_log/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewdeanmartin%2Fsparkle_log/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29062484,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-03T23:14:54.203Z","status":"ssl_error","status_checked_at":"2026-02-03T23:14:50.873Z","response_time":96,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpu","data-visualization","logging","memory","performance-monitoring","python","sparkline"],"created_at":"2024-12-22T07:19:45.578Z","updated_at":"2026-02-04T00:03:15.445Z","avatar_url":"https://github.com/matthewdeanmartin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sparkle_log\n\nWrite a spark line graph of CPU, Memory, etc to the python log\n\n```text\n❯ sparkle_log\nDemo of Sparkle Monitoring system metrics during operations...\nINFO     CPU   :   % |                              ▄ | min, mean, max (4, 4, 4)\nINFO     Memory:   % |                              ▄ | min, mean, max (46, 46, 46)\nMaybe CPU intensive work done here...\nINFO     CPU   :   % |                           ▆▁█▄ | min, mean, max (1, 3.2, 5)\nINFO     Memory:   % |                           ▄▄▄▄ | min, mean, max (46, 46, 46)\nMaybe Memory intensive work done here...\nINFO     Memory:   % |                         ▄▄▄▄▄▄ | min, mean, max (46, 46, 46)\nINFO     CPU   :   % |                        ▆▁█▄▃▃▁ | min, mean, max (1, 2.6, 5)\nINFO     Memory:   % |                        ▄▄▄▄▄▄▄ | min, mean, max (46, 46, 46)\n```\n\nTracking just one metric at a time looks better.\n\n```text\nINFO     Memory:   % |                              ▄ | min, mean, max (46, 46, 46)\nINFO     Memory:   % |                           ▄▄▄▄ | min, mean, max (46, 46, 46)\nINFO     Memory:   % |                         ▄▄▄▄▄▄ | min, mean, max (46, 46, 46)\nINFO     Memory:   % |                        ▄▄▄▄▄▄▄ | min, mean, max (46, 46, 46)\n```\n\n## Install\n\n`pip install sparkle_log`\n\n## Usage\n\nThis will write up to log entries to your AWS Lambda log, at a frequency you specify, e.g. every 60 seconds.\nLight-weight, cheap, immediately correlates to your other print statements and log entries.\n\nIf logging is less than INFO, then no data is collected.\n\nAs a decorator\n\n```python\nimport sparkle_log\nimport logging\n\nlogging.basicConfig(level=logging.INFO)\n\n\n@sparkle_log.monitor_metrics_on_call((\"cpu\", \"memory\" \"drive\"), 60)\ndef handler_name(event, context) -\u003e str:\n    return \"Hello world!\"\n```\n\nAs a context manager:\n\n```python\nimport time\nimport sparkle_log\nimport logging\n\nlogging.basicConfig(level=logging.INFO)\n\n\ndef handler_name(event, context) -\u003e str:\n    with sparkle_log.MetricsLoggingContext(\n        metrics=(\"cpu\", \"memory\", \"drive\"), interval=5\n    ):\n        time.sleep(20)\n        return \"Hello world!\"\n```\n\n```python\nimport time\nimport logging\nimport random\nfrom sparkle_log import MetricsLoggingContext\n\nlogging.basicConfig(level=logging.INFO)\n\n\ndef dodgy_metric() -\u003e int:\n    return random.randint(0, 100)\n\n\nwith MetricsLoggingContext(\n    metrics=(\"dodgy\",), interval=1, custom_metrics={\"dodgy\": dodgy_metric}\n):\n    print(\"Monitoring system metrics during operations...\")\n    time.sleep(20)\n```\n\n## Supported Styles\n\nGraph styles currently are all autoscaled. Linear, faces, vertical have only 3 levels. Bar has 8 levels.\n\n```python\nfrom typing import cast\nfrom sparkle_log import sparkline, GraphStyle\n\nfor style in [\"bar\", \"jagged\", \"vertical\", \"linear\", \"ascii_art\", \"pie_chart\", \"faces\"]:\n    print(\n        f\"{style}: {sparkline([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], cast(GraphStyle, style))}\"\n    )\n```\n\nResults:\n\n```text\nbar: ▁▂▃▃▄▅▆▆▇█\njagged: ___--^^¯¯¯\nvertical: ___|||‖‖‖‖\nlinear: ___---¯¯¯¯\nascii_art:  .:-=+*#%@\npie_chart: ○○◔◔◑◑◕◕●●\nfaces: 😞😞😞😐😐😊😊😁😁😁\n```\n\n## Prior art\n\nYou could also use container insights or htop. This tool should provide the most value when the server is headless and\nyou only have logging or no easy way to correlate log entries to graphs.\n\n### Diagnostics as sparklines\n\n- [memsparkline](https://pypi.org/project/memsparkline/) - CLI tool to show memory as sparkline.\n- [densli](https://pypi.org/project/densli/)  (defunct?) server stats tool with terminal sparkline display\n- [sparcli](https://pypi.org/project/sparcli/) Context manager for displaying arbitrary metrics as sparklines\n\n### Sparkline functions\n\n- [py-sparkblocks](https://pypi.org/project/py-sparkblocks/) function to create sparkline graph\n- [sparklines](https://pypi.org/project/sparklines/) function to create sparkline graph\n- [rich-sparklines](https://pypi.org/project/rich-sparklines/) function that works with rich UI library\n- [yasl](https://pypi.org/project/yasl/) Yet Another Sparkline Library\n- [Piltdown](https://pypi.org/project/Piltdown) Variety of ASCII/Unicode graphs including sparklines.\n- [termgraph](https://pypi.org/project/termgraph/) - Various terminal graphs not including sparklines, but including bar\n  graphs.\n- [lehar](https://pypi.org/project/lehar/) - Another sparkline function\n\n### CLI tools that display sparklines from arbitrary numbers\n\n- [sparkl](https://pypi.org/project/sparkl/)\n- [sparkback](https://github.com/mmichie/sparkback)\n- [spark](http://github.com/holman/spark) Pure bash implementation that seems to have inspired many clones.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthewdeanmartin%2Fsparkle_log","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatthewdeanmartin%2Fsparkle_log","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthewdeanmartin%2Fsparkle_log/lists"}