This repository demonstrates how to build microservices that communicate and showcases how to instrument these services with OpenTelemetry and Azure Monitor Distro (AzMon Distro) for distributed tracing and observability.
This repository is inspired by the Azure-Samples/svc-invoke-dapr-python, which demonstrates microservice communication using Dapr. However, this implementation focuses on using OpenTelemetry to trace service-to-service communication between the following services:
- Checkout Service: Initiates the order process.
- Order Service: Processes the order.
- Receipt Service: Generates a receipt for the order.
- Azure Storage Account: Stores the receipt data.
- Microservice communication.
- Deployment to Azure Container Apps (ACA) using Azure Developer CLI (azd).
- Distributed tracing and monitoring with Azure Application Insights and AzMon Distro.
- Tracing service-to-service communication, including interactions with Azure Storage Account.
- Install Python 3.8+.
- Install Azure Developer CLI (azd).
- Install Docker and ensure it is running.
- Ensure you have Azure CLI installed and authenticated.
- Install Azure Developer CLI (azd) version 0.9.0-beta.3 or greater.
-
Initialize the project:
azd init
Provide the following information when prompted:
Environment Name: Unique name for your Azure resources.Azure Location: Region where resources will be deployed.Azure Subscription: Subscription to use for deployment.
-
Deploy the application:
azd up
This command will:
- Package the application (
azd package). - Provision Azure resources (
azd provision). - Deploy the application code (
azd deploy).
- Package the application (
-
Verify the deployment:
- Navigate to the Azure Portal and locate the Container Apps for all services.
- Check the
Log streamfor each app to confirm successful communication.
-
View distributed traces:
- Open the Azure Application Insights resource in the Azure Portal.
- Use the "Transaction Search" or "Live Metrics" features to view traces of service invocation and Azure Storage interactions.
The Azure Monitor OpenTelemetry Distro (AzMon Distro) simplifies the process of instrumenting your applications for distributed tracing and metrics collection. It integrates seamlessly with Azure Application Insights.
-
Install the AzMon Distro package:
pip install azure-monitor-opentelemetry
-
Update your application code to initialize the AzMon Distro SDK:
from azure.monitor.opentelemetry import configure_azure_monitor configure_azure_monitor(connection_string="InstrumentationKey=<your-instrumentation-key>")
-
Redeploy the services locally or to Azure to start collecting traces and metrics.
- Automatic instrumentation for HTTP, database, and messaging libraries.
- Seamless integration with Azure Monitor for end-to-end observability.
