From 22fccbc368173e9df64dcb73699ec7f8919157b4 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Mon, 12 Feb 2024 12:35:35 +1300 Subject: [PATCH] Update dotnet.mdx --- .../opentelemetry-setup/dotnet.mdx | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/platform-includes/performance/opentelemetry-setup/dotnet.mdx b/platform-includes/performance/opentelemetry-setup/dotnet.mdx index 27f9f735d5b0a..61b957ae0fbd1 100644 --- a/platform-includes/performance/opentelemetry-setup/dotnet.mdx +++ b/platform-includes/performance/opentelemetry-setup/dotnet.mdx @@ -6,11 +6,7 @@ To start tracing in a console application, you'll need to add Sentry to the trac ```csharp using var tracerProvider = Sdk.CreateTracerProviderBuilder() - .AddSource(serviceName) - .ConfigureResource(resource => - resource.AddService( - serviceName: serviceName, - serviceVersion: serviceVersion)) + .AddSource(serviceName) // <-- The name of an activity sources you care about .AddSentry() // <-- Configure OpenTelemetry to send traces to Sentry .Build(); ``` @@ -36,10 +32,8 @@ var builder = WebApplication.CreateBuilder(args); builder.Services.AddOpenTelemetry() .WithTracing(tracerProviderBuilder => tracerProviderBuilder - .AddSource(Telemetry.ActivitySource.Name) - .ConfigureResource(resource => resource.AddService(Telemetry.ServiceName)) - .AddAspNetCoreInstrumentation() - .AddHttpClientInstrumentation() + .AddAspNetCoreInstrumentation() // <-- Adds ASP.NET Core telemetry sources + .AddHttpClientInstrumentation() // <-- Adds HttpClient telemetry sources .AddSentry() // <-- Configure OpenTelemetry to send trace information to Sentry ); ``` @@ -61,13 +55,7 @@ To start tracing in an ASP.NET application, you'll need to create a tracer provi ```csharp var builder = Sdk.CreateTracerProviderBuilder() - .AddAspNetInstrumentation() - .AddSource(Telemetry.ServiceName) - .SetResourceBuilder( - ResourceBuilder.CreateDefault() - .AddService(serviceName: Telemetry.ServiceName, serviceVersion: "1.0.0") - ); - + .AddAspNetInstrumentation(); // <-- Adds ASP.NET telemetry sources ``` Next, initialize Sentry and opt into the use of OpenTelemetry. Provide the SDK with the builder for OpenTelemetry's tracer provider to allow sending spans to Sentry.