Skip to content

Sample demonstrating microservice communication on Azure Container Apps using Python with OpenTelemetry and Azure Monitor Distro for tracing and observability.

Notifications You must be signed in to change notification settings

Be3751/aca-otel-tracing

 
 

Repository files navigation

Microservice Communication with OpenTelemetry Tracing

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.

Inspiration

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.

Features

  • 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.

Prerequisites


Deploy to Azure and Verify Tracing

Prerequisites

  • Ensure you have Azure CLI installed and authenticated.
  • Install Azure Developer CLI (azd) version 0.9.0-beta.3 or greater.

Steps

  1. 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.
  2. Deploy the application:

    azd up

    This command will:

    • Package the application (azd package).
    • Provision Azure resources (azd provision).
    • Deploy the application code (azd deploy).
  3. Verify the deployment:

    • Navigate to the Azure Portal and locate the Container Apps for all services.
    • Check the Log stream for each app to confirm successful communication.
  4. 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.

Instrumentation with AzMon Distro

Overview

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.

Steps to Enable AzMon Distro

  1. Install the AzMon Distro package:

    pip install azure-monitor-opentelemetry
  2. 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>")
  3. Redeploy the services locally or to Azure to start collecting traces and metrics.

Benefits

  • Automatic instrumentation for HTTP, database, and messaging libraries.
  • Seamless integration with Azure Monitor for end-to-end observability.

Resources

About

Sample demonstrating microservice communication on Azure Container Apps using Python with OpenTelemetry and Azure Monitor Distro for tracing and observability.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Bicep 80.3%
  • Python 17.4%
  • Dockerfile 2.3%