[][src]Crate opentelemetry_application_insights

An Azure Application Insights exporter implementation for OpenTelemetry Rust.

Disclaimer: This is not an official Microsoft product.

Usage

Configure the exporter:

use opentelemetry::{global, sdk};

fn init_tracer() {
    let instrumentation_key = "...".to_string();
    let exporter = opentelemetry_application_insights::Exporter::new(instrumentation_key);
    let provider = sdk::Provider::builder()
        .with_simple_exporter(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 SpanKindApplication Insights telemetry type
CLIENT, PRODUCER, INTERNALDependency
SERVER, CONSUMERRequest

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 keyApplication Insights field
enduser.idContext: Authenticated user id
http.urlDependency Data
db.statementDependency Data
http.hostDependency Target
net.peer.nameDependency Target
db.instanceDependency Target
http.status_codeDependency Result code
db.typeDependency Type
messaging.systemDependency Type
"HTTP" if any http. attribute existsDependency Type
"DB" if any db. attribute existsDependency Type
http.urlRequest Url
http.targetRequest Url
http.status_codeRequest Response code

All other attributes are be directly converted to custom properties.

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

Structs

Exporter

Application Insights span exporter