Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions fastrace-datadog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,76 @@

[Datadog](https://docs.datadoghq.com/tracing/) reporter for [`fastrace`](https://crates.io/crates/fastrace).

> [!WARNING]
>
> `fastrace-datadog` is deprecated in favor of [`fastrace-opentelemetry`](https://crates.io/crates/fastrace-opentelemetry).
>
> The Datadog Agent ingests OTLP natively, so traces can be sent through `fastrace-opentelemetry` instead.
>
> See [Migration](#migration-to-fastrace-opentelemetry) below.

## Migration to fastrace-opentelemetry

The Datadog Agent ingests OTLP natively. First, enable OTLP ingestion in your Agent (see Datadog's [OTLP ingest docs](https://docs.datadoghq.com/opentelemetry/interoperability/otlp_ingest_in_the_agent/)). Then replace the reporter with `fastrace-opentelemetry` pointed at the Agent's OTLP endpoint (gRPC `4317` by default). Your instrumentation (`Span::root`, `#[trace]`, ...) stays the same — only the reporter setup changes.

Update your dependencies:

```toml
[dependencies]
fastrace = { version = "0.7", features = ["enable"] }
fastrace-opentelemetry = { version = "0.18.0" }
opentelemetry = { version = "0.32.0", default-features = false, features = ["trace"] }
opentelemetry-otlp = { version = "0.32.0", default-features = false, features = ["trace", "grpc-tonic"] }
opentelemetry_sdk = { version = "0.32.0", default-features = false, features = ["trace"] }
```

**Before** (deprecated):

```rust,ignore
let reporter = fastrace_datadog::DatadogReporter::new(
"127.0.0.1:8126".parse().unwrap(),
"my-service",
"db",
"select",
);
fastrace::set_reporter(reporter, Config::default());
```

**After** (OTLP to the Datadog Agent):

```rust,ignore
use std::borrow::Cow;

use fastrace::collector::Config;
use fastrace_opentelemetry::OpenTelemetryReporter;
use opentelemetry::InstrumentationScope;
use opentelemetry::KeyValue;
use opentelemetry_otlp::SpanExporter;
use opentelemetry_otlp::WithExportConfig;
use opentelemetry_sdk::Resource;

let reporter = OpenTelemetryReporter::new(
SpanExporter::builder()
.with_tonic()
.with_endpoint("http://127.0.0.1:4317".to_string()) // Datadog Agent OTLP endpoint
.with_protocol(opentelemetry_otlp::Protocol::Grpc)
.with_timeout(opentelemetry_otlp::OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT)
.build()
.expect("initialize otlp exporter"),
Cow::Owned(
Resource::builder()
.with_service_name("my-service")
.with_attributes([KeyValue::new("span.resource", "db")])
.with_attributes([KeyValue::new("span.type", "select")])
.build(),
),
InstrumentationScope::builder("my-crate")
.with_version(env!("CARGO_PKG_VERSION"))
.build(),
);
fastrace::set_reporter(reporter, Config::default());
```

## Dependencies

```toml
Expand Down
77 changes: 74 additions & 3 deletions fastrace-jaeger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@

[Jaeger](https://www.jaegertracing.io/) reporter for [`fastrace`](https://crates.io/crates/fastrace).

> [!WARNING]
>
> `fastrace-jaeger` is deprecated in favor of [`fastrace-opentelemetry`](https://crates.io/crates/fastrace-opentelemetry).
>
> Jaeger has supported OTLP natively since v1.35 — the path Jaeger now recommends — and a dedicated Jaeger reporter only duplicates `fastrace-opentelemetry`.
>
> See [Migrating to fastrace-opentelemetry](#migrating-to-fastrace-opentelemetry) below.

## Dependencies

```toml
Expand All @@ -27,15 +35,78 @@ Web UI is available on [http://127.0.0.1:16686/](http://127.0.0.1:16686/)
## Report to Jaeger Agent

```rust
// deprecated
use std::net::SocketAddr;

use fastrace::collector::Config;
use fastrace::prelude::*;
use fastrace_jaeger::JaegerReporter;

// Initialize reporter
let reporter = JaegerReporter::new("127.0.0.1:6831".parse().unwrap(), "asynchronous").unwrap();
fastrace::set_reporter(reporter, Config::default());

{
// Start tracing
let root = Span::root("root", SpanContext::random());
}

fastrace::flush();
```

### Migrating to fastrace-opentelemetry

`fastrace-opentelemetry` exports via OTLP, which Jaeger accepts natively (v1.35+). Your instrumentation (`Span::root`, `#[trace]`, ...) stays the same — only the reporter changes.

For example, given that you have a Jaeger stack as below:

```shell
docker run --rm -d -p6831:6831/udp -p14268:14268 -p16686:16686 -p4317:4317 --name jaeger jaegertracing/all-in-one:1.76.0
```

You can report to it via OTLP as below:

First, update your dependencies:

```toml
[dependencies]
fastrace = { version = "0.7", features = ["enable"] }
fastrace-opentelemetry = { version = "0.18.0" }
opentelemetry = { version = "0.32.0", default-features = false, features = ["trace"] }
opentelemetry-otlp = { version = "0.32.0", default-features = false, features = ["trace", "grpc-tonic"] }
opentelemetry_sdk = { version = "0.32.0", default-features = false, features = ["trace"] }
```

Then, initialize `OpenTelemetryReporter` with OTLP exporter:

```rust,ignore
use std::borrow::Cow;

use fastrace::collector::Config;
use fastrace::prelude::*;
use fastrace_opentelemetry::OpenTelemetryReporter;
use opentelemetry::InstrumentationScope;
use opentelemetry::KeyValue;
use opentelemetry_otlp::SpanExporter;
use opentelemetry_otlp::WithExportConfig;
use opentelemetry_sdk::Resource;

// Initialize reporter
let reporter =
fastrace_jaeger::JaegerReporter::new("127.0.0.1:6831".parse().unwrap(), "asynchronous")
.unwrap();
let reporter = OpenTelemetryReporter::new(
SpanExporter::builder()
.with_tonic()
.with_endpoint("http://127.0.0.1:4317".to_string())
.with_protocol(opentelemetry_otlp::Protocol::Grpc)
.with_timeout(opentelemetry_otlp::OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT)
.build()
.expect("initialize otlp exporter"),
Cow::Owned(
Resource::builder()
.with_attributes([KeyValue::new("service.name", "asynchronous")])
.build()
),
InstrumentationScope::builder("example-crate").with_version(env!("CARGO_PKG_VERSION")).build(),
);
fastrace::set_reporter(reporter, Config::default());

{
Expand Down
2 changes: 1 addition & 1 deletion fastrace-opentelemetry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Zipkin UI is available on [http://127.0.0.1:9411/](http://127.0.0.1:9411/)

## Report to OpenTelemetry Collector

```rust, no_run
```rust,no_run
use std::borrow::Cow;

use fastrace::collector::Config;
Expand Down