This repository is for active development of the Azure SDK for Java. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/java/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-java.
MIT License
2.35k
stars
1.99k
forks
source link
Define the scopes of Spring Observability - Tracing #21969
For Spring applications, there is already good tracing support by Spring Cloud Sleuth, the tracing information of your request and messages will be recorded successfully, also complete trace information is able to export.
Unfortunately, when using the Azure Spring Starter and Spring Cloud Sleuth Starter together, such as azure-spring-boot-starter-storage and spring-cloud-starter-sleuth, only the Spring level trace information can be recorded, the activities of Azure SDK will not be recorded..
e.g:
We expect it to be like this in Zipkin UI:
Problem
Azure SDK defines the tracing interface, and the default implementation is OpenTelemetryHttpPolicy and OpenTelemetryTracer which is based on Open Telemetry, but Spring Cloud Sleuth is well used for tracing in the Spring community. When using Spring Cloud Sleuth Starter, Spring Cloud Sleuth Starter will not enable the Azure SDK tracing feature unless we use the Spring Cloud Sleuth API to implement the Azure SDK tracing interface.
Rationale
Azure SDK will enable the tracing when the ServiceLoader can load the implementation successfully.
AfterRetryPolicyProvider implementation is used for service based on HTTP protocol. You can find the method stack in HttpPolicyProviders class. The SDK service builder provides upstream with an entrance to add an HTTP pipeline policy, which will be applied to HttpPipeline to process spans for each HTTP request for Azure service.
Tracer implementation is used for service based on AMQP protocol. It will be used by the TracerProviderclass.
Here we need SDK to open custom TracerProvider capability (Feature request: Service Bus | Event hubs), otherwise, we will be blocked.
Solution
Core implementation for Sleuth
Add new module azure-spring-cloud-trace-sleuth. Each Azure SDK Service depends on Azure Core interfaces, implements Azure SDK tracing implementation by Sleuth API
Auto-configure in Spring Boot
Delegates the tracer of azure-spring-cloud-trace-sleuth module to the Sleuth tracer context, which means the Azure SDK tracing will use the same Tracer instance from the Spring application context finally.
Goal
When the Spring Cloud Sleuth is enabled in an application, Sleuth will record the activities of Azure SDK services, which includes the below service clients:
Please note: These activities will not contain authentication from Azure Active Directory, such as token acquire, etc.
Context
For Spring applications, there is already good tracing support by Spring Cloud Sleuth, the tracing information of your request and messages will be recorded successfully, also complete trace information is able to export.
Unfortunately, when using the Azure Spring Starter and Spring Cloud Sleuth Starter together, such as
azure-spring-boot-starter-storage
andspring-cloud-starter-sleuth
, only the Spring level trace information can be recorded, the activities of Azure SDK will not be recorded..e.g: We expect it to be like this in Zipkin UI:
Problem
Azure SDK defines the tracing interface, and the default implementation is OpenTelemetryHttpPolicy and OpenTelemetryTracer which is based on
Open Telemetry
, but Spring Cloud Sleuth is well used for tracing in the Spring community. When using Spring Cloud Sleuth Starter, Spring Cloud Sleuth Starter will not enable the Azure SDK tracing feature unless we use the Spring Cloud Sleuth API to implement the Azure SDK tracing interface.Rationale
Azure SDK will enable the tracing when the
ServiceLoader
can load the implementation successfully.AfterRetryPolicyProvider
implementation is used for service based on HTTP protocol. You can find the method stack in HttpPolicyProviders class. The SDK service builder provides upstream with an entrance to add an HTTP pipeline policy, which will be applied toHttpPipeline
to process spans for each HTTP request for Azure service.Tracer
implementation is used for service based on AMQP protocol. It will be used by the TracerProviderclass. Here we need SDK to open customTracerProvider
capability (Feature request: Service Bus | Event hubs), otherwise, we will be blocked.Solution
Core implementation for Sleuth Add new module
azure-spring-cloud-trace-sleuth
. Each Azure SDK Service depends on Azure Core interfaces, implements Azure SDK tracing implementation by Sleuth APIAuto-configure in Spring Boot Delegates the tracer of
azure-spring-cloud-trace-sleuth
module to the Sleuth tracer context, which means the Azure SDK tracing will use the sameTracer
instance from the Spring application context finally.Goal
When the Spring Cloud Sleuth is enabled in an application, Sleuth will record the activities of Azure SDK services, which includes the below service clients: Please note: These activities will not contain authentication from Azure Active Directory, such as token acquire, etc.
https://github.com/Azure/azure-sdk-for-java/issues/24651
https://github.com/Azure/azure-sdk-for-java/issues/24652
Other clients (Not directly based on HTTP or AMQP protocol)