gpt4 book ai didi

azure - 在 azure 应用程序洞察中,记录长 JSON 会被修剪

转载 作者:行者123 更新时间:2023-12-03 00:47:21 24 4
gpt4 key购买 nike

我的目标是使用 azure 应用程序洞察记录用户请求,请求将转换为 JSON 格式然后保存。

有时,用户请求可能会很长,并且会在 Azure 应用程序洞察 View 中被修剪,从而导致无效的 JSON。

CustomDimensions下面,它看起来像:

trimmed json

我正在使用 Microsoft.ApplicationInsights.TelemetryClient 命名空间。

这是我的代码:

var properties = new Dictionary<string, string>
{
{ "RequestJSON", requestJSON }
};
TelemetryClientInstance.TrackTrace("some description", SeverityLevel.Verbose, properties);

我引用这个重载:

public void TrackTrace(string message, SeverityLevel severityLevel, IDictionary<string, string> properties);

最佳答案

根据 Trace telemetry: Application Insights data model ,对于 Custom Properties最大值长度为 8192

就您而言,它超出了限制。

我能想到两种解决方案:

1.使用TrackTrace方法时,将requestJSON写入message字段。 trace message 最大长度为32768个字符,可能满足您的需求。

2.当requestJSON的长度大于8192时,将requestJSON拆分为1个以上的自定义属性。例如,如果requestJSON的长度为2*8192,则可以添加2个自定义属性: property RequestJSON_1 存储前 8192 数据,属性 RequestJSON_2 存储剩下的 8192 数据。

使用解决方案 2 时,您可以轻松使用 Kusto queryproperty RequestJSON_1property RequestJSON_2 连接在一起,这样您就可以得到完整的/有效的 json 数据。

关于azure - 在 azure 应用程序洞察中,记录长 JSON 会被修剪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60090214/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com