public AllDotNetMetricsApiResponse GetAllDonNetMetrics(GetAllDotNetMetricsApiRequest request) { var fromParameter = request.FromTime.ToString("s") + "Z"; var toParameter = request.ToTime.ToString("s") + "Z"; var httpRequest = new HttpRequestMessage(HttpMethod.Get, $"{request.ClientBaseAddress}/api/metrics/dotnet/from/{fromParameter}/to/{toParameter}"); try { HttpResponseMessage response = _httpClient.SendAsync(httpRequest).Result; string jsonString = response.Content.ReadAsStringAsync() .Result .Replace("\\", "") .Trim(new char[1] { '"' }); var allDotNetMetricsApiResponse = JsonConvert.DeserializeObject <AllDotNetMetricsApiResponse>(jsonString); return(allDotNetMetricsApiResponse); } catch (Exception ex) { return(null); } }
public AllDotNetMetricsApiResponse GetDotNetMetrics(GetAllDotNetMetricsApiRequest request) { string content = GetMetricsApiResponseString(request, Strings.TableNames[(int)Enums.MetricsNames.DotNet]); if (content != null) { return(JsonConvert.DeserializeObject <AllDotNetMetricsApiResponse>(content)); } else { _logger.LogError("null content"); return(null); } }
public AllDotNetMetricsApiResponse GetDotNetMetrics(GetAllDotNetMetricsApiRequest request) { var fromParameter = request.FromTime.ToString("yyyy-MM-dd HH:mm:ss"); var toParameter = request.ToTime.ToString("yyyy-MM-dd HH:mm:ss"); var httpRequest = new HttpRequestMessage(HttpMethod.Get, $"{request.ClientBaseAddress.TrimEnd('/')}/api/metrics/dotnet/errors-count/from/{fromParameter}/to/{toParameter}"); try { HttpResponseMessage response = _httpClient.SendAsync(httpRequest).Result; using var responseStream = response.Content.ReadAsStreamAsync().Result; return(JsonSerializer.DeserializeAsync <AllDotNetMetricsApiResponse>(responseStream).Result); } catch (Exception ex) { _logger.LogError(ex.Message); } return(null); }
public AllDotNetMetricsApiResponse GetDonNetMetrics(GetAllDotNetMetricsApiRequest request) { var fromParameter = request.FromTime.ToUnixTimeSeconds(); var toParameter = request.ToTime.ToUnixTimeSeconds(); var httpRequest = new HttpRequestMessage(HttpMethod.Get, $"{request.AgentUrl}/api/dotnetmetrics/from/{fromParameter}/to/{toParameter}"); try { HttpResponseMessage response = _httpClient.SendAsync(httpRequest).Result; using var responseStream = response.Content.ReadAsStreamAsync().Result; return(JsonSerializer.DeserializeAsync <AllDotNetMetricsApiResponse>(responseStream).Result); } catch (Exception ex) { _logger.LogError(ex.Message); } return(null); }
public AllDotNetMetricsApiResponse GetAllDotNetMetrics(GetAllDotNetMetricsApiRequest request) { var fromParameter = request.FromTime.UtcDateTime.ToString("O"); var toParameter = request.ToTime.UtcDateTime.ToString("O"); var uri = request.ClientBaseAddress; var httpRequest = new HttpRequestMessage(HttpMethod.Get, $"{uri}api/metrics/dotnet/errors-count/from/{fromParameter}/to/{toParameter}"); try { HttpResponseMessage response = _httpClient.SendAsync(httpRequest).Result; using var responseStream = response.Content.ReadAsStreamAsync().Result; using var streamReader = new StreamReader(responseStream); var content = streamReader.ReadToEnd(); return(JsonConvert.DeserializeObject <AllDotNetMetricsApiResponse>(content)); } catch (Exception ex) { _loggerNetwork.LogError(ex.Message); return(null); } }
public AllDotNetMetricsApiResponse GetAllDotNetMetrics(GetAllDotNetMetricsApiRequest request) { var httpRequest = new HttpRequestMessage(HttpMethod.Get, $"{request.Addres}/api/metrics/dotnet/from/{request.FromTime:o}/to/{request.ToTime:o}"); try { HttpResponseMessage response = _httpClient.SendAsync(httpRequest).Result; using var responseStream = response.Content.ReadAsStreamAsync().Result; using var streamReader = new StreamReader(responseStream); var content = streamReader.ReadToEnd(); var result = JsonSerializer.Deserialize <AllDotNetMetricsApiResponse>(content, new JsonSerializerOptions() { PropertyNameCaseInsensitive = true }); return(result); } catch (Exception ex) { _logger.LogError(ex.Message); } return(null); }