Ocbj.OpenTracing.Contrib.NetCore 1.0.1

dotnet add package Ocbj.OpenTracing.Contrib.NetCore --version 1.0.1
                    
NuGet\Install-Package Ocbj.OpenTracing.Contrib.NetCore -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Ocbj.OpenTracing.Contrib.NetCore" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Ocbj.OpenTracing.Contrib.NetCore" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Ocbj.OpenTracing.Contrib.NetCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Ocbj.OpenTracing.Contrib.NetCore --version 1.0.1
                    
#r "nuget: Ocbj.OpenTracing.Contrib.NetCore, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Ocbj.OpenTracing.Contrib.NetCore@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Ocbj.OpenTracing.Contrib.NetCore&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Ocbj.OpenTracing.Contrib.NetCore&version=1.0.1
                    
Install as a Cake Tool

nuget

OpenTracing instrumentation for .NET Core apps

This repository provides OpenTracing instrumentation for .NET Core based applications. It can be used with any OpenTracing compatible tracer.

IMPORTANT: OpenTracing and OpenCensus have merget to form OpenTelemetry! The OpenTelemetry .NET library can be found at https://github.com/open-telemetry/opentelemetry-dotnet.

Supported .NET versions

This fork supports apps targeting .NET 8.0 and .NET 9.0

Supported libraries and frameworks

DiagnosticSource based instrumentation

This project supports any library or framework that uses .NET's DiagnosticSource to instrument its code. It will create a span for every Activity and it will create span.Log calls for all other diagnostic events.

To further improve the tracing output, the library provides enhanced instrumentation (Inject/Extract, tags, configuration options) for the following libraries / frameworks:

  • ASP.NET Core
  • Entity Framework Core
  • System.Net.Http (HttpClient)
  • System.Data.SqlClient
  • Microsoft.Data.SqlClient
Microsoft.Extensions.Logging based instrumentation

This project also adds itself as a logger provider for logging events from the Microsoft.Extensions.Logging system. It will create span.Log calls for each logging event, however it will only create them if there is an active span (ITracer.ActiveSpan).

Usage

This project depends on several packages from Microsofts Microsoft.Extensions.* stack (e.g. Dependency Injection, Logging) so its main use case is ASP.NET Core apps and any other Microsoft.Extensions-based console apps.

1. Add the NuGet package OpenTracing.Contrib.NetCore to your project.
2. Add the OpenTracing services to your IServiceCollection via services.AddOpenTracing().

How you do this depends on how you've setup the Microsoft.Extensions.DependencyInjection system in your app.

In ASP.NET Core apps you can add the call to your ConfigureServices method (of your Program.cs file):

public static IWebHost BuildWebHost(string[] args)
{
    return WebHost.CreateDefaultBuilder(args)
        .UseStartup<Startup>()
        .ConfigureServices(services =>
        {
            // Enables and automatically starts the instrumentation!
            services.AddOpenTracing();
        })
        .Build();
}
3. Make sure InstrumentationService, which implements IHostedService, is started.

InstrumentationService is responsible for starting and stopping the instrumentation. The service implements IHostedService so it is automatically started in ASP.NET Core, however if you have your own console host, you manually have to call StartAsync and StopAsync.

Note that .NET Core 2.1 greatly simplified this setup by introducing a generic HostBuilder that works similar to the existing WebHostBuilder from ASP.NET Core. Have a look at the TrafficGenerator sample for an example of a HostBuilder based console application.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 1,838 8/8/2025
1.0.0 1,103 8/3/2025