{"id":20015636,"url":"https://github.com/jen20/go-usdt","last_synced_at":"2025-05-04T22:31:35.171Z","repository":{"id":144212997,"uuid":"89723911","full_name":"jen20/go-usdt","owner":"jen20","description":"DTrace User-Defined Static Tracing Probes for applications written in Go","archived":false,"fork":false,"pushed_at":"2017-04-28T16:37:30.000Z","size":13,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-08T12:51:48.744Z","etag":null,"topics":["dtrace","go","usdt"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jen20.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":"2017-04-28T16:21:42.000Z","updated_at":"2023-05-09T16:17:06.000Z","dependencies_parsed_at":"2024-05-05T17:48:02.880Z","dependency_job_id":null,"html_url":"https://github.com/jen20/go-usdt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jen20%2Fgo-usdt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jen20%2Fgo-usdt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jen20%2Fgo-usdt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jen20%2Fgo-usdt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jen20","download_url":"https://codeload.github.com/jen20/go-usdt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252408265,"owners_count":21743083,"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":["dtrace","go","usdt"],"created_at":"2024-11-13T07:46:45.333Z","updated_at":"2025-05-04T22:31:35.152Z","avatar_url":"https://github.com/jen20.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-usdt - USDT Probes for Go\n\nThis library allows dynamic creation of DTrace USDT probes from Go programs.\nThe current implementation depends on cgo, and has been tested only on Illumos\n(specifically SmartOS) and Mac OS X Sierra.\n\n## Installation\n\n```\ngo get -u github.com/jen20/go-usdt\n```\n\n## Usage Example\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"reflect\"\n\t\"time\"\n\n\t\"github.com/jen20/go-usdt\"\n)\n\nfunc main() {\n\tprovider, err := usdt.NewProvider(\"examplep\", \"examplem\")\n\tif err != nil {\n\t\tlog.Fatalf(\"NewProvider: %s\", err)\n\t}\n\tdefer provider.Close()\n\n\tprobe, err := usdt.NewProbe(\"examplef\", \"examplen\", reflect.String, reflect.Int)\n\tif err != nil {\n\t\tlog.Fatalf(\"NewProbe: %s\", err)\n\t}\n\n\terr = provider.AddProbe(probe)\n\tif err != nil {\n\t\tlog.Fatalf(\"AddProbe: %s\", err)\n\t}\n\n\terr = provider.Enable()\n\tif err != nil {\n\t\tlog.Fatalf(\"Enable: %s\", err)\n\t}\n\n\tfor i := 0; ; i++ {\n\t\tif i%2 == 0 {\n\t\t\tprobe.Fire(\"string argument\", 42)\n\t\t} else {\n\t\t\tprobe.Fire(\"different argument\", 21)\n\t\t}\n\t\ttime.Sleep(1 * time.Second)\n\t}\n}\n```\n\nCompile the binary using `go build`, then run it. Probe output can be accessed\nusing the following DTrace command:\n\n```\ndtrace -Z \\\n    -n 'examplep$target::: { trace(arg1); trace(copyinstr(arg0)) }' \\\n    -c ./go-usdt-test\n```\n\nThe `-Z` option permits starting DTrace despite the probes being matched not\nyet existing. `go-usdt-test` is the name of the compiled binary. Use of `sudo`\nis required on OS X, and the DTrace SIP capability must be configured to allow\nuse of DTrace.\n\n## TODO\n\nThe library is usable in this form if you are targeting only OS X and SmartOS,\nand find cgo acceptable. However, future work should broaden the appeal:\n\n- Work out a story for compilation on systems which do not support DTrace which\n  has minimal cost in terms of both invasiveness and overhead.\n- Investigate static generation (using `go generate`) of probe definitions and\n  functions which do not require interface arguments.\n- Complete a native Go implementation which does not require use of cgo.\n\n## Credits\n\n- The Go API is based on an older project: [github.com/ecin/go-dtrace](github.com/ecin/go-dtrace)\n\n- The implementation is based on\n  [github.com/chrisa/libusdt][github.com/chrisa/libusdt], by Chris Andrews,\n  which is compiled statically into the compiled Go binary. The license for\n  libusdt is included in the file `LICENSE.libusdt`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjen20%2Fgo-usdt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjen20%2Fgo-usdt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjen20%2Fgo-usdt/lists"}