public CounterInfoResponse GetResponse() { var response = new CounterInfoResponse { Counters = new List<CounterInfo>(this.knownCounters.Values), }; if (this.shouldAggregateDetails) { response.RequestDetails = new List<RequestDetails>(this.details); } return response; }
public CounterInfoResponse GetResponse() { var response = new CounterInfoResponse { Counters = new List <CounterInfo>(this.knownCounters.Values), }; if (this.shouldAggregateDetails) { response.RequestDetails = new List <RequestDetails>(this.details); } return(response); }
public void AddSamples(CounterInfoResponse response) { lock (this.knownCounters) { foreach (var item in response.Counters) { this.AddSampleData(item); } } if (response.RequestDetails != null && this.shouldAggregateDetails) { lock (this.details) { this.details.AddRange(response.RequestDetails); } } }
private async Task <Response> Info(Request request, TieredRequest fanoutRequest, string counterPattern, DimensionSpecification queryParameters) { var localResponseData = new CounterInfoResponse(); foreach (var c in this.server.DataManager.Counters) { if (c.Name.MatchGlob(counterPattern)) { localResponseData.Counters.Add(BuildCounterInfo(c, queryParameters)); } } // If there's no lower tier we can bounce out now. if (fanoutRequest == null) { return(localResponseData.Counters.Count == 0 ? request.CreateErrorResponse(HttpStatusCode.NotFound, "No matching counters are defined.") : Response.Create(request, HttpStatusCode.OK, localResponseData)); } var distributedResponse = await this.server.CreateQueryClient(fanoutRequest) .CounterInfoQuery(counterPattern, fanoutRequest, queryParameters); CounterInfoSampleCombiner.Merge(distributedResponse, localResponseData); // add details from this server if needed if (fanoutRequest.IncludeRequestDiagnostics && distributedResponse.RequestDetails != null) { distributedResponse.RequestDetails.Add(new RequestDetails { Server = this.server.ServerInfo, IsAggregator = true, HttpResponseCode = (localResponseData.Counters.Count > 0 ? (short)HttpStatusCode.OK : (short)HttpStatusCode.NotFound), Status = RequestStatus.Success, }); } return(Response.Create(request, HttpStatusCode.OK, distributedResponse)); }
public static void Merge(CounterInfoResponse aggregatedResponse, CounterInfoResponse localResponse) { if (localResponse != null && localResponse.Counters.Count > 0) { // We want a fast lookup dictionary here. var aggregatedCounters = aggregatedResponse.Counters.ToDictionary(counterInfo => counterInfo); foreach (var counterInfo in localResponse.Counters) { CounterInfo aggregateCounterInfo; if (aggregatedCounters.TryGetValue(counterInfo, out aggregateCounterInfo)) { MergeSampleData(aggregateCounterInfo, counterInfo); } else { aggregatedResponse.Counters.Add(counterInfo); } } } }
private async Task<Response> Info(Request request, TieredRequest fanoutRequest, string counterPattern, DimensionSpecification queryParameters) { var localResponseData = new CounterInfoResponse(); foreach (var c in this.server.DataManager.Counters) { if (c.Name.MatchGlob(counterPattern)) { localResponseData.Counters.Add(BuildCounterInfo(c, queryParameters)); } } // If there's no lower tier we can bounce out now. if (fanoutRequest == null) { return localResponseData.Counters.Count == 0 ? request.CreateErrorResponse(HttpStatusCode.NotFound, "No matching counters are defined.") : Response.Create(request, HttpStatusCode.OK, localResponseData); } var distributedResponse = await this.server.CreateQueryClient(fanoutRequest) .CounterInfoQuery(counterPattern, fanoutRequest, queryParameters); CounterInfoSampleCombiner.Merge(distributedResponse, localResponseData); // add details from this server if needed if (fanoutRequest.IncludeRequestDiagnostics && distributedResponse.RequestDetails != null) { distributedResponse.RequestDetails.Add(new RequestDetails { Server = this.server.ServerInfo, IsAggregator = true, HttpResponseCode = (localResponseData.Counters.Count > 0 ? (short)HttpStatusCode.OK : (short)HttpStatusCode.NotFound), Status = RequestStatus.Success, }); } return Response.Create(request, HttpStatusCode.OK, distributedResponse); }