View on GitHub

Arcus Observability

Observability development in Azure with a breeze

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.

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:depenencies:isEnabled"];
ILogger logger = new LoggerConfiguration()
    .WriteTo.AzureApplicationInsights("<key>")
    .Filter.With(TelemetryTypeFilter.On(TelemetryType.Dependency, isTrackingEnabled: bool.Parse(trackDependencies)))
    .CreateLogger();

← back