Hey guys, I don't know if it's a bug but we are having some issues and would like some help. What we are trying to achieve is the following:
We have an Azure Function that make use of Serilog and this sink to write into AppInsights, this function does some calls to Azure Blob and when container/blob does not exist we do not want to log the 404/409 dependencies trace (We have so many calls that are part of the business process).
This is the startup code of the function:
public class Startup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
var configuration = new ConfigurationBuilder()
.SetBasePath(Environment.CurrentDirectory)
.AddJsonFile("local.settings.json", true, true)
.AddEnvironmentVariables()
.Build();
var loggerConfiguration = new LoggerConfiguration();
loggerConfiguration.MinimumLevel.Warning();
loggerConfiguration.MinimumLevel.Override("Microsoft", LogEventLevel.Error);
loggerConfiguration.Enrich.FromLogContext();
loggerConfiguration.WriteTo.ApplicationInsights(configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"], new TraceTelemetryConverter(), LogEventLevel.Warning);
var logger = loggerConfiguration.CreateLogger();
builder.Services
.AddLogging(lb => lb.AddSerilog(logger))
.AddApplicationInsightsTelemetryProcessor<TelemetryStorageFilterProcessor>();
}
public class TelemetryStorageFilterProcessor : ITelemetryProcessor
{
private ITelemetryProcessor Next { get; set; }
private static readonly List<string> _dependencyTypes = new() { "azure table", "azure blob", "inproc | microsoft.storage", "microsoft.storage" };
public TelemetryStorageFilterProcessor(ITelemetryProcessor next)
{
Next = next;
}
public void Process(ITelemetry item)
{
if (item is DependencyTelemetry dependency
&& _dependencyTypes.Contains(dependency.Type.ToLower())
&& dependency.Success == false)
{
return;
}
Next.Process(item);
}
}
}
The Function have the following NuGet packages installed:
Hey guys, I don't know if it's a bug but we are having some issues and would like some help. What we are trying to achieve is the following:
We have an Azure Function that make use of Serilog and this sink to write into AppInsights, this function does some calls to Azure Blob and when container/blob does not exist we do not want to log the 404/409 dependencies trace (We have so many calls that are part of the business process).
This is the startup code of the function:
The Function have the following NuGet packages installed:
No matter how we register the processor, the 404/409 dependencies are still written in AppInsights. What are we doing wrong?