Skip to content

Prototype for distributed tracing in a .NET microservice environment using ActiveMQ as message broker.

Notifications You must be signed in to change notification settings

gruabamike/distributed-tracing

Repository files navigation

Distributed Tracing with OpenTelemetry in .NET

Introduction

This repository covers an exemplary implementation of distributed tracing in a microservices architecture using .NET. The generation of complete traces of an end-to-end request is depicted through the message broker ActiveMQ. To obtain complete traces, the concepts known from OpenTelemetry regarding the propagation of context and semantic conventions were applied. To enable the convenient mechanism of automatic instrumentation of processes communicating through the message broker, the opentelemetry-dotnet-contrib repository has been forked and an implementation for automatic instrumentation for ActiveMQ has been added.

Architecture

Alt prototype architecture

Context Propagation

Alt context propagation

Trace

Alt Trace

Span (Semantic Conventions)

Alt Span

Setup & Deployment

This chapter describes the setup and deployment process in order to run the prototype using automatic instrumentation of ActiveMQ.

Prerequisites

Setup Local NuGet Feed (BaGet via Docker)

  • setup BaGet docker image
    • setup BaGet in any directory (e.g. C:\src\BaGet)
    • create file baget.env
    • add folder baget-data
    • run docker command in same folder as .env file docker run --rm --name nuget-server -p 5555:80 --env-file baget.env -v "$(pwd)/baget-data:/var/baget" loicsharma/baget:latest
  • make sure that you've installed nuget.exe (>_ dotnet nuget)

Publish OpenTelemetry.Instrumentation.ActiveMQ Packages

  • clone opentelemetry-dotnet-contrib and open the solution
  • switch to the specified branch
  • terminal: change directory to src folder "OpenTelemetry.Instrumentation.ActiveMQ"
  • dotnet pack
  • navigate to specified output folder where the packages and symbols have been created
  • push it to your local BaGet NuGet Feed
  • dotnet nuget push -k ${{NUGET-API-KEY}} -s http://localhost:5555/v3/index.json OpenTelemetry.Instrumentation.ActiveMQ.0.0.0-alpha.0.559.nupkg
  • dotnet nuget push -k ${{NUGET-API-KEY}} -s http://localhost:5555/v3/index.json OpenTelemetry.Instrumentation.ActiveMQ.0.0.0-alpha.0.559.snupkg

Entity Framework Migration

The tools can be installed as either a global or local tool. Most developers prefer installing dotnet ef as a global tool using the following command: dotnet tool install --global dotnet-ef

Update the tool using the following command: dotnet tool update --global dotnet-ef

Run DistributedTracing via Docker-Compose

  • clone this repository
  • navigate to root project folder
  • double check if the references nuget package version in the libraries matches the pushed ones
  • docker-compose up
  • initial database migration (navigate to the following directories respectively: Users.Api, Orders.Api)
    • dotnet ef database update

Example request

The following request can be executed (e.g. with postman)

POST /orders HTTP/1.1
Content-Type: application/json
User-Agent: PostmanRuntime/7.30.0
Accept: */*
Postman-Token: c0f043d2-dbad-45c8-832b-cf64667eebe3
Host: localhost:9001
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 136
 
{
  "userId": "00000000-0000-0000-0000-000000000001",
  "productId": "00000000-0000-0000-0000-000000000001",
  "quantity": 2
}

Services

About

Prototype for distributed tracing in a .NET microservice environment using ActiveMQ as message broker.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published