本文整理汇总了C#中Microsoft.ApplicationInsights.TelemetryClient.TrackTrace方法的典型用法代码示例。如果您正苦于以下问题:C# TelemetryClient.TrackTrace方法的具体用法?C# TelemetryClient.TrackTrace怎么用?C# TelemetryClient.TrackTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.ApplicationInsights.TelemetryClient
的用法示例。
在下文中一共展示了TelemetryClient.TrackTrace方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Index
public ActionResult Index()
{
var tc = new TelemetryClient();
tc.TrackTrace("I made it to the home page", SeverityLevel.Error);
return View();
}
示例2: Get
// GET api/values/5
public string Get(int id)
{
var client = new TelemetryClient();
client.TrackTrace("trace");
return "value";
}
示例3: Index
public ActionResult Index()
{
ViewBag.Title = "Home Page";
var client = new TelemetryClient();
client.TrackTrace("trace");
return View();
}
示例4: UpdateSettings
public async Task UpdateSettings(string trainArguments = null, float? initialExplorationEpsilon = null, bool? isExplorationEnabled = null)
{
var token = Request.Headers["Authorization"];
if (token != ConfigurationManager.AppSettings[ApplicationMetadataStore.AKPassword])
throw new UnauthorizedAccessException();
var telemetry = new TelemetryClient();
try
{
telemetry.TrackTrace($"UpdateSettings(trainArguments={trainArguments}, initialExplorationEpsilon={initialExplorationEpsilon}, isExplorationEnabled={isExplorationEnabled})");
string azureStorageConnectionString = ConfigurationManager.AppSettings[ApplicationMetadataStore.AKConnectionString];
var storageAccount = CloudStorageAccount.Parse(azureStorageConnectionString);
var blobClient = storageAccount.CreateCloudBlobClient();
var settingsBlobContainer = blobClient.GetContainerReference(ApplicationBlobConstants.SettingsContainerName);
var blob = settingsBlobContainer.GetBlockBlobReference(ApplicationBlobConstants.LatestClientSettingsBlobName);
ApplicationClientMetadata clientMeta;
if (await blob.ExistsAsync())
clientMeta = JsonConvert.DeserializeObject<ApplicationClientMetadata>(await blob.DownloadTextAsync());
else
clientMeta = new ApplicationClientMetadata();
if (trainArguments != null)
clientMeta.TrainArguments = trainArguments;
if (initialExplorationEpsilon != null)
clientMeta.InitialExplorationEpsilon = (float)initialExplorationEpsilon;
if (isExplorationEnabled != null)
clientMeta.IsExplorationEnabled = (bool)isExplorationEnabled;
await blob.UploadTextAsync(JsonConvert.SerializeObject(clientMeta));
}
catch (Exception e)
{
telemetry.TrackException(e);
}
}
示例5: Main
static void Main(string[] args)
{
if (args.Length == 1)
{
TelemetryClient client = new TelemetryClient(TelemetryConfiguration.Active);
client.TrackTrace("One trace is sent to make sure that SDK is initialized.");
string param = args[0];
switch (param)
{
case "unhandled" :
GenerateUnhandledException();
break;
case "unobserved" :
GenerateUnobservedException(client);
break;
}
}
else
throw new ArgumentException("One parameter is required");
}
示例6: ReportLog
/// <summary>
/// Reports a log event to telemetry.
/// </summary>
/// <param name="eventName"></param>
/// <param name="metric"></param>
public void ReportLog(object component, string message, SeverityLevel level = SeverityLevel.Information)
{
TelemetryClient client = new TelemetryClient();
client.TrackTrace($"[{component.GetType().Name}] {message}", level);
}
示例7: TrackWhenChannelIsNullWillThrowInvalidOperationException
public void TrackWhenChannelIsNullWillThrowInvalidOperationException()
{
var config = new TelemetryConfiguration();
config.InstrumentationKey = "Foo";
var client = new TelemetryClient(config);
Assert.Throws<InvalidOperationException>(() => client.TrackTrace("test trace"));
}
示例8: TrackUsesInstrumentationKeyFromConfigurationWhenTheInstrumenationKeyIsEmpty
public void TrackUsesInstrumentationKeyFromConfigurationWhenTheInstrumenationKeyIsEmpty()
{
ITelemetry sentTelemetry = null;
var channel = new StubTelemetryChannel { OnSend = telemetry => sentTelemetry = telemetry };
var configuration = new TelemetryConfiguration { TelemetryChannel = channel };
var client = new TelemetryClient(configuration);
var observe = client.Context.InstrumentationKey;
string expectedKey = Guid.NewGuid().ToString();
configuration.InstrumentationKey = expectedKey;
Assert.DoesNotThrow(() => client.TrackTrace("Test Message"));
Assert.Equal(expectedKey, sentTelemetry.Context.InstrumentationKey);
}
示例9: TrackDoesNotInitializeInstrumentationKeyWhenItWasSetExplicitly
public void TrackDoesNotInitializeInstrumentationKeyWhenItWasSetExplicitly()
{
var configuration = new TelemetryConfiguration { TelemetryChannel = new StubTelemetryChannel(), InstrumentationKey = Guid.NewGuid().ToString() };
var client = new TelemetryClient(configuration);
var expectedKey = Guid.NewGuid().ToString();
client.Context.InstrumentationKey = expectedKey;
client.TrackTrace("Test Message");
Assert.Equal(expectedKey, client.Context.InstrumentationKey);
}