Skip to content

Commit

Permalink
Merge pull request #12 from AuxMon/master
Browse files Browse the repository at this point in the history
Taking the bug fix in Metrics
  • Loading branch information
jagadisk committed Aug 12, 2014
2 parents b2073c2 + 2416594 commit 0eb5f5c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
6 changes: 2 additions & 4 deletions src/Insights/Customizations/Shoebox/ShoeboxHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,12 @@ public static string UnEscapeKey(string key)

public static string GenerateMetricDefinitionFilterString(IEnumerable<string> names)
{
return names.Select(n => "name.value eq '" + n + "'").Aggregate((a, b) => a + " or " + b);
return names == null || !names.Any() ? null : names.Select(n => "name.value eq '" + n + "'").Aggregate((a, b) => a + " or " + b);
}

public static string GenerateMetricFilterString(MetricFilter filter)
{

return string.Format(CultureInfo.InvariantCulture,
"{0}timeGrain eq duration'{1}' and startTime eq {2} and endTime eq {3}",
return string.Format(CultureInfo.InvariantCulture, "{0}timeGrain eq duration'{1}' and startTime eq {2} and endTime eq {3}",
filter.Names == null || !filter.Names.Any() ? string.Empty : "(" + GenerateMetricDefinitionFilterString(filter.Names) + ") and ",
filter.TimeGrain.To8601String(),
filter.StartTime.ToString("O"),
Expand Down
9 changes: 4 additions & 5 deletions src/Insights/Generated/Insights/MetricDefinitionOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ public async Task<MetricDefinitionListResponse> GetMetricDefinitionsAsync(string
{
throw new ArgumentNullException("resourceUri");
}
if (filterString == null)
{
throw new ArgumentNullException("filterString");
}

// Tracing
bool shouldTrace = CloudContext.Configuration.Tracing.IsEnabled;
Expand All @@ -105,7 +101,10 @@ public async Task<MetricDefinitionListResponse> GetMetricDefinitionsAsync(string
// Construct URL
string url = "/" + resourceUri.Trim() + "/metricDefinitions?";
url = url + "api-version=2014-04-01";
url = url + "&$filter=" + Uri.EscapeDataString(filterString.Trim());
if (filterString != null)
{
url = url + "&$filter=" + Uri.EscapeDataString(filterString != null ? filterString.Trim() : "");
}
string baseUrl = this.Client.BaseUri.AbsoluteUri;
// Trim '/' character from the end of baseUrl and beginning of url.
if (baseUrl[baseUrl.Length - 1] == '/')
Expand Down
9 changes: 4 additions & 5 deletions src/Insights/OnetimeGenerated/MetricDefinitionOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ public async Task<MetricDefinitionListResponse> GetMetricDefinitionsInternalAsyn
{
throw new ArgumentNullException("resourceUri");
}
if (filterString == null)
{
throw new ArgumentNullException("filterString");
}

// Tracing
bool shouldTrace = CloudContext.Configuration.Tracing.IsEnabled;
Expand All @@ -105,7 +101,10 @@ public async Task<MetricDefinitionListResponse> GetMetricDefinitionsInternalAsyn
// Construct URL
string url = "/" + resourceUri.Trim() + "/metricDefinitions?";
url = url + "api-version=2014-04-01";
url = url + "&$filter=" + Uri.EscapeDataString(filterString.Trim());
if (filterString != null)
{
url = url + "&$filter=" + Uri.EscapeDataString(filterString != null ? filterString.Trim() : "");
}
string baseUrl = this.Client.BaseUri.AbsoluteUri;
// Trim '/' character from the end of baseUrl and beginning of url.
if (baseUrl[baseUrl.Length - 1] == '/')
Expand Down

0 comments on commit 0eb5f5c

Please sign in to comment.