请求遥测:Application Insights 数据模型Request telemetry: Application Insights data model

Application Insights 中的请求遥测项表示由应用程序的外部请求触发的执行的逻辑序列。A request telemetry item (in Application Insights) represents the logical sequence of execution triggered by an external request to your application. 每个请求执行由包含所有执行参数的唯一 IDurl 标识。Every request execution is identified by unique ID and url containing all the execution parameters. 可以按逻辑 name 将请求分组,并定义此请求的 sourceYou can group requests by logical name and define the source of this request. 代码执行的结果可能是 successfail,并且具有特定的 durationCode execution can result in success or fail and has a certain duration. 可以进一步根据 resultCode 将成功和失败的执行分组。Both success and failure executions may be grouped further by resultCode. 请求遥测的开始时间在信封级别定义。Start time for the request telemetry defined on the envelope level.

请求遥测使用自定义的 propertiesmeasurements 支持标准可扩展性模型。Request telemetry supports the standard extensibility model using custom properties and measurements.

名称Name

请求的名称表示用于处理该请求的代码路径。Name of the request represents code path taken to process the request. 较小的基数值对请求分组更有利。Low cardinality value to allow better grouping of requests. 对于 HTTP 请求,该名称表示 HTTP 方法和 URL 路径模板,例如,不带实际 id 值的 GET /values/{id}For HTTP requests it represents the HTTP method and URL path template like GET /values/{id} without the actual id value.

在字母大小写方面,Application Insights Web SDK 会“按原样”发送请求名称。Application Insights web SDK sends request name "as is" with regards to letter case. UI 上的分组区分大小写,因此 GET /Home/Index 被视为不同于 GET /home/INDEX,即使两者通常生成相同的控制器和操作执行。Grouping on UI is case-sensitive so GET /Home/Index is counted separately from GET /home/INDEX even though often they result in the same controller and action execution. 原因在于,URL 往往区分大小写The reason for that is that urls in general are case-sensitive. 可能想要确定所有 404 是否发生在以大写形式键入的 URL 上。You may want to see if all 404 happened for the urls typed in uppercase. 可在该博客文章中详细了解 ASP.NET Web SDK 如何处理请求名称集合。You can read more on request name collection by ASP.NET Web SDK in the blog post.

最大长度:1024 个字符Max length: 1024 characters

IDID

请求调用实例的标识符。Identifier of a request call instance. 用于在请求与其他遥测项之间建立关联。Used for correlation between request and other telemetry items. ID 应该全局唯一。ID should be globally unique. 有关详细信息,请参阅关联页。For more information, see correlation page.

最大长度:128 个字符Max length: 128 characters

URLUrl

包含所有查询字符串参数的请求 URL。Request URL with all query string parameters.

最大长度:2048 个字符Max length: 2048 characters

Source

请求的源。Source of the request. 示例包括调用方的检测密钥或调用方的 IP 地址。Examples are the instrumentation key of the caller or the ip address of the caller. 有关详细信息,请参阅关联页。For more information, see correlation page.

最大长度:1024 个字符Max length: 1024 characters

DurationDuration

请求持续时间,格式为:DD.HH:MM:SS.MMMMMMRequest duration in format: DD.HH:MM:SS.MMMMMM. 必须是正数且小于 1000 天。Must be positive and less than 1000 days. 此字段是必填的,因为请求遥测表示具有开始和结束时间的操作。This field is required as request telemetry represents the operation with the beginning and the end.

响应代码Response code

请求执行的结果。Result of a request execution. HTTP 请求的 HTTP 状态代码。HTTP status code for HTTP requests. 它可能是 HRESULT 值,或者其他请求类型的异常类型。It may be HRESULT value or exception type for other request types.

最大长度:1024 个字符Max length: 1024 characters

SuccessSuccess

指示调用成功还是失败。Indication of successful or unsuccessful call. 此字段是必填的。This field is required. 如果未显式设置为 false - 将请求视为成功。When not set explicitly to false - a request is considered to be successful. 如果操作被异常中断或者返回错误结果代码,请将此值设置为 falseSet this value to false if operation was interrupted by exception or returned error result code.

对于 Web 应用程序,如果响应代码小于 400 或等于 401,Application Insights 会将请求定义为成功。For the web applications, Application Insights define a request as successful when the response code is less than 400 or equal to 401. 但是,在某些情况下,此默认映射与应用程序的语义不匹配。However there are cases when this default mapping does not match the semantic of the application. 响应代码 404 可能指示“无记录”,这可能是常规流的一部分。Response code 404 may indicate "no records", which can be part of regular flow. 它也可能指示链接断开。It also may indicate a broken link. 对于断开的链接,甚至可以实现更高级的逻辑。For the broken links, you can even implement more advanced logic. 仅当通过分析 URL 引用站点确定这些断开的链接位于同一站点时,才可以将这些链接标记为失败。You can mark broken links as failures only when those links are located on the same site by analyzing url referrer. 或者,在从公司的移动应用程序访问这些链接时,可将其标记为失败。Or mark them as failures when accessed from the company's mobile application. 同样,在从不支持重定向的客户端访问这些链接时,301302 将指示失败。Similarly 301 and 302 indicates failure when accessed from the client that doesn't support redirect.

部分接受的内容 206 可能指示整个请求失败。Partially accepted content 206 may indicate a failure of an overall request. 例如,Application Insights 终结点以单个请求的形式接收一批遥测项。For instance, Application Insights endpoint receives a batch of telemetry items as a single request. 未成功处理该批中的某些项时,该终结点将返回 206It returns 206 when some items in the batch were not processed successfully. 206 比率提高指示出现了需要调查的问题。Increasing rate of 206 indicates a problem that needs to be investigated. 类似的逻辑适用于 207 多状态,其中的成功结果可能是不同响应代码的最差结果。Similar logic applies to 207 Multi-Status where the success may be the worst of separate response codes.

可在该博客文章中详细了解请求结果代码和状态代码。You can read more on request result code and status code in the blog post.

自定义属性Custom properties

自定义属性的名称-值集合。Name-value collection of custom properties. 该集合用于通过自定义维度来扩展标准遥测。This collection is used to extend standard telemetry with the custom dimensions. 示例为部署槽,该槽生成特定于遥测或遥测项的属性,例如订单号。Examples are deployment slot that produced telemetry or telemetry-item specific property like order number.

最大密钥长度:150 最大值长度:8192Max key length: 150 Max value length: 8192

自定义度量值Custom measurements

自定义度量值的集合。Collection of custom measurements. 使用此集合报告与遥测项关联的命名度量值。Use this collection to report named measurement associated with the telemetry item. 典型用例如下:Typical use cases are:

  • 依赖项遥测有效负载的大小the size of Dependency Telemetry payload
  • 由请求遥测处理的队列项数the number of queue items processed by Request Telemetry
  • 客户完成向导步骤完成事件遥测中的步骤所花的时间。time that customer took to complete the step in wizard step completion Event Telemetry.

可以在 Application Analytics 中查询自定义度量值You can query custom measurements in Application Analytics:

customEvents
| where customMeasurements != ""
| summarize avg(todouble(customMeasurements["Completion Time"]) * itemCount)

备注

与所属遥测项关联的自定义度量值。Custom measurements are associated with the telemetry item they belong to. 这些度量值可以通过遥测项(包含这些度量值)采样。They are subject to sampling with the telemetry item containing those measurements. 使用指标遥测跟踪其值独立于其他遥测类型的度量值。To track a measurement that has a value independent from other telemetry types, use Metric telemetry.

最大密钥长度:150Max key length: 150

后续步骤Next steps