我正在实现自定义 ApplicationInsights 记录器,并且能够在跟踪、异常和请求等写入位置写入所有日志,但跟踪和异常中的 OperationId 为空。
昨天我使用相同的代码并在所有表中获取 OperationId。之后我在玩多线程场景,效果不佳。现在我用简单的代码重新开始,但看不到 OperationId。
我的代码有什么问题?
public static class Function2
{
private static TelemetryClient telemetryClient = new TelemetryClient(new Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration
{
InstrumentationKey = "********-****-********-****"
});
[FunctionName("Function2")]
public static HttpResponseMessage Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)]HttpRequestMessage req)
{
RequestTelemetry requestTelemetry = new RequestTelemetry { Name = "Function2" };
var operation = telemetryClient.StartOperation(requestTelemetry);
telemetryClient.TrackTrace("trace message", SeverityLevel.Error);
telemetryClient.TrackException(new System.Exception("My custom exception"));
operation.Telemetry.Success = true;
telemetryClient.StopOperation(operation);
return req.CreateResponse(HttpStatusCode.OK, "Hello ");
}
}
Run Code Online (Sandbox Code Playgroud) 我在 Visual Studio 2019 中发布 azure 函数时收到以下警告。
无法评估扩展元数据的“Cosmos.CRTCompat.dll”。异常消息:IL 格式错误。无法评估扩展元数据的“Microsoft.Azure.Documents.ServiceInterop.dll”。异常消息:IL 格式错误。
我在一个空白项目中尝试了相同的操作,但出现了相同的警告。
我在 VS Code 中看到同样的问题
C:\Users\pankaj.ra.nuget\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.1.5\build\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets(63,5):警告:无法评估“Cosmos.CRTCompat.dll”以获取扩展元数据。异常消息:IL 格式错误。
我的函数项目文件
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventHubs" Version="4.1.1" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.5" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud) 我正在使用SQL API使用CosmosDB,并且试图合并两个集合。我在文档中看到了join示例,但没有得到实际的外观。
请求日志
{
"DateTimeStamp": "2018-03-16T10:56:52.1411006Z",
"RequestId": "8ce80648-66e2-4357-98a8-7a71e8b65301",
"IPAddress": "0.0.0.173"
}
Run Code Online (Sandbox Code Playgroud)
响应日志
{
"DateTimeStamp": "2018-03-16T10:56:52.1411006Z",
"RequestId": "8ce80648-66e2-4357-98a8-7a71e8b65301",
"Body": "Hello"
}
Run Code Online (Sandbox Code Playgroud)
是否可以同时加入这两个系列?怎么样?
我知道GC有3(0,1,2)代,但我想知道GC如何决定变量的生成?
我认为所有变量都进入第0代,经过一段时间后转移到第1代和第2代.对于GC来说,决定生成是否重要?
PROGRAM1:
private static void Main(string[] args)
{
int a = 0;
string name = "Test";
var byteArray = new byte[10];
byteArray[4] = 4;
Console.WriteLine($"Generation of array {GC.GetGeneration(byteArray)}");
Console.WriteLine($"Generation of local int variable {GC.GetGeneration(a)}");
Console.WriteLine($"Generation of local string variable {GC.GetGeneration(name)}");
}
Run Code Online (Sandbox Code Playgroud)
结果
Generation of array 0
Generation of local int variable 0
Generation of local string variable 0
Run Code Online (Sandbox Code Playgroud)
程序2:
private static void Main(string[] args)
{
int a = 0;
string name = "Test";
var byteArray = new byte[100000000];
byteArray[4] …Run Code Online (Sandbox Code Playgroud)