Skip to content

Commit

Permalink
Update dotnet.mdx
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescrosswell committed Feb 11, 2024
1 parent 6995e5e commit 22fccbc
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions platform-includes/performance/opentelemetry-setup/dotnet.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
```
Expand All @@ -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
);
```
Expand All @@ -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.
Expand Down

0 comments on commit 22fccbc

Please sign in to comment.