服务模型性能计数器实例名称 [英] Service Model performance counters Instance Name

查看:92
本文介绍了服务模型性能计数器实例名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试直接连接到ServiceModel发出的性能计数器(用于服务,端点和操作).问题是,当我尝试与某个服务(或端点/操作)相关时,我需要指定计数器的实例名称.

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.

根据 MSDN 哪个实例名称很简单, 但是,在某些情况下,实例名称的一个组成部分(uri,合同名称等)太长时,它会被缩短,并且在字符串的开头或结尾添加哈希码.它是散列的.

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.

所以我的问题是有一种方法可以基于服务名称及其地址获取ServiceModel实例名称

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

推荐答案

我知道这并不理想,但是您可以将用于生成计数器实例名称的当前.NET实现复制到自己的代码/应用程序中,以编程方式生成相同的名称从完整的服务名称和地址.

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.

您可以在此处查看WCF使用的代码:

You can see the code used by WCF here:

对于SerivcePerformanceCounters:

For SerivcePerformanceCounters:

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

对于EndpointPerformanceCounters:

For EndpointPerformanceCounters:

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

对于OperationPerformanceCounters:

For OperationPerformanceCounters:

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

不利之处在于,对用于命名实例的.NET算法所做的任何更改都会破坏您的实现.

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.

这篇关于服务模型性能计数器实例名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆