[c#] Using W3C Trace Context standard in distributed tracing

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • opentelemetry-specification

    Specifications for OpenTelemetry

  • W3C TraceContext is one of the propagators maintained and distributed as extension packages by OTel. That's the reason why OTel is always related to W3C TraceContext and vice versa.

  • dotnet-trace-context

    Dotnet 5 W3C Trace Context example

  • Inside src folder, type the command below to up all containers (first-api, second-api, worker, rabbit and zipkin):

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • zipkin

    Zipkin is a distributed tracing system

  • The main objective is to propagate a message with traceparent id throw two APIs and one worker using W3C trace context standard. The first-api calls the second-api by a http call while the second-api has an asynchronous communication with the worker by a message broker (rabbitmq was chosen for that). Furthermore, zipkin was the trace system chosen (or vendor as the standard call it), being responsible for getting the application traces and building the distributed tracing diagram:

  • .NET Runtime

    .NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.

  • The default diagnostics library in .NET 5, called System.Diagnostics, is already prepared to propagate the context based on W3C TraceContext specification. In previous .NET Core versions, the context was propagated with a hierarchical identifier format by default. On .NET Core 3.0, the identifier format setup started to be available, see this stackoverflow question for more information about how to configure w3c's format in previous .NET Core versions.

  • trace-context-w3c

    W3C Trace Context purpose of and what kind of problem it came to solve.

  • The main objective is to propagate a message with traceparent id throw two APIs and one worker using W3C trace context standard. The first-api calls the second-api by a http call while the second-api has an asynchronous communication with the worker by a message broker (rabbitmq was chosen for that). Furthermore, zipkin was the trace system chosen (or vendor as the standard call it), being responsible for getting the application traces and building the distributed tracing diagram:

  • opentelemetry-dotnet

    The OpenTelemetry .NET Client

  • Besides that, the propagation fields (traceparent and tracestate) were added in the message header. In the last article, I said that the standard (in the Working Draft (WD) step of the w3c process) recommends to add the propagation fields in the application-properties section by the message publisher. For the current example, I chose to propagate that context in the message header even for AMQP calls as was done in the dotnet OpenTelemetry example. It's important to reinforce that Trace Context: AMQP protocol is not a W3C Recommendation yet. Take a look at the place where the propagation fields were added:

  • ASP.NET Core

    ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.

  • By default, the ASP.NET core starts an Activity span when the request is beginning and stop it at the end for that reason this kind of setup is not required for the first-api and the second-api. On the other hand, the manually creation of an activity span is required for the worker because in that case, it's not dealing with http calls, neither an API, but a message listener.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • RabbitMQ

    Open source RabbitMQ: core server and tier 1 (built-in) plugins

  • The main objective is to propagate a message with traceparent id throw two APIs and one worker using W3C trace context standard. The first-api calls the second-api by a http call while the second-api has an asynchronous communication with the worker by a message broker (rabbitmq was chosen for that). Furthermore, zipkin was the trace system chosen (or vendor as the standard call it), being responsible for getting the application traces and building the distributed tracing diagram:

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts