internal static void MethodCalled(string operationName) { EndpointDispatcher endpointDispatcher = GetEndpointDispatcher(); if (endpointDispatcher != null) { if (Scope == PerformanceCounterScope.All) { string perfCounterId = endpointDispatcher.PerfCounterId; OperationPerformanceCountersBase operationPerformanceCounters = GetOperationPerformanceCounters(endpointDispatcher.PerfCounterInstanceId, operationName); if (operationPerformanceCounters != null) { operationPerformanceCounters.MethodCalled(); } EndpointPerformanceCountersBase endpointPerformanceCounters = GetEndpointPerformanceCounters(endpointDispatcher.PerfCounterInstanceId); if (endpointPerformanceCounters != null) { endpointPerformanceCounters.MethodCalled(); } } ServicePerformanceCountersBase servicePerformanceCounters = GetServicePerformanceCounters(endpointDispatcher.PerfCounterInstanceId); if (servicePerformanceCounters != null) { servicePerformanceCounters.MethodCalled(); } } }
internal static void MethodCalled(string operationName) { EndpointDispatcher el = GetEndpointDispatcher(); if (null != el) { if (PerformanceCounters.Scope == PerformanceCounterScope.All) { string uri = el.PerfCounterId; OperationPerformanceCountersBase opCounters = PerformanceCounters.GetOperationPerformanceCounters(el.PerfCounterInstanceId, operationName); if (null != opCounters) { opCounters.MethodCalled(); } EndpointPerformanceCountersBase eCounters = PerformanceCounters.GetEndpointPerformanceCounters(el.PerfCounterInstanceId); if (null != eCounters) { eCounters.MethodCalled(); } } ServicePerformanceCountersBase sCounters = PerformanceCounters.GetServicePerformanceCounters(el.PerfCounterInstanceId); if (null != sCounters) { sCounters.MethodCalled(); } } }
internal static void TxFlowed(EndpointDispatcher el, string operation) { if (null != el) { ServicePerformanceCountersBase sCounters = PerformanceCounters.GetServicePerformanceCounters(el.PerfCounterInstanceId); if (null != sCounters) { sCounters.TxFlowed(); } if (PerformanceCounters.Scope == PerformanceCounterScope.All) { OperationPerformanceCountersBase oCounters = PerformanceCounters.GetOperationPerformanceCounters(el.PerfCounterInstanceId, operation); if (null != oCounters) { oCounters.TxFlowed(); } EndpointPerformanceCountersBase eCounters = PerformanceCounters.GetEndpointPerformanceCounters(el.PerfCounterInstanceId); if (null != sCounters) { eCounters.TxFlowed(); } } } }
static internal void AuthorizationFailed(string operationName) { EndpointDispatcher el = GetEndpointDispatcher(); if (null != el) { string uri = el.PerfCounterId; if (PerformanceCounters.Scope == PerformanceCounterScope.All) { OperationPerformanceCountersBase counters = PerformanceCounters.GetOperationPerformanceCounters(el.PerfCounterInstanceId, operationName); if (null != counters) { counters.AuthorizationFailed(); } EndpointPerformanceCountersBase eCounters = PerformanceCounters.GetEndpointPerformanceCounters(el.PerfCounterInstanceId); if (null != eCounters) { eCounters.AuthorizationFailed(); } } ServicePerformanceCountersBase sCounters = PerformanceCounters.GetServicePerformanceCounters(el.PerfCounterInstanceId); if (null != sCounters) { sCounters.AuthorizationFailed(); } } }
private static string GetShortInstanceName(ServiceHostBase serviceHost) { ServiceInfo serviceInfo = new ServiceInfo(serviceHost); string serviceName = serviceInfo.ServiceName; string uri = GetServiceUri(serviceHost, serviceInfo); int length = serviceName.Length + uri.Length + 2; if (length > maxCounterLength) { int count = 0; truncOptions tasks = ServicePerformanceCountersBase.GetCompressionTasks( length, serviceName.Length, uri.Length); //if necessary, compress service name to 8 chars with a 2 char hash code if ((tasks & truncOptions.service32) > 0) { count = 32; serviceName = GetHashedString(serviceName, count - hashLength, serviceName.Length - count + hashLength, true); } //if necessary, compress uri to 36 chars with a 2 char hash code if ((tasks & truncOptions.uri31) > 0) { count = 31; uri = GetHashedString(uri, 0, uri.Length - count + hashLength, false); } } // replace '/' with '|' because perfmon fails when '/' is in perfcounter instance name return(serviceName + "@" + uri.Replace('/', '|')); }
internal ServiceModelPerformanceCounters( ServiceHostBase serviceHost, ContractDescription contractDescription, EndpointDispatcher endpointDispatcher) { this.perfCounterId = endpointDispatcher.PerfCounterId; if (PerformanceCounters.Scope == PerformanceCounterScope.All) { this.operationPerfCounters = new Dictionary<string, OperationPerformanceCountersBase>(contractDescription.Operations.Count); this.actionToOperation = new SortedList<string, string>(contractDescription.Operations.Count); foreach (OperationDescription opDescription in contractDescription.Operations) { Fx.Assert(null != opDescription.Messages, "OperationDescription.Messages should not be null"); Fx.Assert(opDescription.Messages.Count > 0, "OperationDescription.Messages should not be empty"); Fx.Assert(null != opDescription.Messages[0], "OperationDescription.Messages[0] should not be null"); if (null != opDescription.Messages[0].Action && !this.actionToOperation.Keys.Contains(opDescription.Messages[0].Action)) { this.actionToOperation.Add(opDescription.Messages[0].Action, opDescription.Name); } OperationPerformanceCountersBase c; if (!this.operationPerfCounters.TryGetValue(opDescription.Name, out c)) { OperationPerformanceCountersBase counters = PerformanceCountersFactory.CreateOperationCounters(serviceHost.Description.Name, contractDescription.Name, opDescription.Name, endpointDispatcher.PerfCounterBaseId); if (counters != null && counters.Initialized) { this.operationPerfCounters.Add(opDescription.Name, counters); } else { // cleanup the others and return. this.initialized = false; return; } } } // add endpoint scoped perf counters EndpointPerformanceCountersBase endpointCounters = PerformanceCountersFactory.CreateEndpointCounters(serviceHost.Description.Name, contractDescription.Name, endpointDispatcher.PerfCounterBaseId); if (endpointCounters != null && endpointCounters.Initialized) { this.endpointPerfCounters = endpointCounters; } } if (PerformanceCounters.PerformanceCountersEnabled) { this.servicePerfCounters = serviceHost.Counters; } if (PerformanceCounters.MinimalPerformanceCountersEnabled) { this.defaultPerfCounters = serviceHost.DefaultCounters; } this.initialized = true; }
internal ServiceModelPerformanceCounters( ServiceHostBase serviceHost, ContractDescription contractDescription, EndpointDispatcher endpointDispatcher) { this.perfCounterId = endpointDispatcher.PerfCounterId; if (PerformanceCounters.Scope == PerformanceCounterScope.All) { this.operationPerfCounters = new Dictionary <string, OperationPerformanceCountersBase>(contractDescription.Operations.Count); this.actionToOperation = new SortedList <string, string>(contractDescription.Operations.Count); foreach (OperationDescription opDescription in contractDescription.Operations) { Fx.Assert(null != opDescription.Messages, "OperationDescription.Messages should not be null"); Fx.Assert(opDescription.Messages.Count > 0, "OperationDescription.Messages should not be empty"); Fx.Assert(null != opDescription.Messages[0], "OperationDescription.Messages[0] should not be null"); if (null != opDescription.Messages[0].Action && !this.actionToOperation.Keys.Contains(opDescription.Messages[0].Action)) { this.actionToOperation.Add(opDescription.Messages[0].Action, opDescription.Name); } OperationPerformanceCountersBase c; if (!this.operationPerfCounters.TryGetValue(opDescription.Name, out c)) { OperationPerformanceCountersBase counters = PerformanceCountersFactory.CreateOperationCounters(serviceHost.Description.Name, contractDescription.Name, opDescription.Name, endpointDispatcher.PerfCounterBaseId); if (counters != null && counters.Initialized) { this.operationPerfCounters.Add(opDescription.Name, counters); } else { // cleanup the others and return. this.initialized = false; return; } } } // add endpoint scoped perf counters EndpointPerformanceCountersBase endpointCounters = PerformanceCountersFactory.CreateEndpointCounters(serviceHost.Description.Name, contractDescription.Name, endpointDispatcher.PerfCounterBaseId); if (endpointCounters != null && endpointCounters.Initialized) { this.endpointPerfCounters = endpointCounters; } } if (PerformanceCounters.PerformanceCountersEnabled) { this.servicePerfCounters = serviceHost.Counters; } if (PerformanceCounters.MinimalPerformanceCountersEnabled) { this.defaultPerfCounters = serviceHost.DefaultCounters; } this.initialized = true; }
internal static void TxInDoubt(EndpointDispatcher el, long count) { if (PerformanceCountersEnabled && (el != null)) { ServicePerformanceCountersBase servicePerformanceCounters = GetServicePerformanceCounters(el.PerfCounterInstanceId); if (servicePerformanceCounters != null) { servicePerformanceCounters.TxInDoubt(count); } } }
internal static void TxInDoubt(EndpointDispatcher el, long count) { if (PerformanceCounters.PerformanceCountersEnabled) { if (null != el) { ServicePerformanceCountersBase sCounters = PerformanceCounters.GetServicePerformanceCounters(el.PerfCounterInstanceId); if (null != sCounters) { sCounters.TxInDoubt(count); } } } }
internal ServiceModelPerformanceCounters(ServiceHostBase serviceHost, ContractDescription contractDescription, EndpointDispatcher endpointDispatcher) { this.perfCounterId = endpointDispatcher.PerfCounterId; if (PerformanceCounters.Scope == PerformanceCounterScope.All) { this.operationPerfCounters = new Dictionary<string, OperationPerformanceCountersBase>(contractDescription.Operations.Count); this.actionToOperation = new SortedList<string, string>(contractDescription.Operations.Count); foreach (OperationDescription description in contractDescription.Operations) { OperationPerformanceCountersBase base2; if ((description.Messages[0].Action != null) && !this.actionToOperation.Keys.Contains(description.Messages[0].Action)) { this.actionToOperation.Add(description.Messages[0].Action, description.Name); } if (!this.operationPerfCounters.TryGetValue(description.Name, out base2)) { OperationPerformanceCountersBase base3 = PerformanceCountersFactory.CreateOperationCounters(serviceHost.Description.Name, contractDescription.Name, description.Name, endpointDispatcher.PerfCounterBaseId); if ((base3 != null) && base3.Initialized) { this.operationPerfCounters.Add(description.Name, base3); } else { this.initialized = false; return; } } } EndpointPerformanceCountersBase base4 = PerformanceCountersFactory.CreateEndpointCounters(serviceHost.Description.Name, contractDescription.Name, endpointDispatcher.PerfCounterBaseId); if ((base4 != null) && base4.Initialized) { this.endpointPerfCounters = base4; } } if (PerformanceCounters.PerformanceCountersEnabled) { this.servicePerfCounters = serviceHost.Counters; } if (PerformanceCounters.MinimalPerformanceCountersEnabled) { this.defaultPerfCounters = serviceHost.DefaultCounters; } this.initialized = true; }
internal ServiceModelPerformanceCounters(ServiceHostBase serviceHost, ContractDescription contractDescription, EndpointDispatcher endpointDispatcher) { this.perfCounterId = endpointDispatcher.PerfCounterId; if (PerformanceCounters.Scope == PerformanceCounterScope.All) { this.operationPerfCounters = new Dictionary <string, OperationPerformanceCountersBase>(contractDescription.Operations.Count); this.actionToOperation = new SortedList <string, string>(contractDescription.Operations.Count); foreach (OperationDescription description in contractDescription.Operations) { OperationPerformanceCountersBase base2; if ((description.Messages[0].Action != null) && !this.actionToOperation.Keys.Contains(description.Messages[0].Action)) { this.actionToOperation.Add(description.Messages[0].Action, description.Name); } if (!this.operationPerfCounters.TryGetValue(description.Name, out base2)) { OperationPerformanceCountersBase base3 = PerformanceCountersFactory.CreateOperationCounters(serviceHost.Description.Name, contractDescription.Name, description.Name, endpointDispatcher.PerfCounterBaseId); if ((base3 != null) && base3.Initialized) { this.operationPerfCounters.Add(description.Name, base3); } else { this.initialized = false; return; } } } EndpointPerformanceCountersBase base4 = PerformanceCountersFactory.CreateEndpointCounters(serviceHost.Description.Name, contractDescription.Name, endpointDispatcher.PerfCounterBaseId); if ((base4 != null) && base4.Initialized) { this.endpointPerfCounters = base4; } } if (PerformanceCounters.PerformanceCountersEnabled) { this.servicePerfCounters = serviceHost.Counters; } if (PerformanceCounters.MinimalPerformanceCountersEnabled) { this.defaultPerfCounters = serviceHost.DefaultCounters; } this.initialized = true; }
internal static void MethodReturnedError(string operationName, long time) { EndpointDispatcher el = GetEndpointDispatcher(); if (null != el) { if (PerformanceCounters.Scope == PerformanceCounterScope.All) { string uri = el.PerfCounterId; OperationPerformanceCountersBase counters = PerformanceCounters.GetOperationPerformanceCounters(el.PerfCounterInstanceId, operationName); if (null != counters) { counters.MethodReturnedError(); if (time > 0) { counters.SaveCallDuration(time); } } EndpointPerformanceCountersBase eCounters = PerformanceCounters.GetEndpointPerformanceCounters(el.PerfCounterInstanceId); if (null != eCounters) { eCounters.MethodReturnedError(); if (time > 0) { eCounters.SaveCallDuration(time); } } } ServicePerformanceCountersBase sCounters = PerformanceCounters.GetServicePerformanceCounters(el.PerfCounterInstanceId); if (null != sCounters) { sCounters.MethodReturnedError(); if (time > 0) { sCounters.SaveCallDuration(time); } } } }
internal static void MethodReturnedSuccess(string operationName, long time) { EndpointDispatcher endpointDispatcher = GetEndpointDispatcher(); if (endpointDispatcher != null) { if (Scope == PerformanceCounterScope.All) { string perfCounterId = endpointDispatcher.PerfCounterId; OperationPerformanceCountersBase operationPerformanceCounters = GetOperationPerformanceCounters(endpointDispatcher.PerfCounterInstanceId, operationName); if (operationPerformanceCounters != null) { operationPerformanceCounters.MethodReturnedSuccess(); if (time > 0L) { operationPerformanceCounters.SaveCallDuration(time); } } EndpointPerformanceCountersBase endpointPerformanceCounters = GetEndpointPerformanceCounters(endpointDispatcher.PerfCounterInstanceId); if (endpointPerformanceCounters != null) { endpointPerformanceCounters.MethodReturnedSuccess(); if (time > 0L) { endpointPerformanceCounters.SaveCallDuration(time); } } } ServicePerformanceCountersBase servicePerformanceCounters = GetServicePerformanceCounters(endpointDispatcher.PerfCounterInstanceId); if (servicePerformanceCounters != null) { servicePerformanceCounters.MethodReturnedSuccess(); if (time > 0L) { servicePerformanceCounters.SaveCallDuration(time); } } } }
static internal string CreateFriendlyInstanceName(ServiceHostBase serviceHost) { // instance name is: serviceName@uri ServiceInfo serviceInfo = new ServiceInfo(serviceHost); string serviceName = serviceInfo.ServiceName; string uri; if (!TryGetFullVirtualPath(serviceHost, out uri)) { uri = serviceInfo.FirstAddress; } int length = serviceName.Length + uri.Length + 2; if (length > maxCounterLength) { int count = 0; truncOptions tasks = ServicePerformanceCountersBase.GetCompressionTasks( length, serviceName.Length, uri.Length); //if necessary, compress service name to 8 chars with a 2 char hash code if ((tasks & truncOptions.service32) > 0) { count = 32; serviceName = GetHashedString(serviceName, count - hashLength, serviceName.Length - count + hashLength, true); } //if necessary, compress uri to 36 chars with a 2 char hash code if ((tasks & truncOptions.uri31) > 0) { count = 31; uri = GetHashedString(uri, 0, uri.Length - count + hashLength, false); } } // replace '/' with '|' because perfmon fails when '/' is in perfcounter instance name return(serviceName + "@" + uri.Replace('/', '|')); }
internal static void TxFlowed(EndpointDispatcher el, string operation) { if (el != null) { ServicePerformanceCountersBase servicePerformanceCounters = GetServicePerformanceCounters(el.PerfCounterInstanceId); if (servicePerformanceCounters != null) { servicePerformanceCounters.TxFlowed(); } if (Scope == PerformanceCounterScope.All) { OperationPerformanceCountersBase operationPerformanceCounters = GetOperationPerformanceCounters(el.PerfCounterInstanceId, operation); if (operationPerformanceCounters != null) { operationPerformanceCounters.TxFlowed(); } EndpointPerformanceCountersBase endpointPerformanceCounters = GetEndpointPerformanceCounters(el.PerfCounterInstanceId); if (servicePerformanceCounters != null) { endpointPerformanceCounters.TxFlowed(); } } } }
internal void SetServicePerformanceCounters(ServicePerformanceCountersBase counters) { this.servicePerformanceCounters = counters; //instance throttle is created through the behavior, set the perf counter callbacks if initialized if (this.instanceContexts != null) { InitializeInstancePerfCounterSettings(this.instanceContexts); } //this.calls and this.sessions throttles are created by the constructor. Set the perf counter callbacks InitializeCallsPerfCounterSettings(); InitializeSessionsPerfCounterSettings(); }
internal void SetServicePerformanceCounters(ServicePerformanceCountersBase counters) { this.servicePerformanceCounters = counters; if (this.instanceContexts != null) { this.InitializeInstancePerfCounterSettings(); } this.InitializeCallsPerfCounterSettings(); this.InitializeSessionsPerfCounterSettings(); }
public ServiceModelPerformanceCountersEntry(ServicePerformanceCountersBase serviceCounters) { this.servicePerformanceCounters = serviceCounters; this.performanceCounters = new List <ServiceModelPerformanceCounters>(); }
public ServiceModelPerformanceCountersEntry(ServicePerformanceCountersBase serviceCounters) { this.servicePerformanceCounters = serviceCounters; this.performanceCounters = new List<ServiceModelPerformanceCounters>(); }