ILogger如何记录到Azure Application Insights?

问题描述 投票:2回答:2

在Azure功能中,当您启用遥测到Application Insight并触发(例如)logger.LogInformation调用(其中loggerILogger实例)时,它是否异步(即非阻塞)同步(阻塞)将其发送到Application Insight实例),或通过异步耗尽的本地日志?

azure azure-functions azure-application-insights
2个回答
2
投票

通常,记录器将被连接以将日志调用转换为Application Insights SDK中的各种trackMessage或相关调用。这些消息在AI端进行批处理,然后在满足消息的阈值计数后或在经过一定时间后发送。对应用程序见解的调用都是非阻塞的,并且不会抛出异常(您不希望遥测对您的真实应用产生负面影响!)

天蓝色函数将使用的c#sdks将在这里:https://github.com/Microsoft/ApplicationInsights-dotnet/

我通常在顶部说,因为所有这些都取决于SDK的配置方式,这取决于Azure功能底层代码。 GitHub和他们的信息在这里:https://github.com/Azure/Azure-Functions,他们有一个特定的wiki设置AI信息,这里:https://github.com/Azure/Azure-Functions/wiki/App-Insights


1
投票

这似乎是具体如何将数据发送到Application Insights的相关代码:

https://github.com/Microsoft/ApplicationInsights-dotnet/tree/develop/src/Microsoft.ApplicationInsights/Channel

ILogger包裹了一个TelemetryClient,它将数据发送到ITelemetryChannel

InMemoryTelemetryChannel包含如何汇总数据并将其发送到Application Insights的逻辑。正如John所说,该频道使用“缓冲区”来存储尚未发送的数据。当缓冲区已满或在内部特定时间(30秒)时,刷新缓冲区并将数据异步发送到Azure Portal。

© www.soinside.com 2019 - 2024. All rights reserved.