azure - Azure Function V4 (.net 6) - 自定义指标 - 跟踪事件未正确记录
问题描述
我创建了 Azure 函数 (HTTP) 并使用 HTTPClient 调用了另一个 HTTP 函数。例如:Function1 调用 Function2。在 Function1 中,我有循环并基于它(次数)Function2 被调用。
我有以下代码的 startup.cs 文件
var aiOptions = new
Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions();
aiOptions.EnableAdaptiveSampling = false;
aiOptions.EnableQuickPulseMetricStream = false;
aiOptions.InstrumentationKey = "xxxxxxxxxxxxxxxxxxxxx";
aiOptions.RequestCollectionOptions.TrackExceptions = true;
builder.Services.AddApplicationInsightsTelemetry(aiOptions);
并使用下面的代码 in 函数来获取遥测客户端
public Function1(TelemetryClient _TC)
{
this._telementryclient = _TC;
}
下面的代码存在于循环中。
var properties = new Dictionary<string, string>
{{"ID", "xxxxxxxx"}, {"ProductID", "xxxxxxxxx"}, {"Track", "Function1" }
};
var metrics = new Dictionary<string, double>
{{"Count", 1}, { "Status", 1}};
//// Send the event:
_telementryclient.TrackEvent("TableTest", properties, metrics);
问题是上面的代码循环运行了 10 次,但事件在 customevents 表中只记录了 6-7 行。
host.json:
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": false,
"maxTelemetryItemsPerSecond": 20
}
}
packages used:
Microsoft.Azure.WebJobs.Extensions.ApplicationInsights (1.0.0 preview2)
Microsoft.Azure.WebJobs.Logging.ApplicationInsights 3.0.27
Please suggest
解决方案
推荐阅读
- sql - 递归 CTE 以找到所有子级父级和深度的总计
- windows - 使用 Powershell 在 Windows 资源管理器中驱动高级搜索 - 如何通过管道将 Out-GridView 传输到 Windows 资源管理器?
- redux - Redux thunk 返回一个承诺而不是一个已解决的值
- python - 根据多列聚合函数的条件结果计算唯一记录
- c# - 系统生成数组
- gpu - GRAFANA 中的英特尔 GPU 利用率统计数据
- javascript - 如何为对象添加属性?(不能添加属性 x,对象在 x 处不可扩展)
- javascript - Formik InitialValues 不会更改为 Form React Native 的状态定义值
- java - 如何在迭代时添加到 HashMap 中的 ArrayList
- c - c 中 fscanf 循环的分段错误,CS50 拼写代码