Skip to content

Commit

Permalink
Removing all trace of AOP, causes many issues having such a heavy dll…
Browse files Browse the repository at this point in the history
… for what should just be formatting, if someone wants it back in, go ahead the codes in here and svn

also had to add some necessary improvs so that we get more messaging formatting options, i.e, inclusion of timestamps and also the ability to convert the message to a specific culture at time of formatting, rather than leaving to the OS to decide, we need this as messages to statsd fail when values are passed in with commma's... so needed to specify a non comma culture on occassions.  shazam.
  • Loading branch information
Emmanuel Acheampong committed Nov 12, 2012
1 parent da13984 commit 63c1a45
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 145 deletions.
6 changes: 1 addition & 5 deletions src/JustEat.StatsD/JustEat.StatsD.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,16 @@
<Reference Include="nunit.framework">
<HintPath>..\..\packages\NUnit.2.6.1\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="PostSharp, Version=2.1.0.0, Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7, processorArchitecture=MSIL">
<HintPath>..\..\packages\PostSharp.2.1.7.18\lib\net20\PostSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DateTimeExtensions.cs" />
<Compile Include="GlobalSuppression.cs" />
<Compile Include="IUdpClient.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RequiresPostSharp.cs" />
<Compile Include="StatsDMonitoringAspect.cs" />
<Compile Include="StatsDMessageFormatter.cs" />
<Compile Include="TestableUdpClient.cs" />
</ItemGroup>
Expand Down
34 changes: 28 additions & 6 deletions src/JustEat.StatsD/StatsDMessageFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ public string Timing(long milliseconds, string statBucket)

public string Timing(long milliseconds, double sampleRate, string statBucket)
{
return Format(sampleRate, string.Format(CultureInfo.CurrentCulture, "{0}:{1:d}|ms", statBucket, milliseconds));
return Format(CultureInfo.CurrentCulture, sampleRate, string.Format(CultureInfo.CurrentCulture, "{0}:{1:d}|ms", statBucket, milliseconds));
}

public string Timing(long milliseconds, double sampleRate, string statBucketn, CultureInfo culture)
{
return Format(culture, sampleRate, string.Format(culture, "{0}:{1:d}|ms", statBucketn, milliseconds));
}

public string Decrement(string statBucket)
{
return Increment(-1, 1.0, statBucket);
Expand Down Expand Up @@ -69,9 +74,15 @@ public string Increment(long magnitude, double sampleRate, string statBucket)
return Format(stat, sampleRate);
}

public string Increment(long magnitude, double sampleRate, string statBucket, CultureInfo culture)
{
var stat = string.Format(culture, "{0}:{1}|c", statBucket, magnitude);
return Format(stat, sampleRate);
}

public string Increment(long magnitude, double sampleRate, params string[] statBuckets)
{
return Format(sampleRate, statBuckets.Select(key => string.Format(CultureInfo.CurrentCulture, "{0}:{1}|c", key, magnitude)).ToArray());
return Format(CultureInfo.CurrentCulture, sampleRate, statBuckets.Select(key => string.Format(CultureInfo.CurrentCulture, "{0}:{1}|c", key, magnitude)).ToArray());
}

public string Gauge(long magnitude, string statBucket)
Expand All @@ -80,12 +91,23 @@ public string Gauge(long magnitude, string statBucket)
return Format(stat, 1.0);
}

public string Gauge(long magnitude, string statBucket, CultureInfo cultureInfo)
{
var stat = string.Format(cultureInfo, "{0}:{1}|g", statBucket, magnitude);
return Format(stat, 1.0);
}

public string Gauge(long magnitude, string statBucket, CultureInfo cultureInfo, DateTime timeStamp)
{
var stat = string.Format(cultureInfo, "{0}:{1}|g|@{2}", statBucket, magnitude, timeStamp.AsUnixTime());
return Format(stat, 1.0);
}
private string Format(String stat, double sampleRate)
{
return Format(sampleRate, stat);
return Format(CultureInfo.CurrentCulture, sampleRate, stat);
}

private string Format(double sampleRate, params string[] stats)
private string Format(IFormatProvider cultureInfo, double sampleRate, params string[] stats)
{
var formatted = new StringBuilder();
if (sampleRate < 1.0)
Expand All @@ -94,15 +116,15 @@ private string Format(double sampleRate, params string[] stats)
{
if (_random.NextDouble() <= sampleRate)
{
formatted.AppendFormat(CultureInfo.CurrentCulture, "{0}|@{1:f}\n", stat, sampleRate);
formatted.AppendFormat(cultureInfo, "{0}|@{1:f}\n", stat, sampleRate);
}
}
}
else
{
foreach (var stat in stats)
{
formatted.AppendFormat(CultureInfo.CurrentCulture, "{0}\n", stat);
formatted.AppendFormat(cultureInfo, "{0}\n", stat);
}
}

Expand Down
64 changes: 0 additions & 64 deletions src/JustEat.StatsD/StatsDMonitoringAspect.cs

This file was deleted.

5 changes: 0 additions & 5 deletions testing/JustEat.StatsD.Tests/JustEat.StatsD.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@
<Reference Include="nunit.framework">
<HintPath>..\..\packages\NUnit.2.6.1\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="PostSharp, Version=2.1.0.0, Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7, processorArchitecture=MSIL">
<HintPath>..\..\packages\PostSharp.2.1.7.18\lib\net20\PostSharp.dll</HintPath>
</Reference>
<Reference Include="Rhino.Mocks">
<HintPath>..\..\packages\RhinoMocks.3.6.1\lib\net\Rhino.Mocks.dll</HintPath>
</Reference>
Expand All @@ -59,11 +56,9 @@
<ItemGroup>
<Compile Include="GlobalSuppression.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RequiresPostSharp.cs" />
<Compile Include="WhenIntegratingAgainstARealStatsD.cs" />
<Compile Include="WhenMetricsHappen.cs" />
<Compile Include="WhenSentViaNLog.cs" />
<Compile Include="WhenTriggeredViaAop.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\JustEat.StatsD\JustEat.StatsD.csproj">
Expand Down
65 changes: 0 additions & 65 deletions testing/JustEat.StatsD.Tests/WhenTriggeredViaAop.cs

This file was deleted.

0 comments on commit 63c1a45

Please sign in to comment.