Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
New Relic SDK
An idiomatic Rust wrapper around the New Relic C SDK.
See also the [rocket_newrelic] crate for example integration with the Rocket web framework.
Note: versions 0.1.0 onwards of this crate are completely incompatible with previous versions as they move away from the deprecated New Relic SDK to the newer New Relic C SDK. This has additional requirements: see https://docs.newrelic.com/docs/agents/c-sdk/get-started/introduction-c-sdk for details.
In particular, the New Relic SDK will not link against musl - see the newrelic-sys crate for more details.
See https://github.com/hjr3/newrelic-rs for the <0.1.0 repository.
Usage
Add this crate to your Cargo.toml
:
[]
= "0.2"
You can then instrument your code as follows:
use ;
use ;
See the examples directory of the repository for more complex examples, including segments (custom, datastore and external) and further configuration.
This crate still requires the New Relic daemon to be running as per the documentation for the New Relic C SDK; be sure to read this first.
Functionality
The core functionality from the C SDK is currently implemented. A few extra things are still TODO!
- Transactions
- Adding attributes
- Noticing errors
- Ignoring transactions
- Renaming transactions
- Overriding timings
- Segments
- Custom
- Datastore
- External
- Nesting segments
- Overriding timings
- Custom events
- Custom metrics
- Async segments
- Distributed tracing
- Transaction tracing configuration
- Datastore segment tracing configuration
- Logging/daemon configuration
Failures
Currently, creating a transaction using this library returns a Result<newrelic::Transaction, newrelic::Error>
, making it up to the user to either fail hard, or ignore, when transactions fail to be created.
However, 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.
This behaviour may be changed in future, if it proves to be unpopular.
use ;
Async
The Segmented
extension trait adds the ability to run a future inside of a segment. The feature async
is required.
Distributed Tracing
Distributed tracing is available wiith the feature distributed_tracing
. Notably, this feature requires the libc crate.