【问题标题】:Why do Dialog classes have a TelemetryClient property?为什么 Dialog 类有 TelemetryClient 属性?
【发布时间】:2019-10-07 19:16:14
【问题描述】:

Microsoft Bot Framework 中的 Dialog 类有一个名为 TelemetryClient 的属性。此属性用于存储对话的特定遥测客户端。

我想知道遥测客户端在对话类中进行了什么样的日志记录?这个属性是如何使用的?

Javascript:

https://docs.microsoft.com/en-us/javascript/api/botbuilder-dialogs/dialog?view=botbuilder-ts-latest#telemetryclient

C#:

https://docs.microsoft.com/en-us/dotnet/api/microsoft.bot.builder.dialogs.dialog.telemetryclient?view=botbuilder-dotnet-stable#Microsoft_Bot_Builder_Dialogs_Dialog_TelemetryClient

该属性可能仅用于控制对话框级别的日志记录。那个存在;遥测客户端属性只能由日志中间件访问。我查看了 Dialog 对象构造和 ComponentDialog 构造的 javascript 源代码。我的发现支持了这个假设,因为我只发现了赋值和访问逻辑。

【问题讨论】:

    标签: javascript c# node.js botframework


    【解决方案1】:

    对话框具有 TelemetryClient 类通过显示最常用的功能、检测不需要的行为并提供对可用性、性能和使用情况的可见性来深入了解您的机器人。遥测日志记录使机器人应用程序能够将事件数据发送到遥测服务,例如 Application Insights。

    • TelemetryLoggerMiddleware、TelemetryLuisRecognizer、TelemetryQnAMaker 和 SkillConfiguration 使用 Microsoft.ApplicationInsights.TelemetryClient。建议从依赖注入容器中获取 TelemetryClient 的实例。 TelemetryClient 是线程安全的。 TelemetryClient 类将事件、指标和其他遥测数据发送到 Application Insights 服务。 TelemetryClient() 初始化 TelemetryClient 类的新实例。您可以使用活动配置发送遥测数据,通常从 ApplicationInsights.config 加载。

    • TelemetryClient 实例用于报告自动生成的遥测数据。用于发送所有类型遥测的遥测客户端。 它是与 Application Insights 服务交互的主要入口点。使用 .UseApplicationInsights() 或 AddApplicationInsights() 方法配置 Application Insights 时,TelemetryClient 会自动注入 DI。您可以使用构造函数注入来获取 TelemetryClient 实例。 Application Insights 遥测客户端有一个内存缓冲区和一个刷新间隔(默认为 1 分钟),用于将缓冲的遥测数据发送到 AI 端点。

    Bot Framework 提供 TelemetryClient,但也允许用户提供自己的,以便他们可以更改记录的内容。

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 2017-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-09
      • 1970-01-01
      • 2018-04-28
      • 2021-12-26
      • 1970-01-01
      相关资源
      最近更新 更多