Git Product home page Git Product logo

distributed-tracing's Introduction

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

distributed-tracing's People

Contributors

gruaba2k avatar gruabamike avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

distributed-tracing's Issues

improve usage of semantic conventions

  • AttributeMessagingSystem
  • AttributeMessagingDestination
  • AttributeMessagingDestinationKind
  • AttributeMessagingProtocol
  • AttributeMessagingProtocolVersion
  • AttributeMessagingUrl
  • AttributeMessagingMessageId
  • AttributeMessagingConversationId (Correlation ID)
  • AttributeMessagingConsumerId (ClientId)
  • MessagingDestinationKindValues (queue und topic)
  • AttributeMessagingOperation

https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/messaging.md
https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/messaging.md#operation-names

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.