[−][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 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.
Structs
Exporter | Application Insights span exporter |