{"id":16984747,"url":"https://github.com/nektro/zig-tracer","last_synced_at":"2025-03-22T15:30:44.698Z","repository":{"id":196145234,"uuid":"694390802","full_name":"nektro/zig-tracer","owner":"nektro","description":"Generic tracing library for Zig, supports multiple backends.","archived":false,"fork":false,"pushed_at":"2025-02-16T06:11:37.000Z","size":30,"stargazers_count":20,"open_issues_count":4,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T12:50:42.632Z","etag":null,"topics":["zig","zig-package"],"latest_commit_sha":null,"homepage":"","language":"Zig","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/nektro.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-20T23:00:09.000Z","updated_at":"2025-03-04T21:29:16.000Z","dependencies_parsed_at":"2024-04-11T11:31:25.180Z","dependency_job_id":"4faedbae-fb37-4a0d-b6ca-5f86c78a49df","html_url":"https://github.com/nektro/zig-tracer","commit_stats":null,"previous_names":["nektro/zig-tracer"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nektro%2Fzig-tracer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nektro%2Fzig-tracer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nektro%2Fzig-tracer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nektro%2Fzig-tracer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nektro","download_url":"https://codeload.github.com/nektro/zig-tracer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244978406,"owners_count":20541850,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["zig","zig-package"],"created_at":"2024-10-14T02:34:04.867Z","updated_at":"2025-03-22T15:30:44.118Z","avatar_url":"https://github.com/nektro.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zig-tracer\n\nGeneric tracing library for Zig, supports multiple backends.\n\n## Install\n\n- Supports Zigmod\n- Supports Zig package manager\n\n## Usage\n\nin your program:\n\n```zig\nconst std = @import(\"std\");\nconst tracer = @import(\"tracer\");\npub const build_options = @import(\"build_options\");\n\npub const tracer_impl = tracer.spall; // see 'Backends' section below\n\npub fn main() !void {\n    try tracer.init();\n    defer tracer.deinit();\n\n    // main loop\n    while (true) {\n        try tracer.init_thread();\n        defer tracer.deinit_thread();\n\n        handler();\n    }\n}\n\nfn handler() void {\n    const t = tracer.trace(@src());\n    defer t.end();\n}\n```\n\n`@src()` values are sometimes absolute paths so backends may use this value to trim it to only log relative paths\n\n```zig\nexe_options.addOption(usize, \"src_file_trimlen\", std.fs.path.dirname(std.fs.path.dirname(@src().file).?).?.len);\n```\n\n## Backends\n\n- `none` this is the default and causes tracing calls to become a no-op so that `tracer` can be added to libraries transparently\n- `log` uses `std.log` to print on function entrance.\n- `chrome` writes a json file in the `chrome://tracing` format described [here](https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview) and [here](https://www.chromium.org/developers/how-tos/trace-event-profiling-tool/).\n- `spall` writes a binary file compatible with the [Spall](https://gravitymoth.com/spall/) profiler.\n- more? feel free to open an issue with requests!\n\nAny custom backend may also be used that defines the following functions:\n\n- `pub fn init() !void`\n- `pub fn deinit() void`\n- `pub fn init_thread(dir: std.fs.Dir) !void`\n- `pub fn deinit_thread() void`\n- `pub inline fn trace_begin(ctx: tracer.Ctx, comptime ifmt: []const u8, iargs: anytype) void`\n- `pub inline fn trace_end(ctx: tracer.Ctx) void`\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnektro%2Fzig-tracer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnektro%2Fzig-tracer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnektro%2Fzig-tracer/lists"}