{"id":15676971,"url":"https://github.com/sd2k/newrelic","last_synced_at":"2025-08-19T02:33:14.714Z","repository":{"id":38434544,"uuid":"187225610","full_name":"sd2k/newrelic","owner":"sd2k","description":"Rust wrapper around the New Relic C SDK","archived":false,"fork":false,"pushed_at":"2024-06-13T09:30:27.000Z","size":94,"stargazers_count":13,"open_issues_count":0,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-12-09T03:05:42.446Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/sd2k.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","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":"2019-05-17T13:57:19.000Z","updated_at":"2024-08-21T08:29:56.000Z","dependencies_parsed_at":"2024-10-23T13:03:21.887Z","dependency_job_id":null,"html_url":"https://github.com/sd2k/newrelic","commit_stats":{"total_commits":64,"total_committers":9,"mean_commits":7.111111111111111,"dds":0.671875,"last_synced_commit":"5c73eabcd6dfb114938b26f3409c48a7392862e3"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sd2k%2Fnewrelic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sd2k%2Fnewrelic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sd2k%2Fnewrelic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sd2k%2Fnewrelic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sd2k","download_url":"https://codeload.github.com/sd2k/newrelic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230004356,"owners_count":18158281,"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-10-03T16:07:48.945Z","updated_at":"2024-12-18T17:12:35.691Z","avatar_url":"https://github.com/sd2k.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"New Relic SDK\n=============\n\n[![docs.rs](https://docs.rs/newrelic/badge.svg)](https://docs.rs/newrelic)\n[![crates.io](https://img.shields.io/crates/v/newrelic.svg)](https://crates.io/crates/newrelic)\n\nAn idiomatic Rust wrapper around the New Relic C SDK.\n\nSee also the [rocket_newrelic] crate for example integration with the\nRocket web framework.\n\n---\n\nNote: versions 0.1.0 onwards of this crate are completely incompatible\nwith previous versions as they move away from the deprecated New Relic SDK\nto the newer New Relic C SDK. This has additional requirements: see\nhttps://docs.newrelic.com/docs/agents/c-sdk/get-started/introduction-c-sdk\nfor details.\n\nIn particular, the New Relic SDK will not link against musl - see the [newrelic-sys] crate for more details.\n\nSee https://github.com/hjr3/newrelic-rs for the \u003c0.1.0 repository.\n\nUsage\n-----\n\nAdd this crate to your `Cargo.toml`:\n\n```toml\n[dependencies]\nnewrelic = \"0.2\"\n```\n\nYou can then instrument your code as follows:\n\n```rust\nuse std::{env, thread, time::Duration};\n\nuse newrelic::{App, NewRelicConfig};\n\nfn main() {\n    let license_key =\n        env::var(\"NEW_RELIC_LICENSE_KEY\").unwrap_or_else(|_| \"example-license-key\".to_string());\n    let app = App::new(\"my app\", \u0026license_key).expect(\"Could not create app\");\n\n    // Start a web transaction and a segment\n    let _transaction = app\n        .web_transaction(\"Transaction name\")\n        .expect(\"Could not start transaction\");\n    thread::sleep(Duration::from_secs(1));\n\n    // Transaction ends automatically.\n\n    // App is destroyed automatically.\n}\n```\n\nSee the examples directory of the repository for more complex examples, including segments (custom, datastore and external) and further configuration.\n\nThis crate still requires the New Relic daemon to be running as per the [documentation for the New Relic C SDK][c-sdk]; be sure to read this first.\n\nFunctionality\n-------------\n\nThe core functionality from the C SDK is currently implemented. A few extra things are still TODO!\n\n* [ ] Transactions\n    * [x] Adding attributes\n    * [x] Noticing errors\n    * [x] Ignoring transactions\n    * [x] Renaming transactions\n    * [ ] Overriding timings\n* [x] Segments\n    * [x] Custom\n    * [x] Datastore\n    * [x] External\n    * [x] Nesting segments\n    * [ ] Overriding timings\n* [x] Custom events\n* [x] Custom metrics\n* [x] Async segments\n* [x] Distributed tracing\n* [x] Transaction tracing configuration\n* [x] Datastore segment tracing configuration\n* [x] Logging/daemon configuration\n\nFailures\n--------\n\nCurrently, creating a transaction using this library returns a `Result\u003cnewrelic::Transaction, newrelic::Error\u003e`, making it up to the user to either fail hard, or ignore, when transactions fail to be created.\n\nHowever, when working with Segments in the library, the failure of the segment is hidden from the user for ergonomic purposes. That is, in the following example, creation of the segment might fail (which will be logged using the `log` crate), but the argument passed to the custom segment closure is still of type `newrelic::Segment`. This makes it much simpler to work with nested segments.\n\nThis behaviour may be changed in future, if it proves to be unpopular.\n\n```rust\nuse newrelic::{App, NewRelicConfig};\n\nfn main() {\n    let app =\n        App::new(\"my app\", \"my license key\").expect(\"Could not create app\");\n    let transaction = app\n        .web_transaction(\"Transaction name\")\n        .expect(\"Could not start transaction\");\n    let expensive_value = transaction.custom_segment(\"Segment name\", \"Segment category\", |seg| {\n        do_something_expensive()\n    });\n}\n\n```\n\nAsync\n--------\n\nThe [`Segmented`] extension trait adds the ability to run a future inside of a segment.  The feature `async` is required.\n\nDistributed Tracing\n--------\n\n[Distributed tracing][nr-distributed-tracing] is available wiith the feature `distributed_tracing`.  Notably, this feature requires the [libc] crate.\n\n[c-sdk]: https://docs.newrelic.com/docs/agents/c-sdk/get-started/introduction-c-sdk#architecture\n[examples]: https://github.com/sd2k/newrelic/tree/master/examples\n[newrelic-sys]: https://crates.io/crates/newrelic-sys\n[libc]: https://crates.io/crates/libc\n[nr-distributed-tracing]: https://docs.newrelic.com/docs/understand-dependencies/distributed-tracing/get-started/introduction-distributed-tracing\n[`Segmented`]: src/futures.rs\n[rocket_newrelic]: https://crates.io/crates/rocket_newrelic\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsd2k%2Fnewrelic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsd2k%2Fnewrelic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsd2k%2Fnewrelic/lists"}