techgeek03 / MongoDB.Driver.Core.Extensions.DiagnosticSources

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MongoDB.Driver.Core.Extensions.DiagnosticSources

CI NuGet NuGet MyGet (dev)

Usage

This repo includes the package:

The MongoDB.Driver.Core.Extensions.DiagnosticSources package extends the core MongoDB C# driver to expose telemetry information via System.Diagnostics.

To use MongoDB.Driver.Core.Extensions.DiagnosticSources, you need to configure your MongoClientSettings to add this MongoDB event subscriber:

var clientSettings = MongoClientSettings.FromUrl(mongoUrl);
clientSettings.ClusterConfigurator = cb => cb.Subscribe(new DiagnosticsActivityEventSubscriber());
var mongoClient = new MongoClient(clientSettings);

To capture the command text as part of the activity:

var clientSettings = MongoClientSettings.FromUrl(mongoUrl);
var options = new InstrumentationOptions { CaptureCommandText = true };
clientSettings.ClusterConfigurator = cb => cb.Subscribe(new DiagnosticsActivityEventSubscriber(options));
var mongoClient = new MongoClient(clientSettings);

This package exposes an ActivitySource with a Name the same as the assembly, MongoDB.Driver.Core.Extensions.DiagnosticSources. Use this name in any ActivityListener-based listeners.

All the available OpenTelemetry semantic tags are set.

This package supports MongoDB C# Driver versions 2.3 to 3.0.

About

License:Apache License 2.0


Languages

Language:C# 91.8%Language:PowerShell 8.2%