Expand description
§Azure Core OpenTelemetry Tracing
This crate provides OpenTelemetry distributed tracing support for the Azure SDK for Rust.
It bridges the standardized azure_core
tracing traits with the OpenTelemetry for Rust implementation,
enabling automatic span creation, context propagation, and telemetry collection for Azure services.
It allows Rust applications which use the OpenTelemetry APIs to generate OpenTelemetry spans for Azure SDK for Rust Clients.
§OpenTelemetry integration with the Azure SDK for Rust
To integrate the OpenTelemetry APIs with the Azure SDK for Rust, you create a OpenTelemetryTracerProvider
and pass it into your SDK ClientOptions.
use azure_core_opentelemetry::OpenTelemetryTracerProvider;
use opentelemetry_sdk::trace::SdkTracerProvider;
use std::sync::Arc;
// Create an OpenTelemetry tracer provider adapter from an OpenTelemetry TracerProvider
let otel_tracer_provider = Arc::new(SdkTracerProvider::builder().build());
let azure_provider = OpenTelemetryTracerProvider::new(otel_tracer_provider);
let options = ServiceClientOptions {
client_options: ClientOptions {
request_instrumentation: Some(RequestInstrumentationOptions {
tracer_provider: Some(azure_provider),
}),
..Default::default()
},
..Default::default()
};
If it is more convenient to use the global OpenTelemetry provider, then the OpenTelemetryTracerProvider::new_from_global_provider
method will configure the OpenTelemetry support to use the global provider instead of a custom configured provider.
use azure_core_opentelemetry::OpenTelemetryTracerProvider;
use opentelemetry_sdk::trace::SdkTracerProvider;
use std::sync::Arc;
let azure_provider = OpenTelemetryTracerProvider::new_from_global_provider();
let options = ServiceClientOptions {
client_options: ClientOptions {
request_instrumentation: Some(RequestInstrumentationOptions {
tracer_provider: Some(azure_provider),
}),
..Default::default()
},
};
Once the OpenTelemetryTracerProvider
is integrated with the Azure Service ClientOptions, the Azure SDK will be configured to capture per-API and per-HTTP operation tracing options, and the HTTP requests will be annotated with W3C Trace Context headers.
§Contributing
See the CONTRIBUTING.md for details on building, testing, and contributing to these libraries.
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://opensource.microsoft.com/cla/.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
§Reporting security issues and security bugs
Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) secure@microsoft.com. You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the Security TechCenter.
§License
Azure SDK for Rust is licensed under the MIT license.
Structs§
- Open
Telemetry Tracer Provider - Enum to hold different OpenTelemetry tracer provider implementations.