Skip to main content
Version: v2.6.0

Telemetry Filters

Installation

This feature requires to install our NuGet package

PM > Install-Package Arcus.Observability.Telemetry.Serilog.Filters

Telemetry Type Filter

This Serilog filter allows you to filter out different a specific type of telemetry.

using Arcus.Observability.Telemetry.Core;
using Arcus.Observability.Telemetry.Serilog.Filters;
using Serilog.Core;
using Serilog.Configuration;

ILogger logger = new LoggerConfiguration()
.WriteTo.AzureApplicationInsights("<key>")
.Filter.With(TelemetryTypeFilter.On(TelemetryType.Events))
.CreateLogger();

The filter can also be used to reduce telemetry for multiple types by chaining them:

ILogger logger = new LoggerConfiguration()
.WriteTo.AzureApplicationInsights("<key>")
.Filter.With(TelemetryTypeFilter.On(TelemetryType.Events))
.Filter.With(TelemetryTypeFilter.On(TelemetryType.Dependency))
.CreateLogger();

Alternatively, you can explicitly specify if it should track telemetry or not based on the application configuration has to be tracked or not :

var trackDependencies = configuration["telemetry:dependencies:isEnabled"];
ILogger logger = new LoggerConfiguration()
.WriteTo.AzureApplicationInsights("<key>")
.Filter.With(TelemetryTypeFilter.On(TelemetryType.Dependency, isTrackingEnabled: bool.Parse(trackDependencies)))
.CreateLogger();