Service Model performance counters Instance Name

血红的双手。 提交于 2019-12-23 03:02:53

问题


I am trying to connect directly to the performance counters emitted by ServiceModel (for services, endpoints and operations). The problem is that when I try to correlate with a certain service (or endpoint/operation) I need to specified instance name of the counter.

According to MSDN the pattern by which instance name is simple, however in certain cases when one of the components of the instance name (uri, contract name, etc.) is too long it’s shortened and hash code is added at either the beginning or the end of the string.The article doesn’t specify how it’s hashed.

So my question is there a way to get ServiceModel instance name based on the service name and it's address


回答1:


I know it is not ideal, but you could copy the current .NET implementation for generating counter instance names to your own code/application to programatically generate the same names from the full service name and address.

You can see the code used by WCF here:

For SerivcePerformanceCounters:

http://referencesource.microsoft.com/#System.ServiceModel/System/ServiceModel/Diagnostics/ServicePerformanceCountersBase.cs,6d61d34585241697

For EndpointPerformanceCounters:

http://referencesource.microsoft.com/#System.ServiceModel/System/ServiceModel/Diagnostics/EndpointPerformanceCountersBase.cs,e3319d41297320e3

For OperationPerformanceCounters:

http://referencesource.microsoft.com/#System.ServiceModel/System/ServiceModel/Diagnostics/OperationPerformanceCountersBase.cs,5e170817afd5d0ba

The downside is that any change to the .NET algorithm for naming instances will break your implementation.

I'm as frustrated as you surely are, but haven't found a better solution.



来源:https://stackoverflow.com/questions/35747997/service-model-performance-counters-instance-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!