我在应用程序中使用Azure服务(AppService、AppInsight)
此外,我还实现了我的项目int .net Core6,
我正在使用Microsoft.ApplicationInsights.AspNetCore
库(版本2.22.0
)
我在appsetting.json中的Application Insight配置如下所示
"ApplicationInsights": {
"ConnectionString": "InstrumentationKey=a91c943b-5268-42e1-80c3-dc03c5e9bf0c;IngestionEndpoint=https://easteurope.in.applicationinsights.azure.com/;LiveEndpoint=https://easteurope.livediagnostics.monitor.azure.com/"
}
我注册了Application insight服务,如下所示:
builder.Services.AddApplicationInsightsTelemetry();
我的准则是
private readonly TelemetryClient telemetryClient;
public SaveMetricsUseCase(TelemetryClient telemetryClient)
{
this.telemetryClient = telemetryClient;
}
...
private void SaveMetrics() {
telemetryClient.GetMetric("ProjectName.PromptTokens", "CategoryId", "Model", "UserId")
.TrackValue(input.Prompt, input.CategoryId, input.ModelName, input.UserId);
telemetryClient.GetMetric("ProjectName.CompletionTokens", "CategoryId", "Model", "UserId")
.TrackValue(input.Completion, input.CategoryId, input.ModelName, input.UserId);
}
每当我在AppService上部署我的更改时,自定义指标都会被正确保存,但在one hour之后,指标就会停止存储,并且我再也无法在App Insight门户中看到任何指标(其他日志(log)和异常都没有问题地保存在AppInsight中,只有指标不再存储)
Have you any idea what the problem might be?