Sample project for developing Distributed Tracing. We are using these technologies.
- Azure Functions V2
- Storage Queue
- Spring boot
- Service Bus
- Durable Functions (Next Step)
- Application Insights
You can learn how to implement Distributed Tracing using Application Insights and Azure Functions.
Storage Queue -> Azure Functions (1) -> Http Request -> Spring boot -> Service Bus -> Azure Functions (2) -> Service Bus -> Azure Functions (3)
For local development, Use Storage Emulator. Start the emulator.
If you are using Mac, I recommend to use Azurite as a storage emulator.
Download and install it.
Create an Application Insights on Azure Protal. Then get InstrumentationKey.
Copy the local.settings.json.example
to local.settings.json
then chenge the value of APPINSIGHTS_INSTRUMENTATIONKEY
to fit your InstrumentationKey of the ApplicationInsights.
Start the Azure Functions. In case of Visual Studio, Hit F5. In case of Visual Studio Code, Open Visual Studio Code on the FunctionsSample/FunctionsSample directory. Then click Debug Attach to C# Functions
.
Copy the ApplicationInsights.xml then fill the InstrumentKey part from your Application Insights instrument key. Also, I recommend to create set_environment.sh from the set_environment.sh.example. However, ApplicationInsights.xml might be enough.
Go to the JavaSample directory, then gradlew bootRun
Just send get request by postman or something.
http://localhost:7071/api/StartOperation
You will see the telemetry is sending to the Application Insights, and you will see the Parent Request-Id on the Java Application console and current RequestTelemtryId on your terminal.
Parent Request-Id: |gqHOHSfsTMY=.bc503bfa_1.bc503c00_1.
Current Request Id: |gqHOHSfsTMY=.bc503bfa_1.bc503c00_1.5f667911_ RootId: gqHOHSfsTMY= ParentId: |gqHOHSfsTMY=.bc503b
fa_1.bc503c00_1.
like this. After 5 min, you can find the telemetry is on your Application Insigts, Application Map.
Now we almost done. Generate Request/Dependency Telemetry and send it to the Application Insights and make sure it works. However something is remains.
- Sending ParentId to the ServiceBus
- Create a Service Bus Trigger Azure Functions and send the following ServiceBus trigger functions.
- W3C TraceContext correlation sample