gpt4 book ai didi

azure-application-insights - 无需配置即可工作的应用程序洞察力

转载 作者:行者123 更新时间:2023-12-05 03:05:09 25 4
gpt4 key购买 nike

我正在构建一个使用 Application Insights 的小型库。

Application Insights 是否有可能在没有 ApplicationInsights.config 文件的情况下工作?

我尝试在构造函数中手动删除和添加模块,但没有成功。

已编辑

我做了类似的事情:

dependencies = new DependencyTrackingTelemetryModule();
dependencies.Initialize(configuration);

exceptionTelemetryModule = new UnhandledExceptionTelemetryModule();
exceptionTelemetryModule.Initialize(configuration);

unobservedExceptionTelemetry = new UnobservedExceptionTelemetryModule();
unobservedExceptionTelemetry.Initialize(configuration);

serverTelemetryChannel = new ServerTelemetryChannel();
serverTelemetryChannel.DeveloperMode = true;
serverTelemetryChannel.Initialize(configuration);

azureInstanceMetadataTelemetry = new AzureInstanceMetadataTelemetryModule();
azureInstanceMetadataTelemetry.Initialize(configuration);

var developer = new DeveloperModeWithDebuggerAttachedTelemetryModule();
developer.Initialize(configuration);

configuration.TelemetryInitializers.Add(new OperationCorrelationTelemetryInitializer());

client = new TelemetryClient(configuration);

最佳答案

可以像这样完成一个简约的设置。

using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.DependencyCollector;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel;

.. .. ..

  private static void setupApplicationInsights()
{
// Setup Channel, Initializers, and Sampling
// Nugets Required: "Microsoft.ApplicationInsights", "Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel"

var channel = new ServerTelemetryChannel();
var config = TelemetryConfiguration.Active;
config.InstrumentationKey = "putikey";

channel.Initialize(config);
TelemetryConfiguration.Active.TelemetryChannel = channel;

//Setup TelemetryInitializers...
config.TelemetryInitializers.Add(new OperationCorrelationTelemetryInitializer());

//Setup Sampling
config.TelemetryProcessorChainBuilder.UseAdaptiveSampling();

// Setup modules...
// Nugets : Microsoft.ApplicationInsights.DependencyCollector
DependencyTrackingTelemetryModule dep = new DependencyTrackingTelemetryModule();
dep.Initialize(config);

}

关于azure-application-insights - 无需配置即可工作的应用程序洞察力,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51308053/

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