Skip to content

Commit 9c96348

Browse files
SeanFeldmanlizokmmattjohnsonpint
authored
Azure functions and extensions logger (#7000)
* Document TagFilters * Azure Functions isolated worker SDK * Apply suggestions from code review Co-authored-by: Liza Mock <lizka920@gmail.com> * Update index.mdx Remove unnecessary asp.net core verbage * Apply suggestions from code review Co-authored-by: Matt Johnson-Pint <mattjohnsonpint@gmail.com> * Add a tag filter example * Swap configuration samples order * Update src/platforms/dotnet/guides/extensions-logging/index.mdx * Update src/platforms/dotnet/guides/extensions-logging/index.mdx * lint --------- Co-authored-by: Liza Mock <lizka920@gmail.com> Co-authored-by: Matt Johnson-Pint <mattjohnsonpint@gmail.com> Co-authored-by: Matt Johnson-Pint <matt.johnson-pint@sentry.io>
1 parent beb45e0 commit 9c96348

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
title: Azure Functions
2+
sdk: sentry.dotnet.azurefunctions.worker
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
title: Azure Functions (Isolated Worker)
3+
description: "Learn about Sentry's .NET integration with Azure Functions."
4+
---
5+
6+
Sentry provides an integration with Azure Functions through the [Sentry.AzureFunctions.Worker NuGet package](https://www.nuget.org/packages/Sentry.AzureFunctions.Worker).
7+
All triggers are supported.
8+
9+
## Install
10+
11+
Add the Sentry dependency to your Azure Functions application:
12+
13+
```shell {tabTitle:.NET Core CLI}
14+
dotnet add package Sentry.AzureFunctions.Worker -v {{@inject packages.version('sentry.dotnet.azurefunctions.worker') }}
15+
```
16+
17+
```powershell {tabTitle:Package Manager}
18+
Install-Package Sentry.AzureFunctions.Worker -Version {{@inject packages.version('sentry.dotnet.azurefunctions.worker') }}
19+
```
20+
21+
This package extends [Sentry.Extensions.Logging](/platforms/dotnet/guides/extensions-logging/). This means that besides the Azure Functions related features, through this package you'll also get access to the `ILogger<T>` integration and also the features available in the main [Sentry](/platforms/dotnet/) SDK.
22+
23+
## Configure
24+
25+
Sentry integration with Azure Functions (when using the Isolated Worker Process execution mode) is done by calling `.UseSentry()` and specifying the options. E.g.:
26+
27+
```csharp
28+
var host = new HostBuilder()
29+
.ConfigureFunctionsWorkerDefaults((host, builder) =>
30+
{
31+
builder.UseSentry(host, options =>
32+
{
33+
options.Dsn = "___PUBLIC_DSN___";
34+
options.EnableTracing = true;
35+
// When configuring for the first time, to see what the SDK is doing:
36+
// options.Debug = true;
37+
});
38+
})
39+
.Build();
40+
await host.RunAsync();
41+
```
42+
43+
## Samples
44+
45+
- [Integration with Azure Functions](https://github.com/getsentry/sentry-dotnet/tree/main/src/Sentry.AzureFunctions.Worker) sample demonstrates Sentry with Azure Functions Isolated Worker SDK. (**C#**)

src/platforms/dotnet/guides/extensions-logging/index.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,16 @@ Whether or not this integration should initialize the SDK. If you intend to call
150150

151151
A list of filters which are invoked before processing any log message. This allows you to inspect the details of the log entry before they become a `Breadcrumb` or an `Event` with full access to the `Microsoft.Extensions.Logging` data.
152152

153+
#### TagFilters
154+
155+
A list of filters which are invoked before processing any log message to filter out undesired tags.
156+
157+
For example, to remove all tags starting with `PROC_`, add a tag filter to your `SentryOptions` when initializing the SDK.
158+
159+
```csharp
160+
options.TagFilters.Add("PROC_");
161+
```
162+
153163
### Samples
154164

155165
- A [simple example](https://github.com/getsentry/sentry-dotnet/tree/main/samples/Sentry.Samples.ME.Logging) using simply the `LoggerFactory`.

0 commit comments

Comments
 (0)