Skip to content

Commit

Permalink
docs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
robertohuertasm committed Oct 12, 2024
1 parent 5350bb4 commit c86b398
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 22 deletions.
23 changes: 11 additions & 12 deletions nr-tracing-layer/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# dd-tracing-layer
# nr-tracing-layer

[![license](https://img.shields.io/crates/l/dd-tracing-layer?style=for-the-badge)](https://github.com/robertohuertasm/log-tracing-layer/blob/master/LICENSE)
[![crates.io](https://img.shields.io/crates/v/dd-tracing-layer?style=for-the-badge)](https://crates.io/crates/dd-tracing-layer)
[![docs.rs](https://img.shields.io/docsrs/dd-tracing-layer?style=for-the-badge)](https://docs.rs/dd-tracing-layer)
[![license](https://img.shields.io/crates/l/nr-tracing-layer?style=for-the-badge)](https://github.com/robertohuertasm/log-tracing-layer/blob/master/LICENSE)
[![crates.io](https://img.shields.io/crates/v/nr-tracing-layer?style=for-the-badge)](https://crates.io/crates/nr-tracing-layer)
[![docs.rs](https://img.shields.io/docsrs/nr-tracing-layer?style=for-the-badge)](https://docs.rs/nr-tracing-layer)

A [tracing layer](https://tokio.rs/tokio/topics/tracing) that sends logs to the [Datadog Log API](https://docs.datadoghq.com/api/latest/logs/?code-lang=typescript#send-logs).
A [tracing layer](https://tokio.rs/tokio/topics/tracing) that sends logs to the [New Relic Log API](https://docs.newrelic.com/docs/logs/get-started/get-started-log-management/).

It's mainly useful when you don't have access to your infrastructure and you cannot use the [Datadog Agent](https://docs.datadoghq.com/agent/) or any [other mean](https://docs.datadoghq.com/logs/log_collection/?tab=host#setup).

## Requirements

You'll need a [Datadog API Key](https://docs.datadoghq.com/account_management/api-app-keys/#api-keys) for everything to work.
You'll need a [New Relic API Key](https://docs.newrelic.com/docs/apis/intro-apis/new-relic-api-keys/) for everything to work.

## Endpoint

This crate uses the `v2` logs endpoints and, by default, will try to send the logs to the `US1` region.
By default, will try to send the logs to the `US1` region.

You can easily change the region or provide a custom URL if needed.

Expand All @@ -23,19 +22,19 @@ You can easily change the region or provide a custom URL if needed.
Here's a simple example of how to set it up and use it:

```rust
use dd_tracing_layer::DatadogOptions;
use nr_tracing_layer::NewRelicOptions;
use tracing_subscriber::prelude::*;
use tracing::{instrument, subscriber};
use tracing::{instrument, subscriber}

#[instrument]
fn log(msg: &'static str) {
tracing::info!("your message: {}", msg);
}

fn main() {
let options = DatadogOptions::new("my-service", "my-datadog-api-key")
let options = NewRelicOptions::new("my-service", "my-new-relic-api-key")
.with_tags("env:dev");
let dd = dd_tracing_layer::create(options);
let dd = nr_tracing_layer::create(options);
let subscriber = tracing_subscriber::registry()
.with(tracing_subscriber::fmt::Layer::new().json())
.with(dd);
Expand Down
14 changes: 5 additions & 9 deletions nr-tracing-layer/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
//! A tracing layer that sends logs to [New Relic](https://docs.datadoghq.com/api/latest/logs/?code-lang=typescript#send-logs).
//!
//! It's mainly useful when you don't have access to your infrastructure and you cannot use the [Datadog Agent](https://docs.datadoghq.com/agent/) or any [other mean](https://docs.datadoghq.com/logs/log_collection/?tab=host#setup).
//! A tracing layer that sends logs to [New Relic](https://docs.newrelic.com/docs/logs/get-started/get-started-log-management/).
//!
//! ## Example
//!
//! ```rust
//! use dd_tracing_layer::DatadogOptions;
//! use nr_tracing_layer::NewRelicOptions;
//! use tracing_subscriber::prelude::*;
//! use tracing::{instrument, subscriber};
//!
Expand All @@ -15,9 +13,9 @@
//! }
//!
//! fn main() {
//! let options = DatadogOptions::new("my-service", "my-datadog-api-key")
//! let options = NewRelicOptions::new("my-service", "my-new-relic-api-key")
//! .with_tags("env:dev");
//! let dd = dd_tracing_layer::create(options);
//! let dd = nr_tracing_layer::create(options);
//! let subscriber = tracing_subscriber::registry()
//! .with(tracing_subscriber::fmt::Layer::new().json())
//! .with(dd);
Expand All @@ -27,12 +25,10 @@
//!```
mod new_relic_ingestor;

// TODO: (ROB) fix the documentation of the module

pub use log_tracing_layer::LogLayer;
pub use new_relic_ingestor::{NewRelicOptions, Region};

/// Creates a log layer that will send logs to Datadog
/// Creates a log layer that will send logs to New Relic.
#[must_use]
pub fn create(options: NewRelicOptions) -> LogLayer {
let ingestor = new_relic_ingestor::NewRelicLogIngestor::new(options);
Expand Down
2 changes: 1 addition & 1 deletion nr-tracing-layer/tests/new_relic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ mod tests {
}

#[test]
// #[ignore]
#[ignore]
fn nr_manual_tests_without_mock_server() {
// set up
dotenvy::from_filename(".env").ok();
Expand Down

0 comments on commit c86b398

Please sign in to comment.