寻找请求和依赖调用

huangapple go评论57阅读模式
英文:

Finding requests and the dependency call

问题

如果一切设置正确以记录来自asp.net核心应用程序的请求的sql调用,我正在尝试查看与给定sql调用关联的asp.net控制器的请求。然而,我不确定连接条件。我应该连接到依赖项的operation_parentId和请求的operationId吗?如果这样做,我什么都得不到。依赖项和调用它的请求之间的“关联”是什么?

例如,像这样:

// 使用operationId连接
requests 
| where timestamp > start_time and timestamp < end_time
| join (dependencies
        | where ['type'] == "SQL" and data has "some-field-name-here" 
        ) on operation_Id

// 使用parentid连接 ????
requests 
| where timestamp > start_time and timestamp < end_time
| join (dependencies
        | where ['type'] == "SQL" and data has "some-field-name-here" 
        ) on $left.operation_Id = $right.operationParentId

第二个查询什么都没有给我,但是如果我查看据称制作了该关联sql调用的代码的第一个查询的请求,我会发现在该请求的关联方法中没有会进行该sql调用的语句。我漏掉了什么?

英文:

Assuming things are setup correctly to log sql calls on requests from an asp.net core app, Im trying to see the request from an asp.net controller that was associated with a given sql call. However, Im not sure on the join condition. Should I join on operation_parentId of the dependency to the operationId of the request? If I do, I get nothing. What is the "tie" between the dependency and the request that called it?

eg. Something like this

// join on operationid
    requests 
    |where timestamp &gt; start_time and timestamp &lt; end_time
    | join (dependencies
            | where [&#39;type&#39;] == &quot;SQL&quot; and data has &quot;some-field-name-here&quot; 
            ) on operation_Id
	
//join on parentid ????		
    requests 
    |where timestamp &gt; start_time and timestamp &lt; end_time
    | join (dependencies
            | where [&#39;type&#39;] == &quot;SQL&quot; and data has &quot;some-field-name-here&quot; 
            ) on $left.operation_Id = $right.operationParentId

The 2nd query gives me nothing, but the requests in the 1st query, if I look at the code that supposedly made the associated sql call, there is no statements that in the associated method of that request that would have made that sql call. What am I missing?

答案1

得分: 1

以下是翻译好的部分:

获取所有相关遥测项的最简单方法是通过连接operation_Id来完成,就像你所做的那样。但请注意可能会有一些嵌套。假设我们有以下情况:

  • API控制器
    • 某些依赖项
      • SQL依赖项
    • 其他一些依赖项

使用你的查询,你将看不到包含生成“Sql依赖项”的代码的“某些依赖项”,因为你过滤掉了所有不属于“SQL”类型的遥测项。

你还可以使用Idoperation_ParentId遍历树形结构。例如,要获取第一级依赖项(“某些依赖项”和“其他一些依赖项”),你可以这样做:

requests 
    |where timestamp > start_time and timestamp < end_time
    | join (dependencies
            | where ['type'] == "SQL" and data has "some-field-name-here" 
            ) on $left.id == $right.operationParentId

在这里是有关遥测关联数据模型的文档。

英文:

The easiest way of getting all the related telemetry items is by joining on the operation_Id like you did. But be aware there might be some nesting. Lets assume that we have the following situation:

  • API Controller
    • Some Dependency
      • Sql Dependency
    • Some Other Dependency

With your query you won't see the "Some dependency" that contains the code that generates the "Sql Dependency" because you filtered out all telemetry not of type "SQL".

You can also walk throught the tree using the Id and operation_ParentId. For example, to get the first level dependencies ("Some Dependency" & "Some Other Dependency") you do:

requests 
    |where timestamp &gt; start_time and timestamp &lt; end_time
    | join (dependencies
            | where [&#39;type&#39;] == &quot;SQL&quot; and data has &quot;some-field-name-here&quot; 
            ) on $left.id == $right.operationParentId

Here are the docs regarding the data model of the correlation.

huangapple
  • 本文由 发表于 2023年4月17日 21:42:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/76035816.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定