Skip to content

Commit f65f0c7

Browse files
Distributed Tracing for Java Azure Functions - Duplicate logs in AI issue (#8915)
* Do not send user generated logs to AI and quick pulse service if the worker AI agent is enabled.
1 parent 02b4afb commit f65f0c7

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

release_notes.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
- My change description (#PR)
55
-->
66
- Update Java Worker Version to [2.8.0](https://github.com/Azure/azure-functions-java-worker/releases/tag/2.8.0)
7-
87
- Track ApplicationInsights ingestion service response by subscribing to transmission event [PR](https://github.com/Azure/azure-functions-host/pull/8828)
98
- Update ApplicationInsights packages to 2.21.0 (#8838)
109
- Support model-type bindings for out-of-proc workers (#8815)
10+
- Fix the duplicate log issue with Java ApplicationInsights agent
1111
- Update Node.js Worker Version to [3.5.2](https://github.com/Azure/azure-functions-nodejs-worker/releases/tag/v3.5.2)
1212

13+
1314
**Release sprint:** Sprint 132
1415
[ [bugs](https://github.com/Azure/azure-functions-host/issues?q=is%3Aissue+milestone%3A%22Functions+Sprint+132%22+label%3Abug+is%3Aclosed) | [features](https://github.com/Azure/azure-functions-host/issues?q=is%3Aissue+milestone%3A%22Functions+Sprint+132%22+label%3Afeature+is%3Aclosed) ]

src/WebJobs.Script/ScriptHostBuilderExtensions.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,26 @@ internal static void ConfigureApplicationInsights(HostBuilderContext context, IL
411411
o.EnableDependencyTracking = false;
412412
});
413413
}
414+
415+
builder.Services.AddOptions<LoggerFilterOptions>().Configure<IEnvironment>((options, environment) =>
416+
{
417+
// Skip sending user generated logs to AI and QuickPulse if worker AI agent is configured, worker will send these logs to AI and Quickpulse service.
418+
if (environment.IsApplicationInsightsAgentEnabled())
419+
{
420+
options.AddFilter<ApplicationInsightsLoggerProvider>((category, logLevel) =>
421+
{
422+
// skip Function.<FunctionName>.User category
423+
if (!string.IsNullOrEmpty(category) && category.Length > 14 && category.EndsWith(".User", StringComparison.Ordinal))
424+
{
425+
return false;
426+
}
427+
else
428+
{
429+
return true;
430+
}
431+
});
432+
}
433+
});
414434
}
415435
}
416436

0 commit comments

Comments
 (0)