{"id":21228790,"url":"https://github.com/hypertrace/goagent","last_synced_at":"2025-06-17T00:36:26.055Z","repository":{"id":38187812,"uuid":"288345033","full_name":"hypertrace/goagent","owner":"hypertrace","description":"Hypertrace Go Agent","archived":false,"fork":false,"pushed_at":"2025-06-02T17:46:14.000Z","size":1026,"stargazers_count":9,"open_issues_count":5,"forks_count":8,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-06T23:58:05.905Z","etag":null,"topics":["distributed-tracing","go","hacktoberfest","hypertrace","instrumentation"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hypertrace.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":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-08-18T03:28:00.000Z","updated_at":"2025-05-01T18:11:43.000Z","dependencies_parsed_at":"2024-10-24T01:48:28.630Z","dependency_job_id":"090cb0d9-ef0c-48c4-8c7b-ba9acb0fe999","html_url":"https://github.com/hypertrace/goagent","commit_stats":{"total_commits":251,"total_committers":21,"mean_commits":"11.952380952380953","dds":0.5617529880478087,"last_synced_commit":"3224ad8c2d07902a1b5bdf198049ef2cee740288"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"purl":"pkg:github/hypertrace/goagent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypertrace%2Fgoagent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypertrace%2Fgoagent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypertrace%2Fgoagent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypertrace%2Fgoagent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hypertrace","download_url":"https://codeload.github.com/hypertrace/goagent/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypertrace%2Fgoagent/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260268632,"owners_count":22983601,"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":["distributed-tracing","go","hacktoberfest","hypertrace","instrumentation"],"created_at":"2024-11-20T23:21:56.685Z","updated_at":"2025-06-17T00:36:26.025Z","avatar_url":"https://github.com/hypertrace.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go Agent\n\n![test](https://github.com/hypertrace/goagent/workflows/test/badge.svg)\n[![codecov](https://codecov.io/gh/hypertrace/goagent/branch/master/graph/badge.svg)](https://codecov.io/gh/hypertrace/goagent)\n\n`goagent` provides a set of complementary instrumentation features for collecting relevant data to be processed by [Hypertrace](https://hypertrace.org).\n\n## Getting started\n\nSetting up Go Agent can be done with a few lines:\n\n```go\nimport \"github.com/hypertrace/goagent/config\"\n\n...\n\nfunc main() {\n    cfg := config.Load()\n    cfg.ServiceName = config.String(\"myservice\")\n\n    shutdown := hypertrace.Init(cfg)\n    defer shutdown\n}\n```\n\nConfig values can be declared in config file, env variables or code. For further information about config check [this section](config/README.md).\n\n## Package net/hyperhttp\n\n### HTTP server\n\nThe server instrumentation relies on the `http.Handler` component of the server declarations.\n\n```go\nimport (\n    \"net/http\"\n\n    \"github.com/gorilla/mux\"\n    \"github.com/hypertrace/goagent/instrumentation/hypertrace/net/hyperhttp\"\n)\n\nfunc main() {\n    // ...\n\n    r := mux.NewRouter()\n    r.Handle(\"/foo/{bar}\", hyperhttp.NewHandler(\n        fooHandler,\n        \"/foo/{bar}\",\n    ))\n\n    // ...\n}\n```\n\n#### Options\n\n##### Filter\n[Filtering](sdk/filter/README.md) can be added as part of options. Multiple filters can be added and they will be run in sequence until a filter returns true (request is blocked), or all filters are run.\n\n```go\n\n// ...\n\n    r.Handle(\"/foo/{bar}\", hyperhttp.NewHandler(\n        fooHandler,\n        \"/foo/{bar}\",\n        hyperhttp.WithFilter(filter.NewMultiFilter(filter1, filter2)),\n    ))\n\n// ...\n\n````\n\n### HTTP client\n\nThe client instrumentation relies on the `http.Transport` component of the HTTP client in Go.\n\n```go\nimport (\n    \"net/http\"\n    \"github.com/hypertrace/goagent/instrumentation/hypertrace/net/hyperhttp\"\n)\n\n// ...\n\nclient := http.Client{\n    Transport: hyperhttp.NewTransport(\n        http.DefaultTransport,\n    ),\n}\n\nreq, _ := http.NewRequest(\"GET\", \"http://example.com\", nil)\n\nres, err := client.Do(req)\n\n// ...\n```\n\n### Running HTTP examples\n\nIn terminal 1 run the client:\n\n```bash\ngo run ./examples/http-client/main.go\n```\n\nIn terminal 2 run the server:\n\n```bash\ngo run ./examples/http-server/main.go\n```\n\n\n## Gin-Gonic Server\n\nGin server instrumentation relies on adding the `hypergin.Middleware` middleware to the gin server. \n```go\nr := gin.Default()\n\ncfg := config.Load()\ncfg.ServiceName = config.String(\"http-gin-server\")\n\nflusher := hypertrace.Init(cfg)\ndefer flusher()\n\nr.Use(hypergin.Middleware())\n```\n\nTo run an example gin server with the hypertrace middleware: \n```bash\ngo run ./examples/gin-server/main.go\n```\n\nThen make a request to `localhost:8080/ping`\n\n## Package google.golang.org/hypergrpc\n\n### GRPC server\n\nThe server instrumentation relies on the `grpc.UnaryServerInterceptor` component of the server declarations.\n\n```go\n\nserver := grpc.NewServer(\n    grpc.UnaryInterceptor(\n        hypergrpc.UnaryServerInterceptor(),\n    ),\n)\n```\n\n#### Options\n\n##### Filter\n[Filtering](sdk/filter/README.md) can be added as part of options. Multiple filters can be added and they will be run in sequence until a filter returns true (request is blocked), or all filters are run.\n\n```go\n\n// ...\n\n    grpc.UnaryInterceptor(\n        hypergrpc.UnaryServerInterceptor(\n            hypergrpc.WithFilter(filter.NewMultiFilter(filter1, filter2))\n        ),\n    ),\n\n// ...\n\n````\n\n### GRPC client\n\nThe client instrumentation relies on the `http.Transport` component of the HTTP client in Go.\n\n```go\nimport (\n    // ...\n\n    hypergrpc \"github.com/hypertrace/goagent/instrumentation/hypertrace/google.golang.org/hypergrpc\"\n    \"google.golang.org/grpc\"\n)\n\nfunc main() {\n    // ...\n    conn, err := grpc.Dial(\n        address,\n        grpc.WithInsecure(),\n        grpc.WithBlock(),\n        grpc.WithUnaryInterceptor(\n            hypergrpc.UnaryClientInterceptor(),\n        ),\n    )\n    if err != nil {\n        log.Fatalf(\"could not dial: %v\", err)\n    }\n    defer conn.Close()\n\n    client := pb.NewCustomClient(conn)\n\n    // ...\n}\n```\n\n### Running GRPC examples\n\nIn terminal 1 run the client:\n\n```bash\ngo run ./examples/grpc-client/main.go\n```\n\nIn terminal 2 run the server:\n\n```bash\ngo run ./examples/grpc-server/main.go\n```\n\n## Other instrumentations\n\n- [database/hypersql](instrumentation/hypertrace/database/hypersql)\n- [github.com/gorilla/hypermux](instrumentation/hypertrace/github.com/gorilla/hypermux)\n\n## Contributing\n\n### Running tests\n\nTests can be run with (requires docker)\n\n```bash\nmake test\n```\n\nfor unit tests only\n\n```bash\nmake test-unit\n```\n\n### Releasing\n\nRun `./release.sh \u003cversion_number\u003e` (`\u003cversion_number\u003e` should follow semver, e.g. `1.2.3`). The script will change the hardcoded version, commit it, push a tag and prepare the hardcoded version for the next release. After that go to the releases page and draft a new release based on the new tag.\n\n### Further Reference\n\nRead more about `goagent` in the 'Yet Another [Go Agent](https://blog.hypertrace.org/blog/yet-another-go-agent/)' blog post. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhypertrace%2Fgoagent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhypertrace%2Fgoagent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhypertrace%2Fgoagent/lists"}