Elyspio.Utils.Telemetry 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Elyspio.Utils.Telemetry --version 1.0.0
                    
NuGet\Install-Package Elyspio.Utils.Telemetry -Version 1.0.0
                    
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="Elyspio.Utils.Telemetry" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Elyspio.Utils.Telemetry" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Elyspio.Utils.Telemetry" />
                    
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 Elyspio.Utils.Telemetry --version 1.0.0
                    
#r "nuget: Elyspio.Utils.Telemetry, 1.0.0"
                    
#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 Elyspio.Utils.Telemetry@1.0.0
                    
#: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=Elyspio.Utils.Telemetry&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Elyspio.Utils.Telemetry&version=1.0.0
                    
Install as a Cake Tool

Elyspio.Utils.Telemetry

Ce package permet d'ajouter des informations de télémétrie dans une application dotnet 7+.

Installation

dotnet add package Elyspio.Utils.Telemetry
dotnet add package Elyspio.Utils.Telemetry.MongoDB
dotnet add package Elyspio.Utils.Telemetry.Sql
dotnet add package Elyspio.Utils.Telemetry.Redis
dotnet add package Elyspio.Utils.Telemetry.MassTransit

Utilisation

Depuis la version 0.11.0, ce package inclut Sisra.Socle.Logs.dotNetCore, afin de récupérer l'idFlux depuis le context serilog

Activation dans l'application

Dans le builder de l'application, il faut ajouter les services de télémétrie


if (builder.Configuration.IsTelemetryEnabled(out var telemetryOptions))
{
	var telemetryBuilder = new AppOpenTelemetryBuilder<Program>(telemetryOptions!)
	{
		Tracing = tracing => tracing
			.AddAppMongoInstrumentation()                         // Elyspio.Utils.MongoDB
			.AddAppSqlClientInstrumentation()                     // Elyspio.Utils.Sql
			.AddAppRedisInstrumentation()                         // Elyspio.Utils.Redis
			.AddAppMassTransitInstrumentation(),                  // Elyspio.Utils.MassTransit
		Meter = meter => meter.AddAppMassTransitInstrumentation() // Elyspio.Utils.MassTransit
	};
	telemetryBuilder.Build(builder.Services);
}

Une fois l'application builder créée, il faut activer les middlewares de Sisra.Socle.Logs.dotNetCore

app.UseSisraSocleLogs();

Gestion des traces de MongoDB

Pour avoir accès aux requêtes jouées dans Mongo il faut ajouter ce code lors de la création du client en plus d'utiliser l'extension AddAppMongoInstrumentation

var mongoUrl = new MongoUrl(connectionString);
var clientSettings = MongoClientSettings.FromUrl(mongoUrl);

clientSettings.ClusterConfigurator = cb => { cb.Subscribe(new MongoDbActivityEventSubscriber()); };

var client = new MongoClient(clientSettings);

Gestion des traces des consumers MassTransit

Pour avoir accès aux messages consommés par MassTransit il faut faire hériter les consumers de la classe TracingConsumer et implementer la méthode ConsumeAsync (renommage de la méthode Consume de MassTransit)

Exemple :

using Elyspio.Utils.Telemetry.MassTransit.Tracing;
using MassTransit;

public class ToggleTodoConsumer(ITodoRepository todoRepository) : TracingConsumer<ToggleTodoMessage> // remplace  IConsumer<ToggleTodoMessage>
{
	// Remplace public async Task Consume(ConsumeContext<ToggleTodoMessage> context)
	protected override async Task ConsumeAsync(ConsumeContext<ToggleTodoMessage> context)
	{
		// Do something
	}
}

Configuration

Dans le fichier appsettings.json, ajouter la section suivante :

{
	"OpenTelemetry": {
		// Obligatoire
		"CollectorUri": "http://localhost:4318",
		// Obligatoire
		"Service": "aura-local-telemetry-webapi",
		// Optionnel
		"Version": "1.0.0",
		// Optionnel par défaut Grpc
		"Protocol": "HttpProtobuf",
		// Optionnel
		"Authentication": {
			"CertificatePemPath": "./client.pem", // Certificat pour faire du mTLS
			"CertificateKeyPath": "./client.key", // key du certificat pour faire du mTLS
		}
	}
}
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 was computed.  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 (4)

Showing the top 4 NuGet packages that depend on Elyspio.Utils.Telemetry:

Package Downloads
Elyspio.Utils.Telemetry.MassTransit

Bootstrap OpenTelemetry instrumentation/exporter

Elyspio.Utils.Telemetry.MongoDB

Bootstrap OpenTelemetry instrumentation/exporter

Elyspio.Utils.Telemetry.Redis

Bootstrap OpenTelemetry instrumentation/exporter

Elyspio.Utils.Telemetry.Sql

Bootstrap OpenTelemetry instrumentation/exporter

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 276 7/20/2025
1.0.0 270 7/20/2025