Service Fabric ETW 日志始终不完整
Service Fabric ETW Logs are always incomplete
我们刚刚开始使用 Service Fabric,到目前为止唯一的痛点是 ETW 和 WAD,它似乎总是在注销时丢失数据(消息、事件消息。)
根据我们目前的经验,它在 visual studio 中始终有效(有时您必须添加提供者名称)并且在部署到 Azure 中的集群时很少有效。当它在 Azure 中工作时 - 版本控制和更新事件源上的函数或添加另一个函数将用空数据点注销。
这是我们使用 Azure CLI 部署的 ETW/WAD ARM 脚本中的部分。
"name": "[concat('VMDiagnosticsVmExt','_vmNodeType0Name')]",
"properties": {
"type": "IaaSDiagnostics",
"autoUpgradeMinorVersion": true,
"protectedSettings": {
"storageAccountName": "[parameters('applicationDiagnosticsStorageAccountName')]",
"storageAccountKey": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('applicationDiagnosticsStorageAccountName')),'2015-05-01-preview').key1]",
"storageAccountEndPoint": "https://core.windows.net/"
},
"publisher": "Microsoft.Azure.Diagnostics",
"settings": {
"WadCfg": {
"DiagnosticMonitorConfiguration": {
"overallQuotaInMB": "50000",
"EtwProviders": {
"EtwEventSourceProviderConfiguration": [
{
"provider": "Microsoft-ServiceFabric-Actors",
"scheduledTransferKeywordFilter": "1",
"scheduledTransferPeriod": "PT5M",
"DefaultEvents": {
"eventDestination": "ServiceFabricReliableActorEventTable"
}
},
{
"provider": "Microsoft-ServiceFabric-Services",
"scheduledTransferPeriod": "PT5M",
"DefaultEvents": {
"eventDestination": "ServiceFabricReliableServiceEventTable"
}
},
{
"provider": "Company-Project-API",
"scheduledTransferPeriod": "PT1M",
"DefaultEvents": {
"eventDestination": "ApiEventTable"
}
}
],
"EtwManifestProviderConfiguration": [
{
"provider": "cbd93bc2-71e5-4566-b3a7-595d8eeca6e8",
"scheduledTransferLogLevelFilter": "Information",
"scheduledTransferKeywordFilter": "4611686018427387904",
"scheduledTransferPeriod": "PT5M",
"DefaultEvents": {
"eventDestination": "ServiceFabricSystemEventTable"
}
}
]
}
}
},
"StorageAccount": "[parameters('applicationDiagnosticsStorageAccountName')]"
},
"typeHandlerVersion": "1.5"
}
这是我们的 EventSource,尽管我们尝试了很多变体。
using Microsoft.Diagnostics.Tracing;
namespace Project.API
[EventSource(Name = "Company-Project-API")]
public sealed class ApiEventSource : EventSource
{
public static ApiEventSource Current = new ApiEventSource();
[Event(1, Level = EventLevel.Informational, Message = "{0}", Version = 1)]
public void Log(string message)
{
this.WriteEvent(1, message);
}
}
这是我们每次在 WAD 中得到的。
运行 .NET 4.5.2 / .net 核心。
请协助。
编辑 - 好的,我们在升级到 .NET 4.6 方面取得了一些成功 - 消息负载似乎正在注销。我们现在缺少的是 eventmessage 字段。似乎 "message" 字段现在在 VS 中始终为 null。
EDIT2 - 当使用 EventSourceSettings.EtwSelfDescribingEventFormat 作为事件源的构造函数参数时,消息字段似乎丢失了,如下所示。在 VS 和 WAD 中似乎就是这种情况。
public sealed class ApiEventSource : EventSource
{
public ApiEventSource() : base(EventSourceSettings.EtwSelfDescribingEventFormat) {}
}
目前我可以在没有事件消息(自我描述)或不能对方法进行版本控制之间做出选择(即使增加了属性,在使用清单样式时空行仍然被转储到 WAD 中。
自描述 ETW 当前未设计为支持 EventAttribute.Message 属性。消息是一个基于清单的概念(即它们没有记录在事件中,而是放在清单中。由于自描述 ETW 没有清单,消息 属性 实际上被忽略了。
可以想象扩展与自描述 ETW 事件关联的元数据,以便它可以保存消息字符串,但目前不存在,需要更改 ETW。
简单地将消息嵌入负载是避免该问题的预期方法。
我们刚刚开始使用 Service Fabric,到目前为止唯一的痛点是 ETW 和 WAD,它似乎总是在注销时丢失数据(消息、事件消息。)
根据我们目前的经验,它在 visual studio 中始终有效(有时您必须添加提供者名称)并且在部署到 Azure 中的集群时很少有效。当它在 Azure 中工作时 - 版本控制和更新事件源上的函数或添加另一个函数将用空数据点注销。
这是我们使用 Azure CLI 部署的 ETW/WAD ARM 脚本中的部分。
"name": "[concat('VMDiagnosticsVmExt','_vmNodeType0Name')]",
"properties": {
"type": "IaaSDiagnostics",
"autoUpgradeMinorVersion": true,
"protectedSettings": {
"storageAccountName": "[parameters('applicationDiagnosticsStorageAccountName')]",
"storageAccountKey": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('applicationDiagnosticsStorageAccountName')),'2015-05-01-preview').key1]",
"storageAccountEndPoint": "https://core.windows.net/"
},
"publisher": "Microsoft.Azure.Diagnostics",
"settings": {
"WadCfg": {
"DiagnosticMonitorConfiguration": {
"overallQuotaInMB": "50000",
"EtwProviders": {
"EtwEventSourceProviderConfiguration": [
{
"provider": "Microsoft-ServiceFabric-Actors",
"scheduledTransferKeywordFilter": "1",
"scheduledTransferPeriod": "PT5M",
"DefaultEvents": {
"eventDestination": "ServiceFabricReliableActorEventTable"
}
},
{
"provider": "Microsoft-ServiceFabric-Services",
"scheduledTransferPeriod": "PT5M",
"DefaultEvents": {
"eventDestination": "ServiceFabricReliableServiceEventTable"
}
},
{
"provider": "Company-Project-API",
"scheduledTransferPeriod": "PT1M",
"DefaultEvents": {
"eventDestination": "ApiEventTable"
}
}
],
"EtwManifestProviderConfiguration": [
{
"provider": "cbd93bc2-71e5-4566-b3a7-595d8eeca6e8",
"scheduledTransferLogLevelFilter": "Information",
"scheduledTransferKeywordFilter": "4611686018427387904",
"scheduledTransferPeriod": "PT5M",
"DefaultEvents": {
"eventDestination": "ServiceFabricSystemEventTable"
}
}
]
}
}
},
"StorageAccount": "[parameters('applicationDiagnosticsStorageAccountName')]"
},
"typeHandlerVersion": "1.5"
}
这是我们的 EventSource,尽管我们尝试了很多变体。
using Microsoft.Diagnostics.Tracing;
namespace Project.API
[EventSource(Name = "Company-Project-API")]
public sealed class ApiEventSource : EventSource
{
public static ApiEventSource Current = new ApiEventSource();
[Event(1, Level = EventLevel.Informational, Message = "{0}", Version = 1)]
public void Log(string message)
{
this.WriteEvent(1, message);
}
}
这是我们每次在 WAD 中得到的。
运行 .NET 4.5.2 / .net 核心。
请协助。
编辑 - 好的,我们在升级到 .NET 4.6 方面取得了一些成功 - 消息负载似乎正在注销。我们现在缺少的是 eventmessage 字段。似乎 "message" 字段现在在 VS 中始终为 null。
EDIT2 - 当使用 EventSourceSettings.EtwSelfDescribingEventFormat 作为事件源的构造函数参数时,消息字段似乎丢失了,如下所示。在 VS 和 WAD 中似乎就是这种情况。
public sealed class ApiEventSource : EventSource
{
public ApiEventSource() : base(EventSourceSettings.EtwSelfDescribingEventFormat) {}
}
目前我可以在没有事件消息(自我描述)或不能对方法进行版本控制之间做出选择(即使增加了属性,在使用清单样式时空行仍然被转储到 WAD 中。
自描述 ETW 当前未设计为支持 EventAttribute.Message 属性。消息是一个基于清单的概念(即它们没有记录在事件中,而是放在清单中。由于自描述 ETW 没有清单,消息 属性 实际上被忽略了。
可以想象扩展与自描述 ETW 事件关联的元数据,以便它可以保存消息字符串,但目前不存在,需要更改 ETW。
简单地将消息嵌入负载是避免该问题的预期方法。