keke


Namekeke JSON
Version 0.1.4 PyPI version JSON
download
home_pagehttps://github.com/keke-tracing/keke
SummaryEasy profiling in chrome trace format
upload_time2023-11-03 19:12:28
maintainer
docs_urlNone
authorTim Hatch
requires_python>=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # keke

This project is an extremely simple trace-event writer for Python.

You can read the traces in Perfetto or chrome's `about:tracing`.  This only
writes the consensus dialect that works in both, and is tiny enough to just
vendor on the off-chance that you want tracing in the future.

If your needs are more like a line profiler, you might want either pytracing
(slightly abandoned, the git version does work in py3) or viztracer (unsuitable
for vendoring in other projects due to size, but actively maintained).

I drew inspiration from both in writing this.

# Simple Example

```py
from __future__ import annotations  # for IO[str]

from typing import IO, Optional
import time

import click

@click.command()
@click.option("--trace", type=click.File(mode="w"), help="Trace output filename")
@click.option("--foo", help="This value gets logged")
def main(trace: Optional[IO[str]], foo: Optional[str]) -> None:
    with keke.TraceOutput(file=trace):
        with kev("main", __name__, foo=foo):
            sub()

def sub():
    with kev("sub1", __name__):
        time.sleep(1)
    with kev("sub2", __name__):
        time.sleep(2)
```
# Overhead

Very close to zero when not enabled.

The easiest way to not-enable is call `TraceOutput(file=None)` which will do nothing.

# Processes, or "how to get to distributed tracing"

This approach avoids all magic.

If you're calling another (trace-aware) program, then the simplest thing to do
is come up with a unique name and pass that to the child in argv, then attempt
to merge that yourself once it's done.

If you're doing something like fork/spawn to continue python work, then the
parent can control basic information (like the tmpdir to write to) and the child
can open a unique file with its pid.

If you're doing something more distributed, you might come up with a guid and
pass that to the child instead, for the child to tag it for later log uploading.

# What's with the name

I was trying to come up with a short, memorable name and some of the rendered
trace points were very pointy, which reminded me of the "bouba/kiki effect."
The name "kiki" was taken but "keke" was not.

# License

keke is copyright [Tim Hatch](https://timhatch.com/), and licensed under
the MIT license.  I am providing code in this repository to you under an open
source license.  This is my personal repository; the license you receive to
my code is from me and not from my employer. See the `LICENSE` file for details.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/keke-tracing/keke",
    "name": "keke",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "",
    "author": "Tim Hatch",
    "author_email": "tim@timhatch.com",
    "download_url": "https://files.pythonhosted.org/packages/7f/9a/3ccba0035eb9a92af133c896b18b32cc9195b5738bbc21dcbb58db056b41/keke-0.1.4.tar.gz",
    "platform": null,
    "description": "# keke\n\nThis project is an extremely simple trace-event writer for Python.\n\nYou can read the traces in Perfetto or chrome's `about:tracing`.  This only\nwrites the consensus dialect that works in both, and is tiny enough to just\nvendor on the off-chance that you want tracing in the future.\n\nIf your needs are more like a line profiler, you might want either pytracing\n(slightly abandoned, the git version does work in py3) or viztracer (unsuitable\nfor vendoring in other projects due to size, but actively maintained).\n\nI drew inspiration from both in writing this.\n\n# Simple Example\n\n```py\nfrom __future__ import annotations  # for IO[str]\n\nfrom typing import IO, Optional\nimport time\n\nimport click\n\n@click.command()\n@click.option(\"--trace\", type=click.File(mode=\"w\"), help=\"Trace output filename\")\n@click.option(\"--foo\", help=\"This value gets logged\")\ndef main(trace: Optional[IO[str]], foo: Optional[str]) -> None:\n    with keke.TraceOutput(file=trace):\n        with kev(\"main\", __name__, foo=foo):\n            sub()\n\ndef sub():\n    with kev(\"sub1\", __name__):\n        time.sleep(1)\n    with kev(\"sub2\", __name__):\n        time.sleep(2)\n```\n# Overhead\n\nVery close to zero when not enabled.\n\nThe easiest way to not-enable is call `TraceOutput(file=None)` which will do nothing.\n\n# Processes, or \"how to get to distributed tracing\"\n\nThis approach avoids all magic.\n\nIf you're calling another (trace-aware) program, then the simplest thing to do\nis come up with a unique name and pass that to the child in argv, then attempt\nto merge that yourself once it's done.\n\nIf you're doing something like fork/spawn to continue python work, then the\nparent can control basic information (like the tmpdir to write to) and the child\ncan open a unique file with its pid.\n\nIf you're doing something more distributed, you might come up with a guid and\npass that to the child instead, for the child to tag it for later log uploading.\n\n# What's with the name\n\nI was trying to come up with a short, memorable name and some of the rendered\ntrace points were very pointy, which reminded me of the \"bouba/kiki effect.\"\nThe name \"kiki\" was taken but \"keke\" was not.\n\n# License\n\nkeke is copyright [Tim Hatch](https://timhatch.com/), and licensed under\nthe MIT license.  I am providing code in this repository to you under an open\nsource license.  This is my personal repository; the license you receive to\nmy code is from me and not from my employer. See the `LICENSE` file for details.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Easy profiling in chrome trace format",
    "version": "0.1.4",
    "project_urls": {
        "Homepage": "https://github.com/keke-tracing/keke"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e3e90c70d5501b667988c4a340a2fc6006a58491a874f5aa1da56d0757e6336a",
                "md5": "644a53e9c000ef0bc6c831ee8b5b0513",
                "sha256": "b16eb1f8dd768747cf55e9e272a02fc642a4a80718ff4feccb5cdcdf9290af0a"
            },
            "downloads": -1,
            "filename": "keke-0.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "644a53e9c000ef0bc6c831ee8b5b0513",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 8000,
            "upload_time": "2023-11-03T19:12:26",
            "upload_time_iso_8601": "2023-11-03T19:12:26.587905Z",
            "url": "https://files.pythonhosted.org/packages/e3/e9/0c70d5501b667988c4a340a2fc6006a58491a874f5aa1da56d0757e6336a/keke-0.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7f9a3ccba0035eb9a92af133c896b18b32cc9195b5738bbc21dcbb58db056b41",
                "md5": "25c504220b1535bc84d6c8a9d4c70f54",
                "sha256": "a8653b7d9936ddae08d1ea2c298e5e36a50eb379705e3f74ab08b1f6ae3831a0"
            },
            "downloads": -1,
            "filename": "keke-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "25c504220b1535bc84d6c8a9d4c70f54",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 9558,
            "upload_time": "2023-11-03T19:12:28",
            "upload_time_iso_8601": "2023-11-03T19:12:28.161697Z",
            "url": "https://files.pythonhosted.org/packages/7f/9a/3ccba0035eb9a92af133c896b18b32cc9195b5738bbc21dcbb58db056b41/keke-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-03 19:12:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "keke-tracing",
    "github_project": "keke",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "keke"
}
        
Elapsed time: 0.16437s