RemyDuijkeren.OpenTelemetry.Instrumentation.DataverseServiceClient
1.2.0
dotnet add package RemyDuijkeren.OpenTelemetry.Instrumentation.DataverseServiceClient --version 1.2.0
NuGet\Install-Package RemyDuijkeren.OpenTelemetry.Instrumentation.DataverseServiceClient -Version 1.2.0
<PackageReference Include="RemyDuijkeren.OpenTelemetry.Instrumentation.DataverseServiceClient" Version="1.2.0" />
paket add RemyDuijkeren.OpenTelemetry.Instrumentation.DataverseServiceClient --version 1.2.0
#r "nuget: RemyDuijkeren.OpenTelemetry.Instrumentation.DataverseServiceClient, 1.2.0"
// Install RemyDuijkeren.OpenTelemetry.Instrumentation.DataverseServiceClient as a Cake Addin #addin nuget:?package=RemyDuijkeren.OpenTelemetry.Instrumentation.DataverseServiceClient&version=1.2.0 // Install RemyDuijkeren.OpenTelemetry.Instrumentation.DataverseServiceClient as a Cake Tool #tool nuget:?package=RemyDuijkeren.OpenTelemetry.Instrumentation.DataverseServiceClient&version=1.2.0
Dataverse ServiceClient Instrumentation for OpenTelemetry .NET
This is an Instrumentation Library, which instruments Dataverse ServiceClient and collect traces about incoming Dataverse requests.
This component is based on the v1.24 of database semantic conventions. For details on the default set of attributes that are added, checkout Traces sections below.
Getting Started
Step 1: Install Package
Add a reference to
the RemyDuijkeren.OpenTelemetry.Instrumentation.DataverseServiceClient
package. Also, add any other instrumentations & exporters you will need.
dotnet add package RemyDuijkeren.OpenTelemetry.Instrumentation.DataverseServiceClient
Step 2: Enable Dataverse ServiceClient Instrumentation at application startup
Dataverse ServiceClient instrumentation must be enabled at application startup, when setting up the host for
OpenTelemetry. See the
package OpenTelemetry.Extensions.Hosting
for more info how to add OpenTelemetry to the
application.
The following example demonstrates adding Dataverse ServiceClient instrumentation within the extension method
WithTracing()
on the OpenTelemetryBuilder
. The extension method AddDataverseServiceClientInstrumentation()
registers the instrumentation to the TracerProvider
and tries to replace any registered IOrganizationService
,
IOrganizationServiceAsync
or IOrganizationServiceAsync2
by wrapping the service into
OpenTelemetryServiceClientDecorator
that will do the actual tracing.
This example also sets up the Console Exporter, which requires adding the
package OpenTelemetry.Exporter.Console
to the application.
using Microsoft.Extensions.DependencyInjection;
using OpenTelemetry.Trace;
public void ConfigureServices(IServiceCollection services)
{
services.AddOpenTelemetry()
.WithTracing(builder => builder
.AddDataverseServiceClientInstrumentation()
.AddConsoleExporter());
}
Optional create the OpenTelemetryServiceClientDecorator
manually by passing it a ServiceClient
like:
using Microsoft.PowerPlatform.Dataverse.Client;
using OpenTelemetry.Instrumentation.DataverseServiceClient;
var serviceClient = new ServiceClient(new ConnectionOptions { /* your config */ } );
IOrganizationServiceAsync2 decoratedServiceClient = new OpenTelemetryServiceClientDecorator(serviceClient);
// Use the decoratedServiceClient as you would use the serviceClient
var response = decoratedServiceClient.Execute(new WhoAmIRequest());
Traces
Following list of attributes are added by default on activity. See db-spans for more details about each individual attribute:
db.operation
db.sql.table
db.statement
db.system
db.name
db.connection_string
db.user
db.dataverse.organization_id
db.dataverse.organization_version
db.dataverse.geo
error.type
server.address
server.port
Add Custom Activities
When you have helper methods for Dataverse calls that you want to trace, you can create custom activities, using the
extension method StartDataverseActivity
:
public class DataverseHelper
{
private readonly IOrganizationService _service;
public DataverseHelper(IOrganizationService service)
{
_service = service;
}
public void MyFirstHelperMethod()
{
using Activity? activity = _service.StartDataverseActivity();
// Add custom attributes (optional)
activity?.SetTag("custom.tag", "custom value");
// Use the service with your own logic
var response = _service.Execute(new WhoAmIRequest());
}
}
There are overloads for StartDataverseActivity
to pass in the Entity
or EntityReference
, statement and
operation. By default the operation is the name of the method that called StartDataverseActivity
, in this example
MyFirstHelperMethod
.
References
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Framework | net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 is compatible. net481 was computed. |
-
.NETFramework 4.6.2
- Microsoft.PowerPlatform.Dataverse.Client (>= 1.1.16 && < 2.0.0)
- OpenTelemetry (>= 1.4.0 && < 2.0.0)
-
.NETFramework 4.7.2
- Microsoft.PowerPlatform.Dataverse.Client (>= 1.1.16 && < 2.0.0)
- OpenTelemetry (>= 1.4.0 && < 2.0.0)
-
.NETFramework 4.8
- Microsoft.PowerPlatform.Dataverse.Client (>= 1.1.16 && < 2.0.0)
- OpenTelemetry (>= 1.4.0 && < 2.0.0)
-
net6.0
- Microsoft.PowerPlatform.Dataverse.Client (>= 1.1.16 && < 2.0.0)
- OpenTelemetry (>= 1.4.0 && < 2.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.