Diagnose issues with Distributed Tracing for Azure IoT Hub (preview) in Visual Studio Code 

Rukmani Gopalan

Effective monitoring is instrumental in understanding and troubleshooting your modern cloud solution leveraging multiple services. Distributed tracing helps you diagnose issues in your cloud solution by providing the capability to track the flow of a call and the associated latency across these different services.

Today, we announced the public preview of distributed tracing support in Azure IoT Hub. You can leverage the IoT Hub logs with distributed tracing information to monitor the flow of messages through the IoT Hub and troubleshoot problems related to message loss or performance. You can further aggregate these logs to archive them in Blob storage, query the logs through Log Analytics and visualize the data flow in AppInsights as shown below.

You can now use VS code to enable diagnostics on a subset of your devices and choose the frequency of logging by setting a sampling rate of diagnostic logs per device depending on your business needs. This post provides an outline to configure distributed tracing settings using VS Code. Try it today and let us know what you think.

Before you begin

Please take the following steps to ensure that you are ready to leverage distributed tracing.

  1. Ensure that you have the Azure IoT Hub Toolkit v2.x.x extension in VSCode. You can install the Azure IoT Tools to get this extension.
  2. Ensure that your devices have the latest device C SDK and have the code updated to understand the distributed tracing settings. You can leverage the sample client application code to make changes to your device SDK.

 

Configure device to send diagnostic information

After setting up your devices with updated C SDK, now you can control distributed tracing from Visual Studio Code with the Azure IoT Tools extension in VS Code.

  1. Expand “AZURE IOT HUB DEVICES” section inside Explorer, and follow the instructions to connect to your Azure IoT Hub.
  2. Create a device or expand an existing device, you can see there is a child node named “Distributed Tracing Setting (Preview)”
  3. Right click it and select “Update Distributed Tracing Setting (Preview)”
  4. Now you can enable/disable distributed tracing and set the sampling rate
  5. After setting, you can expand “Distributed Tracing Setting (Preview)” node to see if desired property is set successfully:
  6. If your device is connected to IoT Hub, you can monitor reported properties. Once this section is updated, it means your device gets and respects the distributed tracing setting you just set. You can also right click “Enable Distributed Tracing” and “Sampling Rate” nodes under “Desired” to set them separately.

 

Accessing the logs

Once you have enabled distributed tracing on your devices, you can use the Azure portal to archive your logs to Azure storage, query in Log Analytics or visualize in AppMap. More information about distributed tracing and ways to capture and analyze the logs can be found in our documentation.

You can use this sample to get started on how you can configure and access the logs (and visualize the data) using AppInsights.

More useful resources on Azure IoT Hub

 

2 comments

Discussion is closed. Login to edit/delete existing comments.

  • Martin Abbott 0

    The link you’ve provided to the device C SDK above (https://aka.ms/azureiotcsdk) leads to a 404 on GitHub, the short link appears to have an extra character at the end when it is expanded.

    • Rukmani GopalanMicrosoft employee 0

      Thanks a lot Martin, fixed it.

Feedback usabilla icon