首页 > 解决方案 > 找不到 TraceConfigruation 参考(StackDriver ASP.Net 设置)

问题描述

我正在按照为 C# ASP.NET 设置 StackDriver Trace 的设置说明进行操作。在“配置客户端库”部分中,第 3 步:在Global.asax.cs文件的WebApiApplication类中添加以下 Init 代码块以初始化跟踪:

public override void Init()
{
    string projectId = ConfigurationManager.AppSettings["projectId"];
    // ...
    base.Init();
    TraceConfiguration traceConfig = TraceConfiguration
        .Create(bufferOptions: BufferOptions.NoBuffer());
    CloudTrace.Initialize(this, projectId, traceConfig);
}

TraceConfiguration 对象在步骤 2 中引用的任何一个客户端库中都不存在:

using Google.Cloud.Diagnostics.AspNet;
using Google.Cloud.Diagnostics.Common;

我找不到对该对象的任何引用,并且似乎没有内置到 .net 框架中。

标签: asp.netstackdriver

解决方案


假设你正在使用这个:

https://cloud.google.com/trace/docs/setup/aspnet

如果我正确地遵循了这一点,我认为文档已经过时并且在一段时间前TraceConfiguration被替换:TraceOptions

https://github.com/googleapis/google-cloud-dotnet/pull/1120

和: TraceOptions

我会在 PR 上联系那些为这个库做出贡献的人,让我们看看我是否可以让他们帮助你——如果有必要——更正文档。


推荐阅读