Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure functions and extensions logger #7000

Merged
merged 10 commits into from
May 28, 2023
2 changes: 2 additions & 0 deletions src/platforms/dotnet/guides/azure-functions-worker/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title: Azure Functions Isolated Worker
SeanFeldman marked this conversation as resolved.
Show resolved Hide resolved
sdk: sentry.dotnet.azurefunctions.worker
47 changes: 47 additions & 0 deletions src/platforms/dotnet/guides/azure-functions-worker/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
title: Azure Functions Isolated Worker
SeanFeldman marked this conversation as resolved.
Show resolved Hide resolved
description: "Learn about Sentry's .NET integration with Azure Functions Isolated Worker."
SeanFeldman marked this conversation as resolved.
Show resolved Hide resolved
---

Sentry provides an integration with Azure Functions Isolated Worker through the [Sentry.AzureFunctions.Worker NuGet package](https://www.nuget.org/packages/Sentry.AzureFunctions.Worker).
SeanFeldman marked this conversation as resolved.
Show resolved Hide resolved
All triggers are supported.

## Install

Add the Sentry dependency:
SeanFeldman marked this conversation as resolved.
Show resolved Hide resolved

```powershell {tabTitle:Package Manager}
Install-Package Sentry.AzureFunctions.Worker -Version {{@inject packages.version('sentry.dotnet.azurefunctions.worker') }}
```

```shell {tabTitle:.NET Core CLI}
dotnet add package Sentry.AzureFunctions.Worker -v {{@inject packages.version('sentry.dotnet.azurefunctions.worker') }}
```
SeanFeldman marked this conversation as resolved.
Show resolved Hide resolved

You can combine this integration with a logging library like `log4net`, `NLog`, or `Serilog`. The logging integration also capture events when an error is logged.

SeanFeldman marked this conversation as resolved.
Show resolved Hide resolved
### Configuring
SeanFeldman marked this conversation as resolved.
Show resolved Hide resolved

All `ASP.NET Core` configurations are valid here. But one configuration in particular is relevant.

`FlushOnCompletedRequest` ensures all events are flushed out. This is because the general ASP.NET Core hooks for when the process is exiting are not guaranteed to run in a serverless environment. This setting ensures that no event is lost if AWS recycles the process.
SeanFeldman marked this conversation as resolved.
Show resolved Hide resolved

```csharp
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults((host, builder) =>
{
builder.UseSentry(host, options =>
{
// o.Dsn = "<DSN>";
SeanFeldman marked this conversation as resolved.
Show resolved Hide resolved
options.EnableTracing = true;
// When configuring for the first time, to see what the SDK is doing:
// options.Debug = true;
});
})
.Build();
await host.RunAsync();
```

## Samples

- [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#**)
4 changes: 4 additions & 0 deletions src/platforms/dotnet/guides/extensions-logging/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ Whether or not this integration should initialize the SDK. If you intend to call

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.

#### TagFilters

A list of filters which are invoked before processing any log message to filter out undesired tags.

SeanFeldman marked this conversation as resolved.
Show resolved Hide resolved
### Samples

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