{"id":19723528,"url":"https://github.com/remind101/newrelic","last_synced_at":"2025-04-29T22:31:00.103Z","repository":{"id":31740789,"uuid":"35306823","full_name":"remind101/newrelic","owner":"remind101","description":"DEPRECATED: Use the official lib here https://github.com/newrelic/go-agent","archived":false,"fork":false,"pushed_at":"2016-10-25T00:57:55.000Z","size":3216,"stargazers_count":19,"open_issues_count":1,"forks_count":9,"subscribers_count":78,"default_branch":"master","last_synced_at":"2023-08-11T23:38:33.566Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/remind101.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}},"created_at":"2015-05-08T23:29:48.000Z","updated_at":"2017-06-21T17:44:45.000Z","dependencies_parsed_at":"2022-08-29T14:01:00.316Z","dependency_job_id":null,"html_url":"https://github.com/remind101/newrelic","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remind101%2Fnewrelic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remind101%2Fnewrelic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remind101%2Fnewrelic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remind101%2Fnewrelic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/remind101","download_url":"https://codeload.github.com/remind101/newrelic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251592958,"owners_count":21614449,"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":[],"created_at":"2024-11-11T23:22:31.218Z","updated_at":"2025-04-29T22:30:59.795Z","avatar_url":"https://github.com/remind101.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## NewRelic Go Agent\n\nA small convenience layer that sits on top of [newrelic-go-agent](https://github.com/paulsmith/newrelic-go-agent), to make\nit easy to create transactions for NewRelic in Go.\n\n## Caveats\n\nThis is alpha software. It has not been tested in a production environment, or any environment for that matter.\n\n## Installing\n\nYou'll need to [install the nr_agent_sdk first](https://docs.newrelic.com/docs/agents/agent-sdk/installation-configuration/installing-agent-sdk).\n\nThis package will only work on linux platforms. It is also disabled by default. To enable it, use the build flag `newrelic_enabled`:\n\n```\ngo build -tags newrelic_enabled ./...\n```\n\n## Example Usage\n\nSee `./example/main.go` for a more complete example.\n\n``` go\nimport \"github.com/remind101/newrelic\"\n\nfunc main() {\n    newrelic.Init(\"newrelic app name\", \"newrelic license key\")\n    tx := newrelic.NewTx(\"/my/transaction/name\")\n    tx.Start()\n    defer tx.End()\n\n    // Add a segment\n    tx.StartGeneric(\"middleware\")\n    // Do some middleware stuff...\n    tx.EndSegment()\n}\n```\n\n## Using with an http server\n\nThis packages works well as an [httpx middleware](https://github.com/remind101/pkg/blob/master/httpx/middleware/newrelic_tracer.go).\n\nHere is an example using [httpx](https://github.com/remind101/pkg/tree/master/httpx), a context aware http handler.\n\n``` go\n    r := httpx.NewRouter()\n\n    r.Handle(\"/articles\", \u0026ArticlesHandler{}).Methods(\"GET\")\n    r.Handle(\"/articles/{id}\", \u0026ArticleHandler{}).Methods(\"GET\")\n\n    var h httpx.Handler\n\n    // Add NewRelic tracing.\n    h = middleware.NewRelicTracing(r, r, \u0026newrelic.NRTxTracer{})\n\n    // Wrap the route in middleware to add a context.Context.\n    h = middleware.BackgroundContext(h)\n\n    http.ListenAndServe(\":8080\", h)\n```\n\nThe above example will create web transactions named `GET \"/articles\"` and `GET \"/articles/{id}\"`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremind101%2Fnewrelic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fremind101%2Fnewrelic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremind101%2Fnewrelic/lists"}