public ServiceEndpoint( string path, Method[] methods, Action <IEndpointRequest> method, MethodInfo methodInfo, string userSegmentKey, AnalyticsLevel analytics, IDataCatalog dataCatalog, IDataDependencyFactory dataDependencyFactory, IRequestRouter requestRouter) { Path = path; MethodInfo = methodInfo; _userSegmentKey = userSegmentKey; _method = method; _dataCatalog = dataCatalog; _dataDependencyFactory = dataDependencyFactory; _requestRouter = requestRouter; _pathElements = path .Split('/') .Where(p => !string.IsNullOrEmpty(p)) .ToArray(); AddStatistics(analytics, path, methods); }
private void AddStatistics(AnalyticsLevel level, string path, Method[] methods) { var baseId = path + "+"; if (methods != null && methods.Length > 0) { baseId = string.Join("", methods) + baseId + "+"; } if (!string.IsNullOrEmpty(_userSegmentKey)) { baseId += _userSegmentKey + "+"; } var name = path; if (methods != null && methods.Length > 0) { name = string.Join(" or ", methods) + " " + name; } if (!string.IsNullOrEmpty(_userSegmentKey)) { name += " for '" + _userSegmentKey + "' users"; } if (level == AnalyticsLevel.Basic || level == AnalyticsLevel.Full) { _availableStatistics.Add( new StatisticInformation { Id = baseId + "RequestCount", Name = "Requests to " + name, Description = "The total number of requests to " + name + " since the service was started" }); _availableStatistics.Add( new StatisticInformation { Id = baseId + "FailCount", Name = "Failed requests to " + name, Description = "The number of requests to " + name + " that failed since the service was started" }); } if (level == AnalyticsLevel.Full) { _requestsPerMinute = new CountPerMinute(); _availableStatistics.Add( new StatisticInformation { Id = baseId + "RequestRate", Name = "Requests per minute to " + name, Description = "The number of successful requests per minute made to " + name + " over the last 10 minutes" }); } if (level == AnalyticsLevel.Full) { _millisecondsPerRequest = new AverageTime(); _availableStatistics.Add( new StatisticInformation { Id = baseId + "RequestTime", Name = "Average execution time for " + name, Description = "The average time taken to execute successful requests to " + name + " in the last 10 minutes" }); } }