Skip to content

Commit

Permalink
resharper reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
nmbro committed May 8, 2019
1 parent e278ce0 commit 4373c6e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
3 changes: 2 additions & 1 deletion src/Cake.Graphite.Tests/GraphiteTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public void NullHost_ThrowsException()
_settings.Host = null;
var cakeLog = new FakeLog();

Assert.Throws<ArgumentNullException>(() => {
Assert.Throws<ArgumentNullException>(() =>
{
_graphite = new Graphite(cakeLog, _settings);
});
}
Expand Down
15 changes: 8 additions & 7 deletions src/Cake.Graphite/Graphite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class Graphite
}

internal Graphite(
ICakeLog log,
ICakeLog log,
GraphiteSettings settings,
IGraphiteClient client
)
Expand Down Expand Up @@ -65,7 +65,7 @@ internal void Send(string metricName, double value, DateTime timeStamp)
_log.Verbose($"Sending metric: '{PrefixMetricName(metricName)}' with value '{value}' and timestamp '{timeStamp.ToLongDateString()}'");
_client.Send(PrefixMetricName(metricName), value, timeStamp);
}
catch(Exception ex)
catch (Exception ex)
{
if (_settings.ThrowExceptions) throw;
_log.Verbose($"{nameof(Send)} would have thrown an {ex.GetType()}");
Expand All @@ -79,34 +79,35 @@ internal void Send(string metricName, double value)
_log.Verbose($"Sending metric: '{PrefixMetricName(metricName)}' with value '{value}'");
_client.Send(PrefixMetricName(metricName), value);
}
catch(Exception ex)
catch (Exception ex)
{
if (_settings.ThrowExceptions) throw;
_log.Verbose($"{nameof(Send)} would have thrown an {ex.GetType()}");
}
}

private void TrySend(ICollection<Datapoint> datapoints){
private void TrySend(ICollection<Datapoint> datapoints)
{
try
{
_client.Send(datapoints);
}
catch(Exception ex)
catch (Exception ex)
{
if (_settings.ThrowExceptions) throw;
_log.Verbose($"{nameof(Send)} would have thrown an {ex.GetType()}");
}
}

internal void Send(ICollection<(string metricName,double value)> datapointTuples)
internal void Send(ICollection<(string metricName, double value)> datapointTuples)
{
var now = DateTime.UtcNow;
var datapoints = datapointTuples.Select(x => new Datapoint(PrefixMetricName(x.metricName), x.value, now)).ToArray();

TrySend(datapoints);
}

internal void Send(ICollection<(string metricName,double value,DateTime timeStamp)> datapointTuples)
internal void Send(ICollection<(string metricName, double value, DateTime timeStamp)> datapointTuples)
{
var datapoints = datapointTuples.Select(x => new Datapoint(PrefixMetricName(x.metricName), x.value, x.timeStamp)).ToArray();

Expand Down
21 changes: 14 additions & 7 deletions src/Cake.Graphite/GraphiteExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ namespace Cake.Graphite
/// Extension methods for <see cref="Graphite"/>
/// </summary>
[PublicAPI]
public static class GraphiteExtensions{
public static class GraphiteExtensions
{
/// <summary>
/// Send a single metric with timestamp of now
/// </summary>
/// <param name="graphite"></param>
/// <param name="metricName"></param>
/// <param name="value"></param>
[PublicAPI]
public static void Send(this Graphite graphite, string metricName, double value){
public static void Send(this Graphite graphite, string metricName, double value)
{
graphite.Send(metricName, value);
}

Expand All @@ -30,7 +32,8 @@ public static class GraphiteExtensions{
/// <param name="value"></param>
/// <param name="timeStamp"></param>
[PublicAPI]
public static void Send(this Graphite graphite, string metricName, double value, DateTime timeStamp){
public static void Send(this Graphite graphite, string metricName, double value, DateTime timeStamp)
{
graphite.Send(metricName, value, timeStamp);
}

Expand All @@ -40,7 +43,8 @@ public static class GraphiteExtensions{
/// <param name="graphite"></param>
/// <param name="datapointTuples"></param>
[PublicAPI]
public static void Send(this Graphite graphite, ICollection<(string metricName,double value)> datapointTuples){
public static void Send(this Graphite graphite, ICollection<(string metricName, double value)> datapointTuples)
{
graphite.Send(datapointTuples);
}

Expand All @@ -50,7 +54,8 @@ public static class GraphiteExtensions{
/// <param name="graphite"></param>
/// <param name="datapointTuples"></param>
[PublicAPI]
public static void Send(this Graphite graphite, ICollection<(string metricName,double value,DateTime timestamp)> datapointTuples){
public static void Send(this Graphite graphite, ICollection<(string metricName, double value, DateTime timestamp)> datapointTuples)
{
graphite.Send(datapointTuples);
}

Expand All @@ -60,7 +65,8 @@ public static class GraphiteExtensions{
/// <param name="graphite"></param>
/// <param name="datapoints"></param>
[PublicAPI]
public static void Send(this Graphite graphite, ICollection<Datapoint> datapoints){
public static void Send(this Graphite graphite, ICollection<Datapoint> datapoints)
{
graphite.Send(datapoints);
}

Expand All @@ -70,7 +76,8 @@ public static class GraphiteExtensions{
/// <param name="graphite"></param>
/// <param name="datapoints"></param>
[PublicAPI]
public static void Send(this Graphite graphite, params Datapoint[] datapoints){
public static void Send(this Graphite graphite, params Datapoint[] datapoints)
{
graphite.Send(datapoints);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Cake.Graphite/GraphiteSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ public GraphiteSettings(string host = null, ushort httpApiPort = 443, bool useSs
/// Gets or sets the graphite client metrics prefix (usually used for api key for hosted services like HostedGraphite).
/// </summary>
[PublicAPI]
public string Prefix { get; set; }
public string Prefix { get; set; }
}
}

0 comments on commit 4373c6e

Please sign in to comment.