Below host.json affects log verbose but not the opentelemetry logs.
"logging": {
"logLevel": {
"DurableTask.AzureStorage": "Warning"
}
}
Implement a TelemetryProcessor to hide storage spans as shown below:
- Create a custom TelemetryProcessor class in the function project.
public class DurableStorage : ITelemetryProcessor
{
private ITelemetryProcessor Next { get; }
public DurableStorage(ITelemetryProcessor next)
{
Next = next;
}
public void Process(ITelemetry item)
{
{ if (dep.Type == "Azure table" && dep.Name.Contains("DurableTask"))
{ return;
}
if (dep.Data != null && dep.Data.Contains("DurableTask"))
{ return;
}
}
Next.Process(item);
}
}
- Register the TelemetryProcessor in program.cs:
var builder = FunctionsApplication.CreateBuilder(args);
builder.ConfigureFunctionsWebApplication();
builder.Services
.AddApplicationInsightsTelemetryWorkerService();
.ConfigureFunctionsApplicationInsights();
builder.Services.AddOptions<KestrelServerOptions>()
.Configure<IConfiguration>((settings, configuration) =>
{
settings.AllowSynchronousIO = true;
});
builder.Services.AddSingleton<ITelemetryProcessorFactory, FilterProcessorFactory>();
builder.Build().Run();
This will filter DependencyTelemetry with type Azure table Name or Data that contains"DurableTask".
You can use below Python Code Snippet to achieve the same:
from opencensus.ext.azure.trace_exporter import AzureExporter
from opencensus.trace.samplers import ProbabilitySampler
from opencensus.trace.tracer import Tracer
from opencensus.trace import execution_context
def telemetry_processor(envelope):
if envelope.name == "RemoteDependency" and "Table" in envelope.data.get("baseData", {}).get("type", ""):
return False
return True # Allow all other telemetry
exporter = AzureExporter(connection_string="InstrumentationKey=YOUR_KEY")
exporter.add_telemetry_processor(telemetry_processor)
tracer = Tracer(exporter=exporter, sampler=ProbabilitySampler(1.0))
execution_context.set_opencensus_attr("tracer", tracer)