Skip to content

Commit b8e03d4

Browse files
docs(dotnet): Use the OTLP exporter in the Azure Functions guide (#19959)
<!-- Keep the urgency section so automation can prioritize this PR. You may delete other sections you don't need. --> ## DESCRIBE YOUR PR The Azure Functions (isolated worker) guide sets up tracing with `TracerProviderBuilder.AddSentry()` and `SentryOptions.UseOpenTelemetry()` from `Sentry.OpenTelemetry`. Both have been obsolete since sentry-dotnet 6.12.0, so anyone following the guide gets obsolete warnings. The guide now uses the OTLP exporter, as the `Sentry.Samples.OpenTelemetry.AzureFunctions` sample does: - Install `Sentry.OpenTelemetry.Exporter` instead of `Sentry.OpenTelemetry`. `OpenTelemetry` is no longer listed because it comes in transitively. The Package Manager tab now lists the two OpenTelemetry packages it was missing. - `AddSentryOtlpExporter(dsn)` and `UseOtlp()` replace `AddSentry()` and `UseOpenTelemetry()`. The tracing sentence now links to the OpenTelemetry (OTLP) page. - The "enabling tracing" link under Features pointed at the generic tracing concepts page. It now goes to the .NET OpenTelemetry (OTLP) page too. Closes getsentry/sentry-dotnet#5715 ### Notes for review - The snippet drops `TracesSampleRate` and `DisableSentryHttpMessageHandler`, which the sample still sets. Under `UseOtlp()` Sentry creates no transactions of its own, so `TracesSampleRate` has no effect, and the OTLP page already says not to set it. `SentryHttpMessageHandler` already skips span creation under `UseOtlp()`. Against 6.12.1, an `IHttpClientFactory` request sent with the handler on still carries a single `sentry-trace` value, and it matches `traceparent`. - The snippet's error-monitoring-only variant didn't compile. `using OpenTelemetry;` and `using Sentry.OpenTelemetry;` sat outside the performance block, but only the performance option installs those packages. Neither is needed now: `AddSentryOtlpExporter` lives in `OpenTelemetry.Trace`, and `UseOtlp` lives in `Sentry`, which the SDK adds as an implicit using. The snippet now includes `using Microsoft.Extensions.DependencyInjection;`, which `AddOpenTelemetry()` needs. - Both variants of the snippet compile without warnings against Sentry 6.12.1, using the Functions template's `ImplicitUsings`. - #19925 (merges at 7.0.0 GA) makes the same OTLP changes on this page, and also moves the options into `SentrySdk.Init`. When it merges `master` it will conflict in the `logging.AddSentry` block and on the tracing sentence. That sentence is reworded here into active voice. ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. Select exactly one option. For deadlines, replace `YYYY-MM-DD` with the due date. You can update this information later by editing the PR description. - [ ] Urgent deadline (GA date, etc.): YYYY-MM-DD - [ ] Other deadline: YYYY-MM-DD - [x] No deadline: Not urgent, can wait up to 1 week+ 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 136020d commit b8e03d4

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

  • docs/platforms/dotnet/guides/azure-functions-worker

‎docs/platforms/dotnet/guides/azure-functions-worker/index.mdx‎

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ sdk: sentry.dotnet.azure.functions.worker
44
description: "Learn about Sentry's .NET integration with Azure Functions."
55
---
66

7-
Sentry provides an integration with Azure Functions through the [Sentry.Extensions.Logging](https://www.nuget.org/packages/Sentry.Extensions.Logging) and [Sentry.OpenTelemetry](https://www.nuget.org/packages/Sentry.OpenTelemetry) NuGet packages.
7+
Sentry provides an integration with Azure Functions through the [Sentry.Extensions.Logging](https://www.nuget.org/packages/Sentry.Extensions.Logging) and [Sentry.OpenTelemetry.Exporter](https://www.nuget.org/packages/Sentry.OpenTelemetry.Exporter) NuGet packages.
88

99
## Features
1010

11-
In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/).
11+
In addition to capturing errors, you can monitor interactions between multiple services or applications by <PlatformLink to="/tracing/instrumentation/opentelemetry-otlp/">enabling tracing</PlatformLink>.
1212

1313
Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below.
1414

@@ -21,8 +21,7 @@ Add the Sentry dependencies to your Azure Functions application:
2121
```shell {tabTitle:.NET Core CLI}
2222
dotnet add package Sentry.Extensions.Logging -v {{@inject packages.version('sentry.dotnet.extensions.logging') }}
2323
// ___PRODUCT_OPTION_START___ performance
24-
dotnet add package Sentry.OpenTelemetry -v {{@inject packages.version('sentry.dotnet.opentelemetry') }}
25-
dotnet add package OpenTelemetry
24+
dotnet add package Sentry.OpenTelemetry.Exporter -v {{@inject packages.version('sentry.dotnet') }}
2625
dotnet add package OpenTelemetry.Extensions.Hosting
2726
dotnet add package OpenTelemetry.Instrumentation.Http
2827

@@ -32,7 +31,9 @@ dotnet add package OpenTelemetry.Instrumentation.Http
3231
```powershell {tabTitle:Package Manager}
3332
Install-Package Sentry.Extensions.Logging -Version {{@inject packages.version('sentry.dotnet.extensions.logging') }}
3433
// ___PRODUCT_OPTION_START___ performance
35-
Install-Package Sentry.OpenTelemetry -Version {{@inject packages.version('sentry.dotnet.opentelemetry') }}
34+
Install-Package Sentry.OpenTelemetry.Exporter -Version {{@inject packages.version('sentry.dotnet') }}
35+
Install-Package OpenTelemetry.Extensions.Hosting
36+
Install-Package OpenTelemetry.Instrumentation.Http
3637
// ___PRODUCT_OPTION_END___
3738
```
3839

@@ -43,19 +44,18 @@ The [Sentry.Extensions.Logging](/platforms/dotnet/guides/extensions-logging/) pa
4344
The core features of Sentry are enabled by calling `AddSentry` when configuring logging.
4445

4546
<OnboardingOption optionId="performance">
46-
Performance tracing can be enabled by adding Sentry to the OpenTelemetry `TracerProviderBuilder` and then configuring Sentry itself to use OpenTelemetry.
47+
To enable tracing, add Sentry's OTLP exporter to the OpenTelemetry `TracerProviderBuilder` and call `UseOtlp()` on the Sentry options. See <PlatformLink to="/tracing/instrumentation/opentelemetry-otlp/">OpenTelemetry (OTLP)</PlatformLink> for sampling and trace propagation.
4748
</OnboardingOption>
4849

4950
For example:
5051

5152
```csharp
5253
using Microsoft.Extensions.Hosting;
5354
using Microsoft.Extensions.Logging;
54-
using OpenTelemetry;
5555
// ___PRODUCT_OPTION_START___ performance
56+
using Microsoft.Extensions.DependencyInjection;
5657
using OpenTelemetry.Trace;
5758
// ___PRODUCT_OPTION_END___
58-
using Sentry.OpenTelemetry;
5959
6060
var host = new HostBuilder()
6161
.ConfigureFunctionsWorkerDefaults()
@@ -65,7 +65,7 @@ var host = new HostBuilder()
6565
services.AddOpenTelemetry().WithTracing(builder =>
6666
{
6767
builder
68-
.AddSentry() // <-- Configure OpenTelemetry to send traces to Sentry
68+
.AddSentryOtlpExporter("___PUBLIC_DSN___") // <-- Send traces to Sentry over OTLP
6969
.AddHttpClientInstrumentation(); // From OpenTelemetry.Instrumentation.Http, instruments outgoing HTTP requests
7070
});
7171
})
@@ -76,16 +76,13 @@ var host = new HostBuilder()
7676
{
7777
options.Dsn = "___PUBLIC_DSN___";
7878
// ___PRODUCT_OPTION_START___ performance
79-
options.TracesSampleRate = 1.0;
80-
options.UseOpenTelemetry(); // <-- Configure Sentry to use open telemetry
81-
options.DisableSentryHttpMessageHandler = true; // So Sentry doesn't also create spans for outbound HTTP requests
79+
options.UseOtlp(); // <-- Configure Sentry to use OpenTelemetry for tracing
8280
// ___PRODUCT_OPTION_END___
8381
options.Debug = true;
8482
});
8583
})
8684
.Build();
8785

88-
8986
await host.RunAsync();
9087
```
9188

0 commit comments

Comments
 (0)