Crates.io 0.1.1 Documentation 0.1.1 Workflow Status

opentelemetry-application-insights

An Azure Application Insights exporter implementation for OpenTelemetry Rust.

Disclaimer: This is not an official Microsoft product.

Usage

Configure the exporter:

```rust use opentelemetry::{global, sdk};

fn inittracer() { let instrumentationkey = "...".tostring(); let exporter = opentelemetryapplicationinsights::Exporter::new(instrumentationkey); let provider = sdk::Provider::builder() .withsimpleexporter(exporter) .build(); global::set_provider(provider); } ```

Then follow the documentation of opentelemetry to create spans and events.

Attribute mapping

OpenTelemetry and Application Insights are using different terminology. This crate tries it's best to map OpenTelemetry fields to their correct Application Insights pendant.

The OpenTelemetry SpanKind determines the Application Insights telemetry type:

| OpenTelemetry SpanKind | Application Insights telemetry type | | -------------------------------- | ----------------------------------- | | CLIENT, PRODUCER, INTERNAL | Dependency | | SERVER, CONSUMER | Request |

The Span's list of Events are converted to Trace telemetry.

The Span's status determines the Success field of a Dependency or Request. Success is true if the status is OK; otherwise false.

For INTERNAL Spans the Dependency Type is always "InProc" and Success is true.

The following of the Span's attributes map to special fields in Application Insights (the mapping tries to follow OpenTelemetry semantic conventions).

| OpenTelemetry attribute key | Application Insights field | | ---------------------------------------- | ------------------------------ | | enduser.id | Context: Authenticated user id | | http.url | Dependency Data | | db.statement | Dependency Data | | http.host | Dependency Target | | net.peer.name | Dependency Target | | db.instance | Dependency Target | | http.status_code | Dependency Result code | | db.type | Dependency Type | | messaging.system | Dependency Type | | "HTTP" if any http. attribute exists | Dependency Type | | "DB" if any db. attribute exists | Dependency Type | | http.url | Request Url | | http.target | Request Url | | http.status_code | Request Response code |

All other attributes are be directly converted to custom properties.

For Requests the attributes http.method and http.route override the Name.

Thanks

This is based on the amazing work by Denis Molokanov. Check out the appinsights crate, if you want a more direct integration with Application Insights.

Application Insights integration

The integration is based on resources mentioned here:

Can I send telemetry to the Application Insights portal?

We recommend you use our SDKs and use the SDK API. There are variants of the SDK for various platforms. These SDKs handle buffering, compression, throttling, retries, and so on. However, the ingestion schema and endpoint protocol are public.

https://docs.microsoft.com/en-us/azure/azure-monitor/faq#can-i-send-telemetry-to-the-application-insights-portal