Community supported vendor integrations for applications instrumented with [OpenTelemetry
].
[OpenTelemetry
] is a collection of tools, APIs, and SDKs used to instrument,
generate, collect, and export telemetry data (metrics, logs, and traces) for
analysis in order to understand your software's performance and behavior. This
crate provides additional propagators and exporters for sending telemetry data
to [Datadog
].
opentelemetry-datadog
supports following features:
reqwest-blocking-client
: use reqwest
blocking http client to send spans.reqwest-client
: use reqwest
http client to send spans.surf-client
: use surf
http client to send spans.Example showing how to override all configuration options. See the
[DatadogPipelineBuilder
] docs for details of each option.
```norun use opentelemetry::{KeyValue, trace::Tracer}; use opentelemetry::sdk::{trace::{self, IdGenerator, Sampler}, Resource}; use opentelemetry::sdk::export::trace::ExportResult; use opentelemetrydatadog::{newpipeline, ApiVersion, Error}; use opentelemetryhttp::HttpClient; use asynctrait::asynctrait;
// reqwest and surf are supported through features, if you prefer an // alternate http client you can add support by implementing HttpClient as // shown here. #[derive(Debug)] struct IsahcClient(isahc::HttpClient);
#[asynctrait]
impl HttpClient for IsahcClient {
async fn send(&self, request: http::Request
if result.status().is_success() {
Ok(())
} else {
Err(Error::Other(result.status().to_string()).into())
}
} }
fn main() -> Result<(), opentelemetry::trace::TraceError> { let tracer = newpipeline() .withservicename("myapp") .withversion(ApiVersion::Version05) .withagentendpoint("http://localhost:8126") .withtraceconfig( trace::config() .withsampler(Sampler::AlwaysOn) .withidgenerator(IdGenerator::default()) ) .install_batch(opentelemetry::runtime::Tokio)?;
tracer.in_span("doing_work", |cx| {
// Traced app logic here...
});
opentelemetry::global::shutdown_tracer_provider();
Ok(())
} ```