diff --git a/README.md b/README.md index 51f93e7..5bd8a3f 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,24 @@ A metrics library for .NET inspired by the [codahale metrics] library(http://github.com/codahale/metrics) and [Netflix servo](http://github.com/codahale/metrics). +Must metrics provides a simple interface for exposing and publishing application metrics in C#. The primary goals are: + +* **Flexible Publishing**: Once metrics are exposed, it should be easy to regularly poll the metrics and make them available for internal reporting systems, logs, and services like [Datadog](https://www.datadoghq.com/) and [InfluxDB](https://influxdata.com/). + +This is already been implemented inside of Nohros Inc and mous of our applications currently use it. + +# Project Details + +### Documentation + +* [GitHub Wiki](https://github.com/nohros/must.metrics/wiki) + +### Communication + +* For bugs, feedback, questions and discussions please use [GitHub Issues](https://github.com/nohros/must.metrics/issues). + +More details can be found on the [Getting Started](https://github.com/nohros/must.metrics/wiki/Getting-Started) page of the wiki. + ## Getting Involved We use the Collective Code Construction Contract (http://rfc.zeromq.org/spec:22). collaboration model. diff --git a/must.metrics.sln b/must.metrics.sln new file mode 100644 index 0000000..8a208c6 --- /dev/null +++ b/must.metrics.sln @@ -0,0 +1,45 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "metrics", "src\metrics\metrics.csproj", "{EE140ABF-C917-44D7-B89F-D6946332F507}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "metrics.tests", "src\tests\metrics.tests.csproj", "{876848CE-99F0-4AA1-8468-365204B77123}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EE140ABF-C917-44D7-B89F-D6946332F507}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EE140ABF-C917-44D7-B89F-D6946332F507}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EE140ABF-C917-44D7-B89F-D6946332F507}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {EE140ABF-C917-44D7-B89F-D6946332F507}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {EE140ABF-C917-44D7-B89F-D6946332F507}.Debug|x86.ActiveCfg = Debug|Any CPU + {EE140ABF-C917-44D7-B89F-D6946332F507}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EE140ABF-C917-44D7-B89F-D6946332F507}.Release|Any CPU.Build.0 = Release|Any CPU + {EE140ABF-C917-44D7-B89F-D6946332F507}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {EE140ABF-C917-44D7-B89F-D6946332F507}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {EE140ABF-C917-44D7-B89F-D6946332F507}.Release|x86.ActiveCfg = Release|Any CPU + {876848CE-99F0-4AA1-8468-365204B77123}.Debug|Any CPU.ActiveCfg = Debug|x86 + {876848CE-99F0-4AA1-8468-365204B77123}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {876848CE-99F0-4AA1-8468-365204B77123}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {876848CE-99F0-4AA1-8468-365204B77123}.Debug|x86.ActiveCfg = Debug|x86 + {876848CE-99F0-4AA1-8468-365204B77123}.Debug|x86.Build.0 = Debug|x86 + {876848CE-99F0-4AA1-8468-365204B77123}.Release|Any CPU.ActiveCfg = Release|x86 + {876848CE-99F0-4AA1-8468-365204B77123}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {876848CE-99F0-4AA1-8468-365204B77123}.Release|Mixed Platforms.Build.0 = Release|x86 + {876848CE-99F0-4AA1-8468-365204B77123}.Release|x86.ActiveCfg = Release|x86 + {876848CE-99F0-4AA1-8468-365204B77123}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EnterpriseLibraryConfigurationToolBinariesPath = packages\Unity.2.1.505.2\lib\NET35 + EndGlobalSection +EndGlobal diff --git a/nuget/must-metrics.nuspec b/nuget/must-metrics.nuspec new file mode 100644 index 0000000..b3c913b --- /dev/null +++ b/nuget/must-metrics.nuspec @@ -0,0 +1,28 @@ + + + + must.metrics + 0.16.0.0 + Must - Metrics + Nohros Inc + Nohros Inc + https://github.com/nohros/must.metrics + false + + A metrics library for .NET inspired by the Codahale metrics + library and Netflix servo. + + The metrics package of the nohros must framework. + Nohros Inc + en-US + csharp framework nohros security metrics codahale netflix servo + + + + + + + + + + \ No newline at end of file diff --git a/src/api/App.cs b/src/api/App.cs deleted file mode 100644 index 0a16464..0000000 --- a/src/api/App.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Funq; -using ServiceStack.WebHost.Endpoints; - -namespace Nohros.Metrics.Api -{ - public class App : AppHostBase - { - public App() : base("Nohros Metrics", typeof(App).Assembly) { - } - - public override void Configure(Container container) { - } - } -} \ No newline at end of file diff --git a/src/api/Global.asax b/src/api/Global.asax deleted file mode 100644 index 127a7d8..0000000 --- a/src/api/Global.asax +++ /dev/null @@ -1 +0,0 @@ -<%@ Application Codebehind="Global.asax.cs" Inherits="Nohros.Metrics.Api.Global" Language="C#" %> diff --git a/src/api/Global.asax.cs b/src/api/Global.asax.cs deleted file mode 100644 index df84902..0000000 --- a/src/api/Global.asax.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Web; - -namespace Nohros.Metrics.Api -{ - public class Global : HttpApplication - { - protected void Application_Start(object sender, EventArgs e) { - new App().Init(); - } - - protected void Session_Start(object sender, EventArgs e) { - } - - protected void Application_BeginRequest(object sender, EventArgs e) { - } - - protected void Application_AuthenticateRequest(object sender, EventArgs e) { - } - - protected void Application_Error(object sender, EventArgs e) { - } - - protected void Session_End(object sender, EventArgs e) { - } - - protected void Application_End(object sender, EventArgs e) { - } - } -} diff --git a/src/api/TagsApi.cs b/src/api/TagsApi.cs deleted file mode 100644 index 939cd57..0000000 --- a/src/api/TagsApi.cs +++ /dev/null @@ -1,31 +0,0 @@ -using ServiceStack.ServiceHost; -using ServiceStack.ServiceInterface; - -namespace Nohros.Metrics.Api -{ - [Route("/tags", "GET")] - public class TagsRequest - { - } - - [Route("/tags/{TagName}", "GET")] - public class TagRequest - { - public string TagName { get; set; } - } - - public class TagsResponse - { - } - - public class TagsApi : Service - { - public string Get(TagsRequest request) { - return "tags"; - } - - public string Get(TagRequest request) { - return Request.QueryString.Count.ToString(); - } - } -} diff --git a/src/api/metrics.api.csproj b/src/api/metrics.api.csproj deleted file mode 100644 index b564305..0000000 --- a/src/api/metrics.api.csproj +++ /dev/null @@ -1,135 +0,0 @@ - - - - Debug - AnyCPU - - - 2.0 - {787973E3-7340-42FA-80D1-3BC12CCE90CE} - {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} - Library - Properties - Nohros.Metrics.Api - nohros.metrics.api - v4.0 - false - - - true - full - false - bin\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\ - TRACE - prompt - 4 - - - - - ..\packages\ServiceStack.3.9.71\lib\net35\ServiceStack.dll - - - ..\packages\ServiceStack.Common.3.9.71\lib\net35\ServiceStack.Common.dll - - - ..\packages\ServiceStack.Common.3.9.71\lib\net35\ServiceStack.Interfaces.dll - - - ..\packages\ServiceStack.OrmLite.SqlServer.3.9.14\lib\ServiceStack.OrmLite.dll - - - ..\packages\ServiceStack.OrmLite.SqlServer.3.9.14\lib\ServiceStack.OrmLite.SqlServer.dll - - - ..\packages\ServiceStack.Redis.3.9.11\lib\net35\ServiceStack.Redis.dll - - - ..\packages\ServiceStack.3.9.71\lib\net35\ServiceStack.ServiceInterface.dll - - - ..\packages\ServiceStack.Text.3.9.71\lib\net35\ServiceStack.Text.dll - - - - - - - - - - - - - - - - - - - - - - web.config - - - web.config - - - - - - Global.asax - - - - - - - {78931D53-6DEE-4429-9EBD-F873FD5EEC84} - metrics.data - - - - - - - - - - - - - - - False - True - 1072 - / - - - False - False - - - False - - - - - - \ No newline at end of file diff --git a/src/api/packages.config b/src/api/packages.config deleted file mode 100644 index 52ff3b1..0000000 --- a/src/api/packages.config +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/src/api/properties/AssemblyInfo.cs b/src/api/properties/AssemblyInfo.cs deleted file mode 100644 index b4e80f8..0000000 --- a/src/api/properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("nohros.metrics.api")] -[assembly: AssemblyDescription("nohros.metrics.api")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Nohros Inc")] -[assembly: AssemblyProduct("Nohros Metrics")] -[assembly: AssemblyCopyright("Copyright © 2015 by Nohros Inc")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("96104c82-14c1-4e7e-8f01-acbfbf8189b0")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("0.2.0.0")] -[assembly: AssemblyFileVersion("0.2.0.0")] diff --git a/src/api/web.config b/src/api/web.config deleted file mode 100644 index 4d2f7ca..0000000 --- a/src/api/web.config +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/src/api/web.debug.config b/src/api/web.debug.config deleted file mode 100644 index 962e6b7..0000000 --- a/src/api/web.debug.config +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/src/api/web.release.config b/src/api/web.release.config deleted file mode 100644 index 141832b..0000000 --- a/src/api/web.release.config +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/src/aspnet/AppFactory.cs b/src/aspnet/AppFactory.cs deleted file mode 100644 index e07dba5..0000000 --- a/src/aspnet/AppFactory.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using Nohros.Concurrent; - -namespace Nohros.Metrics -{ - public class AppFactory - { - readonly ISettings settings_; - - #region .ctor - /// - /// Initializes a new instance of the using the - /// specified application settings. - /// - /// - /// A object containig the user configured settings. - /// - public AppFactory(ISettings settings) { - settings_ = settings; - } - #endregion - - public MetricsReporter CreateMetricsApplication() { - var registry = new AsyncMetricsRegistry(Executors.ThreadPoolExecutor()); - return new MetricsReporter(settings_, registry); - } - } -} diff --git a/src/aspnet/Global.asax b/src/aspnet/Global.asax deleted file mode 100644 index d6f0a23..0000000 --- a/src/aspnet/Global.asax +++ /dev/null @@ -1 +0,0 @@ -<%@ Application Codebehind="Global.asax.cs" Inherits="Nohros.Metrics.Global" Language="C#" %> diff --git a/src/aspnet/Global.asax.cs b/src/aspnet/Global.asax.cs deleted file mode 100644 index 32adb1a..0000000 --- a/src/aspnet/Global.asax.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Web; - -namespace Nohros.Metrics -{ - public class Global : HttpApplication - { - protected void Application_Start(object sender, EventArgs e) { - var app = new MetricsReporter(); - } - - protected void Session_Start(object sender, EventArgs e) { - } - - protected void Application_BeginRequest(object sender, EventArgs e) { - } - - protected void Application_AuthenticateRequest(object sender, EventArgs e) { - } - - protected void Application_Error(object sender, EventArgs e) { - } - - protected void Session_End(object sender, EventArgs e) { - } - - protected void Application_End(object sender, EventArgs e) { - } - } -} diff --git a/src/aspnet/MetricsHttpHandler.cs b/src/aspnet/MetricsHttpHandler.cs deleted file mode 100644 index 341cd49..0000000 --- a/src/aspnet/MetricsHttpHandler.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Web; - -namespace Nohros.Metrics -{ - public class MetricsHttpHandler : IHttpHandler - { - public void ProcessRequest(HttpContext context) { - } - - public bool IsReusable { - get { return false; } - } - } -} diff --git a/src/aspnet/aspnet.csproj b/src/aspnet/aspnet.csproj deleted file mode 100644 index 2480635..0000000 --- a/src/aspnet/aspnet.csproj +++ /dev/null @@ -1,124 +0,0 @@ - - - - Debug - AnyCPU - - - 2.0 - {9273D44B-7043-474F-8B35-7CE01C544BCD} - {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} - Library - Properties - Nohros.Metrics - nohros.metrics.aspnet - v4.0 - ..\..\..\..\ - true - - false - - - true - full - false - bin\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\ - TRACE - prompt - 4 - - - - ..\..\..\..\packages\Google.ProtocolBuffers.2.4.1.473\lib\net20\Google.ProtocolBuffers.dll - - - ..\..\..\..\packages\Google.ProtocolBuffers.2.4.1.473\lib\net20\Google.ProtocolBuffers.Serialization.dll - - - - - - - - - - - - - - - - - - - - - - web.config - - - web.config - - - - - - - - - - Global.asax - - - - - - - {903B5354-C424-4ADD-BC2B-892E1AA4342A} - common - - - {EE140ABF-C917-44D7-B89F-D6946332F507} - metrics - - - - - - - - - - - - False - True - 1164 - / - - - False - False - - - False - - - - - - \ No newline at end of file diff --git a/src/aspnet/configuration/ISettings.cs b/src/aspnet/configuration/ISettings.cs deleted file mode 100644 index 2110f99..0000000 --- a/src/aspnet/configuration/ISettings.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace Nohros.Metrics -{ - public interface ISettings - { - int ReportingInterval { get; } - } -} diff --git a/src/aspnet/configuration/Settings.cs b/src/aspnet/configuration/Settings.cs deleted file mode 100644 index 597d952..0000000 --- a/src/aspnet/configuration/Settings.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using Nohros.Configuration; - -namespace Nohros.Metrics -{ - public partial class Settings : Configuration.Configuration - { - public Settings(Builder builder): base(builder) { - } - } -} \ No newline at end of file diff --git a/src/aspnet/configuration/SettingsBuilder.cs b/src/aspnet/configuration/SettingsBuilder.cs deleted file mode 100644 index 580387b..0000000 --- a/src/aspnet/configuration/SettingsBuilder.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using Nohros.Configuration.Builders; - -namespace Nohros.Metrics -{ - public partial class Settings - { - public class Builder : AbstractConfigurationBuilder - { - public override Settings Build() { - return new Settings(this); - } - } - } -} \ No newline at end of file diff --git a/src/aspnet/configuration/SettingsLoader.cs b/src/aspnet/configuration/SettingsLoader.cs deleted file mode 100644 index 7a0d07a..0000000 --- a/src/aspnet/configuration/SettingsLoader.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using Nohros.Configuration; - -namespace Nohros.Metrics -{ - public partial class Settings - { - public class Loader : AbstractConfigurationLoader - { - public Loader() :base(new Builder()) { - } - } - } -} \ No newline at end of file diff --git a/src/aspnet/packages.config b/src/aspnet/packages.config deleted file mode 100644 index 586d886..0000000 --- a/src/aspnet/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/aspnet/properties/AssemblyInfo.cs b/src/aspnet/properties/AssemblyInfo.cs deleted file mode 100644 index ee7d3a7..0000000 --- a/src/aspnet/properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("aspnet")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Nohros Inc")] -[assembly: AssemblyProduct("aspnet")] -[assembly: AssemblyCopyright("Copyright © Nohros Inc 2012")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("9089e121-1aa2-4f22-9780-2c1891c930c8")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/aspnet/web.config b/src/aspnet/web.config deleted file mode 100644 index 1a0aae1..0000000 --- a/src/aspnet/web.config +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - diff --git a/src/aspnet/web.debug.config b/src/aspnet/web.debug.config deleted file mode 100644 index 962e6b7..0000000 --- a/src/aspnet/web.debug.config +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/src/aspnet/web.release.config b/src/aspnet/web.release.config deleted file mode 100644 index 141832b..0000000 --- a/src/aspnet/web.release.config +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/src/benckmarks/BenchMarkAttribute.cs b/src/benckmarks/BenchMarkAttribute.cs deleted file mode 100644 index 11b32bb..0000000 --- a/src/benckmarks/BenchMarkAttribute.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2009 The Noda Time authors. All rights reserved. -// Copyright 2015 Nohros Inc. All rights reserved. -// Use of this source code is governed by the Apache License 2.0, -// as found in the LICENSE.txt file. - -using System; - -namespace Nohros.Metrics.Benchmarks -{ - /// - /// Attribute applied to any method which should be benchmarked. - /// - /// - /// The method must be parametersless, and its containing class must have a - /// parameterless constructor. The constructor will be called just one, - /// before all the tests are run - typically any initialization will just - /// before readonly fields. - /// - [AttributeUsage(AttributeTargets.Method)] - public class BenchmarkAttribute : Attribute - { - } -} \ No newline at end of file diff --git a/src/benckmarks/BenchmarkOptions.cs b/src/benckmarks/BenchmarkOptions.cs deleted file mode 100644 index e8fcf32..0000000 --- a/src/benckmarks/BenchmarkOptions.cs +++ /dev/null @@ -1,135 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Nohros.Metrics.Benchmarks -{ - /// - /// Encapsulates all the operations for benchmarking, such as the approximate - /// length of each test, the timer to use and so on. - /// - public class BenchmarkOptions - { - BenchmarkOptions() { - WarmUpTime = TimeSpan.FromSeconds(1); - TestTime = TimeSpan.FromSeconds(10); - Parallel = 1; - } - - /// - /// Initializes a new instance of the class - /// by using the process command argumants. - /// - /// - /// An instanceo the configured accordingly - /// to the supplied command-line arguments. - /// - /// - /// - public static BenchmarkOptions FromCommandLine() { - CommandLine cmd = CommandLine.ForCurrentProcess; - - int warmup = GetSwitchValueAsInt(cmd, "w", "warmup", 1); - int duration = GetSwitchValueAsInt(cmd, "d", "duration", 10); - int parallel = GetSwitchValueAsInt(cmd, "p", "parallel", 1); - if (parallel <= 0) { - parallel = 1; - } - string type = GetSwitchValue(cmd, "t", "type", null); - string method = GetSwitchValue(cmd, "m", "method", null); - - bool raw = cmd.HasSwitch("r") || cmd.HasSwitch("raw"); - - return new BenchmarkOptions { - MethodFilter = method, - TestTime = TimeSpan.FromSeconds(duration), - WarmUpTime = TimeSpan.FromSeconds(warmup), - Parallel = parallel, - DisplayRawResults = raw - }; - } - - static int GetSwitchValueAsInt(CommandLine cmd, string @switch, - string abbrev, int @default) { - return cmd - .GetSwitchValueAsInt(abbrev, cmd.GetSwitchValueAsInt(@switch, @default)); - } - - static string GetSwitchValue(CommandLine cmd, string @switch, - string abbrev, string @default) { - return cmd.GetSwitchValue(abbrev, cmd.GetSwitchValue(@switch, @default)); - } - - /// - /// Gets a representing the target per-test duration. - /// - /// - /// The default test time is 10 seconds. - /// - public TimeSpan TestTime { get; private set; } - - /// - /// Gets a representing the duration of the warm-up - /// time per test. - /// - /// - /// The default warm-up time is 1 second. - /// - public TimeSpan WarmUpTime { get; private set; } - - /// - /// Gets a string containing the - /// - public string TypeFilter { get; private set; } - - /// - /// Gets a list of categories that should be included in the tests. - /// - /// - /// only the categories listed will be included in the test. - /// - /// If the list is empty all the categories will be tested. - /// - /// - public List IncludedCategories { get; private set; } - - /// - /// Gets a list of categories that should be excluded from the test. - /// - /// - /// If the list is empty no category will be excluded. - /// - public List ExcludedCategories { get; private set; } - - /// - /// Gets a string taht defines the methods that should be tested. - /// - /// - /// The method filter performs the filter by using the method name. It - /// accepts wildcards at the end of filter, i.e MyMethod*.s - /// - public string MethodFilter { get; private set; } - - /// - /// Gets flag that indicates if the test shoud run just one time and - /// without timing, just to validate. - /// - public bool DryRunOnly { get; private set; } - - /// - /// Gets the test label. - /// - public string Label { get; private set; } - - /// - /// Gets the degree of paralellism to be used on test. - /// - /// - /// This option should be used only to test code that is thread-safe. - /// Using it to test non thread-safe code could generate unexpected - /// behavior. - /// - public int Parallel { get; private set; } - - public bool DisplayRawResults { get; private set; } - } -} diff --git a/src/benckmarks/BenchmarkResult.cs b/src/benckmarks/BenchmarkResult.cs deleted file mode 100644 index 93c6189..0000000 --- a/src/benckmarks/BenchmarkResult.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2009 The Noda Time authors. All rights reserved. -// Copyright 2015 Nohros Inc. All rights reserved. -// Use of this source code is governed by the Apache License 2.0, -// as found in the LICENSE.txt file. - -using System; -using System.Reflection; -using Nohros.Extensions.Time; - -namespace Nohros.Metrics.Benchmarks -{ - /// - /// Represents the results of running a single test. - /// - public class BenchmarkResult - { - public BenchmarkResult(MethodInfo method, int iterations, - TimeSpan duration) { - Method = method; - Duration = duration; - Iterations = iterations; - } - - public MethodInfo Method { get; private set; } - public TimeSpan Duration { get; private set; } - - public int Iterations { get; private set; } - - public long CallsPerSecond { - get { return Iterations * TimeUnit.Seconds.ToTicks(1) / Duration.Ticks; } - } - - public long NanosecondsPerCall { - get { return (long)Duration.Convert(TimeUnit.Nanoseconds) / Iterations; } - } - } -} diff --git a/src/benckmarks/BenchmarkResultHandler.cs b/src/benckmarks/BenchmarkResultHandler.cs deleted file mode 100644 index 38c0a7c..0000000 --- a/src/benckmarks/BenchmarkResultHandler.cs +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2009 The Noda Time authors. All rights reserved. -// Copyright 2015 Nohros Inc. All rights reserved. -// Use of this source code is governed by the Apache License 2.0, -// as found in the LICENSE.txt file. - -using System; - -namespace Nohros.Metrics.Benchmarks -{ - /// - /// Handler for benchmark results. - /// - /// - /// While we could have used events on BenchmarkRunner, it's likely that a - /// bunch of these will be customized at the same time, so it makes more - /// sense to make it a normal class. - /// - public class BenchmarkResultHandler - { - /// - /// Method that is called at the very start of the set of tests. - /// - /// - /// A contianing the options used in the - /// associated test. - /// - public virtual void OnStartRun(BenchmarkOptions options) { - } - - /// - /// Method that is called at the very end of the set of tests. - /// - public virtual void OnEndRun() { - } - - /// - /// Method that is called at the start of benchmarks for a single type. - /// - public virtual void OnStartType(Type type) { - } - - /// - /// Method that is called at the end of benchmarks for a single type. - /// - public virtual void OnEndType() { - } - - /// - /// Method that is called once for each test. - /// - public virtual void OnResult(BenchmarkResult result) { - } - - /// - /// Method that is called each time a type or method isn't tested - /// unexpectedly. - /// - /// - /// The reason why the type or method isn't tested unexpectedly. - /// - public virtual void OnWarning(string text) { - } - } -} diff --git a/src/benckmarks/BenchmarkRunner.cs b/src/benckmarks/BenchmarkRunner.cs deleted file mode 100644 index 60e6bf6..0000000 --- a/src/benckmarks/BenchmarkRunner.cs +++ /dev/null @@ -1,218 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Reflection; -using System.Threading.Tasks; -using Nohros.Extensions; - -namespace Nohros.Metrics.Benchmarks -{ - public sealed class BenchmarkRunner - { - class Aggregate - { - public TimeSpan Duration { get; set; } - public TimeSpan Iterations { get; set; } - } - - const BindingFlags kAllInstance = - BindingFlags.Public | - BindingFlags.NonPublic | - BindingFlags.Instance; - - readonly BenchmarkOptions options_; - readonly BenchmarkResultHandler result_handler_; - - public BenchmarkRunner(BenchmarkOptions options, - BenchmarkResultHandler handler) { - options_ = options; - result_handler_ = handler; - } - - /// - /// Run the tests for all types and methods annotated with the - /// attribute in the specified - /// . - /// - /// - /// The assembly containing the types and method to benchmark. - /// - public void Run(Assembly assembly) { - result_handler_.OnStartRun(options_); - - IEnumerable types = - assembly - .GetTypes() - .OrderBy(type => type.FullName) - .Where(type => - type - .GetMethods(kAllInstance) - .Any(IsBenchmark)); - - foreach (Type type in types) { - if (options_.TypeFilter != null && type.Name != options_.TypeFilter) { - continue; - } - - var ctor = type.GetConstructor(Type.EmptyTypes); - if (ctor == null) { - result_handler_.OnWarning(R.EmptyConstructorNotFound.Fmt(type.Name)); - continue; - } - - result_handler_.OnStartType(type); - object instance = ctor.Invoke(null); - IEnumerable methods = - type - .GetMethods(kAllInstance) - .Where(IsBenchmark) - .Where(ShouldBenchmark); - foreach (var method in methods) { - BenchmarkResult result = RunBenchmark(method, instance, options_); - if (result.Duration == TimeSpan.Zero) { - result_handler_.OnWarning(R.ZeroDuration.Fmt(result.Method.Name)); - } - result_handler_.OnResult(result); - } - result_handler_.OnEndType(); - } - result_handler_.OnEndRun(); - } - - /// - /// Verify if the give should be benchmarked. - /// - /// - /// The method to verify. - /// - /// - /// true if the method should be benchmarked; otherwise, false. - /// - bool ShouldBenchmark(MethodInfo method) { - HashSet categories = GetCategories(method); - List include = options_.IncludedCategories; - if (include != null && !categories.Overlaps(include)) { - return false; - } - - List exclude = options_.ExcludedCategories; - if (exclude != null && categories.Overlaps(exclude)) { - return false; - } - - string method_filter = options_.MethodFilter; - if (method_filter != null) { - return - !method_filter.EndsWith("*") - ? method.Name == method_filter - : method - .Name - .StartsWith(method_filter.Substring(0, method_filter.Length - 1)); - } - - if (method.GetParameters().Length != 0) { - result_handler_.OnWarning(R.MethodHasParameters.Fmt(method.Name)); - return false; - } - return true; - } - - static BenchmarkResult RunBenchmark(MethodInfo method, object instance, - BenchmarkOptions options) { - var action = - (Action) Delegate - .CreateDelegate(typeof (Action), instance, method); - - if (options.DryRunOnly) { - action(); - return new BenchmarkResult(method, 1, TimeSpan.FromTicks(1)); - } - - // Start small, double until we've hit our warm-up time - int iterations = 100; - while (true) { - PrepareForTest(); - TimeSpan duration = RunTest(action, iterations); - if (duration >= options.WarmUpTime) { - // Scale up the iterations to work out the full test time - double scale = ((double) options.TestTime.Ticks)/duration.Ticks; - double scaled_iterations = scale*iterations; - - // Make sure we never end up overflowing... - iterations = (int) Math.Min(scaled_iterations, int.MaxValue - 1); - break; - } - // Make sure we don't end up overflowing due to doubling... - if (iterations >= int.MaxValue/2) { - break; - } - iterations *= 2; - } - - if (options.Parallel > 1) { - return RunParallel(method, action, iterations, options.Parallel); - } - - PrepareForTest(); - TimeSpan test_duration = RunTest(action, iterations); - return new BenchmarkResult(method, iterations, test_duration); - } - - static BenchmarkResult RunParallel(MethodInfo method, Action action, - int iterations, int degree) { - TimeSpan duration = TimeSpan.Zero; - var @lock = new object(); - int block_size = (int)Math.Round(iterations * 1.0 / degree, 0); - PrepareForTest(); - Parallel.For(0, degree, - () => TimeSpan.Zero, - (i, pls, partial) => { - TimeSpan test_duration = RunTest(action, block_size); - return test_duration + partial; - }, state => { - lock (@lock) { - duration += state; - } - }); - return new BenchmarkResult(method, block_size*degree, duration); - } - - static TimeSpan RunTest(Action action, int iterations) { - var timer = Stopwatch.StartNew(); - for (int i = 0; i < iterations; i++) { - action(); - } - return timer.Elapsed; - } - - static void PrepareForTest() { - GC.Collect(); - GC.WaitForPendingFinalizers(); - GC.Collect(); - } - - static HashSet GetCategories(MethodInfo method) { - Type attribute = typeof (CategoryAttribute); - IEnumerable categories = - method - .GetCustomAttributes(attribute, false) - .Concat(method.DeclaringType.GetCustomAttributes(attribute, false)) - .Cast() - .Select(c => c.Category); - return new HashSet(categories); - } - - /// - /// Checks if the given is annotated with the - /// attribute. - /// - /// - /// true if the given is annotated with - /// the attribute; otherwise, false. - /// - static bool IsBenchmark(MethodInfo method) { - return method.IsDefined(typeof (BenchmarkAttribute), false); - } - } -} diff --git a/src/benckmarks/CategoryAttribute.cs b/src/benckmarks/CategoryAttribute.cs deleted file mode 100644 index e6436ca..0000000 --- a/src/benckmarks/CategoryAttribute.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; - -namespace Nohros.Metrics.Benchmarks -{ - /// - /// Attibute applied to any benchmark method or class to specify that it - /// belongs in a particular category. - /// - /// - /// Categories can be explicity included or excluded at execution time. - /// When applied to a class, all benchmarks within that class are implicity - /// in that category. - /// - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)] - public class CategoryAttribute : Attribute - { - public CategoryAttribute(string category) { - Category = category; - } - - public string Category { get; private set; } - } -} diff --git a/src/benckmarks/ConsoleResultHandler.cs b/src/benckmarks/ConsoleResultHandler.cs deleted file mode 100644 index 955f1b4..0000000 --- a/src/benckmarks/ConsoleResultHandler.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; - -namespace Nohros.Metrics.Benchmarks -{ - /// - /// An implementation of the that - /// output benchmarks results to the console. - /// - public class ConsoleResultHandler : BenchmarkResultHandler - { - const string kLongFormatString = - " {0}: {1:N0} iterations/second; ({2:N0} iterations in {3:N0} ticks; {4:N0} nanoseconds/iteration)"; - - const string kShortFormatString = - " {0}: {1:N0} iterations/second ({4:N0} nanoseconds/iteration)"; - - readonly string format_string_; - - public ConsoleResultHandler(bool raw_results) { - format_string_ = raw_results ? kLongFormatString : kShortFormatString; - } - - public override void OnStartRun(BenchmarkOptions options) { - Console.WriteLine("Environment: CLR {0} on {1} ({2}) with ", Environment.Version, - Environment.OSVersion, - Environment.Is64BitProcess ? "64 bit" : "32 bit"); - if (options.Label != null) { - Console.WriteLine("Run label: {0}", options.Label); - } - } - - public override void OnStartType(Type type) { - Console.WriteLine("Running benchmarks in {0}", GetTypeDisplayName(type)); - } - - public override void OnResult(BenchmarkResult result) { - Console - .WriteLine(format_string_, - result.Method.Name, - result.CallsPerSecond, - result.Iterations, - result.Duration.Ticks, - result.NanosecondsPerCall); - } - - static string GetTypeDisplayName(Type type) { - return type.FullName.Replace("Nohros.Metrics.Benchmarks.", ""); - } - } -} diff --git a/src/benckmarks/R.Designer.cs b/src/benckmarks/R.Designer.cs deleted file mode 100644 index cd80660..0000000 --- a/src/benckmarks/R.Designer.cs +++ /dev/null @@ -1,90 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.1022 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Nohros.Metrics.Benchmarks { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class R { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal R() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Nohros.Metrics.Benchmarks.R", typeof(R).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Ignoring [{0}]: no public parameterless constructor found.. - /// - internal static string EmptyConstructorNotFound { - get { - return ResourceManager.GetString("EmptyConstructorNotFound", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Ignoring [{0}]: method has parameters.. - /// - internal static string MethodHasParameters { - get { - return ResourceManager.GetString("MethodHasParameters", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Test [{0}] had zero duration; no useful result.. - /// - internal static string ZeroDuration { - get { - return ResourceManager.GetString("ZeroDuration", resourceCulture); - } - } - } -} diff --git a/src/benckmarks/R.resx b/src/benckmarks/R.resx deleted file mode 100644 index 7db90c1..0000000 --- a/src/benckmarks/R.resx +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Ignoring [{0}]: no public parameterless constructor found. - - - Ignoring [{0}]: method has parameters. - - - Test [{0}] had zero duration; no useful result. - - \ No newline at end of file diff --git a/src/benckmarks/metrics.benchmarks.csproj b/src/benckmarks/metrics.benchmarks.csproj deleted file mode 100644 index 73a930e..0000000 --- a/src/benckmarks/metrics.benchmarks.csproj +++ /dev/null @@ -1,77 +0,0 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {27BA651C-7219-4AE5-8C3D-61B046D9DA5B} - Library - Properties - Nohros.Metrics.Benchmarks - nohros.metrics.benchmarks - v4.0 - 512 - - - true - full - false - $(SolutionDir)bin\debug\metrics - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - $(SolutionDir)bin\release\metrics - TRACE - prompt - 4 - - - - ..\packages\must.common.1.15.10.3\lib\net40\nohros.dll - - - - - - - - - - - - - - - - - - - - True - True - R.resx - - - - - ResXFileCodeGenerator - R.Designer.cs - - - - - - - - \ No newline at end of file diff --git a/src/benckmarks/packages.config b/src/benckmarks/packages.config deleted file mode 100644 index bcd5d62..0000000 --- a/src/benckmarks/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/benckmarks/properties/AssemblyInfo.cs b/src/benckmarks/properties/AssemblyInfo.cs deleted file mode 100644 index 25dbffd..0000000 --- a/src/benckmarks/properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("nohros.metrics.benckmarks")] -[assembly: AssemblyDescription("nohros.metrics.benckmarks")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Nohros Inc")] -[assembly: AssemblyProduct("Nohros Metrics")] -[assembly: AssemblyCopyright("Copyright © 2015 by Nohros Inc")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("744c6e05-50ff-4797-88af-5910757acf30")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.2.0.0")] -[assembly: AssemblyFileVersion("0.2.0.0")] diff --git a/src/data/ISerie.cs b/src/data/ISerie.cs deleted file mode 100644 index 46e640e..0000000 --- a/src/data/ISerie.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Nohros.Metrics.Data -{ - /// - /// Represents an item that can be searched for using a set of tags. - /// - public interface ISerie - { - } -} \ No newline at end of file diff --git a/src/data/ITagIndex.cs b/src/data/ITagIndex.cs deleted file mode 100644 index b3fd08f..0000000 --- a/src/data/ITagIndex.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Nohros.Metrics.Data -{ - public interface ITagIndex - { - } -} \ No newline at end of file diff --git a/src/data/TaggedItem.cs b/src/data/TaggedItem.cs deleted file mode 100644 index b1f3eba..0000000 --- a/src/data/TaggedItem.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Numerics; -using System.Security.Cryptography; -using System.Text; - -namespace Nohros.Metrics.Data -{ - /// - /// Represents an item that can be searched for using a set of tags. - /// - public class TaggedItem - { - readonly List tags_; - readonly Lazy id_; - - /// - /// Initializes a new instance of the by - /// using the given collection of . - /// - /// - /// The tags to be associated with this item. - /// - public TaggedItem(IEnumerable tags) { - if (tags == null) { - throw new ArgumentNullException("tags"); - } - - tags_ = new List(tags); - id_ = new Lazy(ComputeId); - } - - /// - /// Compute an identifier for a set of tags. - /// - /// - BigInteger ComputeId() { - var sb = new StringBuilder(); - var tags = tags_.OrderBy(t => t.Name); - foreach (Tag tag in tags) { - sb.Append(tag.Name).Append("=").Append(tag.Value); - } - - byte[] buffer = Encoding.UTF8.GetBytes(sb.ToString()); - HashAlgorithm sha1 = SHA1.Create(); - byte[] hash = sha1.ComputeHash(buffer); - return new BigInteger(hash); - } - - /// - /// Gets a unique identifier based on the contained tags. - /// - /// - /// The is a SHA-1 hash of a normalized string - /// representation and identical tags will always get the same id. Note - /// that producing SHA-1 collision is not easy and no collision for SHA-1 - /// has been produced at yet(at the time of writting), it is possible - /// for two distinct set of tags to produce the same hash. You should take - /// that into account while using the to compare two - /// for equality. - /// - public BigInteger Id { - get { return id_.Value; } - } - } -} diff --git a/src/data/metrics.data.csproj b/src/data/metrics.data.csproj deleted file mode 100644 index 73dd390..0000000 --- a/src/data/metrics.data.csproj +++ /dev/null @@ -1,63 +0,0 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {78931D53-6DEE-4429-9EBD-F873FD5EEC84} - Library - Properties - Nohros.Metrics.Data - nohros.metrics.data - v4.0 - 512 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - {EE140ABF-C917-44D7-B89F-D6946332F507} - metrics - - - - - \ No newline at end of file diff --git a/src/data/properties/AssemblyInfo.cs b/src/data/properties/AssemblyInfo.cs deleted file mode 100644 index d05a361..0000000 --- a/src/data/properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("nohros.metrics.data")] -[assembly: AssemblyDescription("nohros.metrics.data")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Nohros Inc")] -[assembly: AssemblyProduct("Nohros Metrics")] -[assembly: AssemblyCopyright("Copyright © 2015 by Nohros Inc")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("41e72081-dc98-4c4b-9441-9c4d4689cbd3")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.2.0.0")] -[assembly: AssemblyFileVersion("0.2.0.0")] diff --git a/src/library/packages.config b/src/library/packages.config deleted file mode 100644 index 4d1a393..0000000 --- a/src/library/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/library/reporting/PollScheduler.cs b/src/library/reporting/PollScheduler.cs deleted file mode 100644 index 3a17348..0000000 --- a/src/library/reporting/PollScheduler.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Threading; -using Nohros.Concurrent; - -namespace Nohros.Metrics.Reporting -{ - /// - /// A basic scheduler for polling metrics that fetch metrics using a - /// dedicated background thread. - /// - public class PollScheduler - { - readonly IMetricsPoller poller_; - readonly NonReentrantSchedule scheduler_; - - public PollScheduler(IMetricsPoller poller, TimeSpan interval) { - poller_ = poller; - scheduler_ = NonReentrantSchedule.Every(interval); - } - - public void Start() { - scheduler_.Run(poller_.Poll); - } - - public WaitHandle Stop() { - return scheduler_.Stop(); - } - } -} diff --git a/src/library/AppMetrics.cs b/src/metrics/AppMetrics.cs similarity index 100% rename from src/library/AppMetrics.cs rename to src/metrics/AppMetrics.cs diff --git a/src/library/ForwardingMetricsRegistry.cs b/src/metrics/ForwardingMetricsRegistry.cs similarity index 100% rename from src/library/ForwardingMetricsRegistry.cs rename to src/metrics/ForwardingMetricsRegistry.cs diff --git a/src/library/IMetricsRegistry.cs b/src/metrics/IMetricsRegistry.cs similarity index 100% rename from src/library/IMetricsRegistry.cs rename to src/metrics/IMetricsRegistry.cs diff --git a/src/library/MetricAddedEventHandler.cs b/src/metrics/MetricAddedEventHandler.cs similarity index 100% rename from src/library/MetricAddedEventHandler.cs rename to src/metrics/MetricAddedEventHandler.cs diff --git a/src/library/MetricsLogger.cs b/src/metrics/MetricsLogger.cs similarity index 100% rename from src/library/MetricsLogger.cs rename to src/metrics/MetricsLogger.cs diff --git a/src/library/MetricsRegistry.cs b/src/metrics/MetricsRegistry.cs similarity index 100% rename from src/library/MetricsRegistry.cs rename to src/metrics/MetricsRegistry.cs diff --git a/src/library/Resources.Designer.cs b/src/metrics/Resources.Designer.cs similarity index 87% rename from src/library/Resources.Designer.cs rename to src/metrics/Resources.Designer.cs index 84f10a9..b92ed7c 100644 --- a/src/library/Resources.Designer.cs +++ b/src/metrics/Resources.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.18052 +// Runtime Version:4.0.30319.18444 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -78,6 +78,15 @@ internal static string ArgIsNotInRange { } } + /// + /// Looks up a localized string similar to An empty [Action] delegate was supplied do be run on a [MetricsContext]. This is usually a signal that the [Action] was garbage collected.. + /// + internal static string EmptyDelegate { + get { + return ResourceManager.GetString("EmptyDelegate", resourceCulture); + } + } + /// /// Looks up a localized string similar to Both group and type need to be specified. /// diff --git a/src/library/Resources.resx b/src/metrics/Resources.resx similarity index 94% rename from src/library/Resources.resx rename to src/metrics/Resources.resx index 0267a67..ed8145d 100644 --- a/src/library/Resources.resx +++ b/src/metrics/Resources.resx @@ -129,4 +129,7 @@ Field [{0}] in class [{1}] is null. All metric fields must be initialized before registering. + + An empty [Action] delegate was supplied do be run on a [MetricsContext]. This is usually a signal that the [Action] was garbage collected. + \ No newline at end of file diff --git a/src/library/annotations/MetricAttribute.cs b/src/metrics/annotations/MetricAttribute.cs similarity index 100% rename from src/library/annotations/MetricAttribute.cs rename to src/metrics/annotations/MetricAttribute.cs diff --git a/src/library/annotations/TagAttribute.cs b/src/metrics/annotations/TagAttribute.cs similarity index 100% rename from src/library/annotations/TagAttribute.cs rename to src/metrics/annotations/TagAttribute.cs diff --git a/src/library/annotations/TagsAttribute.cs b/src/metrics/annotations/TagsAttribute.cs similarity index 100% rename from src/library/annotations/TagsAttribute.cs rename to src/metrics/annotations/TagsAttribute.cs diff --git a/src/library/core/AbstractMetric.cs b/src/metrics/core/AbstractMetric.cs similarity index 80% rename from src/library/core/AbstractMetric.cs rename to src/metrics/core/AbstractMetric.cs index 6b9ed9c..bcc9337 100644 --- a/src/library/core/AbstractMetric.cs +++ b/src/metrics/core/AbstractMetric.cs @@ -173,37 +173,6 @@ protected virtual Measure CreateMeasure(double measure, DateTime timestamp, /// protected internal abstract Measure Compute(long tick); - /// - /// Computes the current value of a metric, synchrosnouly. - /// - /// - /// The value of for the clock - /// associated with the current context for the time when the - /// method was called. - /// - /// - /// The date and time when the method was called. - /// - /// - /// A containg the current metric's value. - /// - /// - /// Due to the async nature of the metrics methods the - /// could be called some time later - /// than the time when the was called. If a metric - /// rely on the value of property or the - /// to compute the measured value, this delay - /// could produce wrong measures. To avoid this a - /// should use the the value of the as the - /// replacement for the . - /// - /// The method is executed inside - /// the context of the associated . - /// - /// - //protected internal virtual Measure Compute(long tick, DateTime time) { - //return Compute(tick); - //} /// public MetricConfig Config { get; private set; } } diff --git a/src/library/core/AbstractStepMetric.cs b/src/metrics/core/AbstractStepMetric.cs similarity index 100% rename from src/library/core/AbstractStepMetric.cs rename to src/metrics/core/AbstractStepMetric.cs diff --git a/src/library/core/BasicCompositeMetric.cs b/src/metrics/core/BasicCompositeMetric.cs similarity index 100% rename from src/library/core/BasicCompositeMetric.cs rename to src/metrics/core/BasicCompositeMetric.cs diff --git a/src/library/core/BucketTimer.cs b/src/metrics/core/BucketTimer.cs similarity index 95% rename from src/library/core/BucketTimer.cs rename to src/metrics/core/BucketTimer.cs index 448fb0b..59719d7 100644 --- a/src/library/core/BucketTimer.cs +++ b/src/metrics/core/BucketTimer.cs @@ -174,10 +174,11 @@ public BucketTimer Build() { const string kBucket = "metrics.bucket"; const string kStatistic = "statistic"; - const string kTotal = "total"; + const string kTotalTime = "total.time"; + const string kTotalCount = "total.count"; const string kCount = "count"; - const string kMin = "min"; - const string kMax = "max"; + const string kMin = "min.time"; + const string kMax = "max.time"; readonly TimeUnit unit_; readonly TimeUnit rate_unit_; @@ -207,7 +208,7 @@ public BucketTimer(Builder builder) : base(builder.Config, builder.Context) { .Config .WithAdditionalTag("unit", rate_unit_.Name()); - count_ = new StepCounter(config.WithAdditionalTag(kStatistic, kCount), + count_ = new StepCounter(config.WithAdditionalTag(kStatistic, kTotalCount), rate_unit_, context); max_ = new StepMaxGauge(config.WithAdditionalTag(kStatistic, kMax)); min_ = new StepMinGauge(config.WithAdditionalTag(kStatistic, kMin)); @@ -218,7 +219,7 @@ public BucketTimer(Builder builder) : base(builder.Config, builder.Context) { // interval. MetricConfig time_config = config - .WithAdditionalTag(kStatistic, kTotal) + .WithAdditionalTag(kStatistic, kTotalTime) .WithAdditionalTag("unit", "nounit"); total_time_ = new StepCounter(time_config, TimeUnit.Ticks, context); diff --git a/src/library/core/CallableGauge.cs b/src/metrics/core/CallableGauge.cs similarity index 100% rename from src/library/core/CallableGauge.cs rename to src/metrics/core/CallableGauge.cs diff --git a/src/library/core/CompositMetricTransformer.cs b/src/metrics/core/CompositMetricTransformer.cs similarity index 100% rename from src/library/core/CompositMetricTransformer.cs rename to src/metrics/core/CompositMetricTransformer.cs diff --git a/src/library/core/Counter.cs b/src/metrics/core/Counter.cs similarity index 100% rename from src/library/core/Counter.cs rename to src/metrics/core/Counter.cs diff --git a/src/library/core/DoubleGauge.cs b/src/metrics/core/DoubleGauge.cs similarity index 100% rename from src/library/core/DoubleGauge.cs rename to src/metrics/core/DoubleGauge.cs diff --git a/src/library/core/ExponentialWeightedMovingAverage.cs b/src/metrics/core/ExponentialWeightedMovingAverage.cs similarity index 100% rename from src/library/core/ExponentialWeightedMovingAverage.cs rename to src/metrics/core/ExponentialWeightedMovingAverage.cs diff --git a/src/library/core/ExponentialWeightedMovingAverages.cs b/src/metrics/core/ExponentialWeightedMovingAverages.cs similarity index 100% rename from src/library/core/ExponentialWeightedMovingAverages.cs rename to src/metrics/core/ExponentialWeightedMovingAverages.cs diff --git a/src/library/core/ExponentiallyDecayingResevoir.cs b/src/metrics/core/ExponentiallyDecayingResevoir.cs similarity index 100% rename from src/library/core/ExponentiallyDecayingResevoir.cs rename to src/metrics/core/ExponentiallyDecayingResevoir.cs diff --git a/src/library/core/Histogram.cs b/src/metrics/core/Histogram.cs similarity index 100% rename from src/library/core/Histogram.cs rename to src/metrics/core/Histogram.cs diff --git a/src/library/core/ICompositeMetric.cs b/src/metrics/core/ICompositeMetric.cs similarity index 100% rename from src/library/core/ICompositeMetric.cs rename to src/metrics/core/ICompositeMetric.cs diff --git a/src/library/core/ICounter.cs b/src/metrics/core/ICounter.cs similarity index 100% rename from src/library/core/ICounter.cs rename to src/metrics/core/ICounter.cs diff --git a/src/library/core/IGauge.cs b/src/metrics/core/IGauge.cs similarity index 100% rename from src/library/core/IGauge.cs rename to src/metrics/core/IGauge.cs diff --git a/src/library/core/IHistogram.cs b/src/metrics/core/IHistogram.cs similarity index 100% rename from src/library/core/IHistogram.cs rename to src/metrics/core/IHistogram.cs diff --git a/src/library/core/IMeter.cs b/src/metrics/core/IMeter.cs similarity index 100% rename from src/library/core/IMeter.cs rename to src/metrics/core/IMeter.cs diff --git a/src/library/core/IMetric.cs b/src/metrics/core/IMetric.cs similarity index 100% rename from src/library/core/IMetric.cs rename to src/metrics/core/IMetric.cs diff --git a/src/library/core/IResevoir.cs b/src/metrics/core/IResevoir.cs similarity index 100% rename from src/library/core/IResevoir.cs rename to src/metrics/core/IResevoir.cs diff --git a/src/library/core/ISampling.cs b/src/metrics/core/ISampling.cs similarity index 100% rename from src/library/core/ISampling.cs rename to src/metrics/core/ISampling.cs diff --git a/src/library/core/IStepMetric.cs b/src/metrics/core/IStepMetric.cs similarity index 100% rename from src/library/core/IStepMetric.cs rename to src/metrics/core/IStepMetric.cs diff --git a/src/library/core/IStoppable.cs b/src/metrics/core/IStoppable.cs similarity index 100% rename from src/library/core/IStoppable.cs rename to src/metrics/core/IStoppable.cs diff --git a/src/library/core/ISummarizable.cs b/src/metrics/core/ISummarizable.cs similarity index 100% rename from src/library/core/ISummarizable.cs rename to src/metrics/core/ISummarizable.cs diff --git a/src/library/core/ITimer.cs b/src/metrics/core/ITimer.cs similarity index 100% rename from src/library/core/ITimer.cs rename to src/metrics/core/ITimer.cs diff --git a/src/library/core/LongGauge.cs b/src/metrics/core/LongGauge.cs similarity index 100% rename from src/library/core/LongGauge.cs rename to src/metrics/core/LongGauge.cs diff --git a/src/library/core/ManualMeter.cs b/src/metrics/core/ManualMeter.cs similarity index 100% rename from src/library/core/ManualMeter.cs rename to src/metrics/core/ManualMeter.cs diff --git a/src/library/core/MaxGauge.cs b/src/metrics/core/MaxGauge.cs similarity index 100% rename from src/library/core/MaxGauge.cs rename to src/metrics/core/MaxGauge.cs diff --git a/src/library/core/MeanRate.cs b/src/metrics/core/MeanRate.cs similarity index 100% rename from src/library/core/MeanRate.cs rename to src/metrics/core/MeanRate.cs diff --git a/src/library/core/Measure.cs b/src/metrics/core/Measure.cs similarity index 92% rename from src/library/core/Measure.cs rename to src/metrics/core/Measure.cs index b4b6e72..e57e4e5 100644 --- a/src/library/core/Measure.cs +++ b/src/metrics/core/Measure.cs @@ -20,7 +20,7 @@ public class Measure /// The object that has produced the measure. /// public Measure(MetricConfig config, double value) : this(config, value, - DateTime.MinValue) { + DateTime.Now) { } /// @@ -38,7 +38,7 @@ public Measure(MetricConfig config, double value) : this(config, value, /// . /// public Measure(MetricConfig config, double value, bool observable) - : this(config, value, DateTime.MinValue, observable) { + : this(config, value, DateTime.Now, observable) { } /// @@ -80,7 +80,7 @@ public Measure(MetricConfig config, double value, DateTime timestamp, MetricConfig = config; Value = value; IsObservable = observable; - TimeStamp = timestamp; + Timestamp = timestamp; } /// @@ -93,16 +93,16 @@ public Measure(MetricConfig config, double value, DateTime timestamp, /// Gets the instantaneous metric's value /// public double Value { get; private set; } - + /// /// Gets the date and time when the measure was measured. /// /// /// This value is set only for measures of metrics that measure past /// events. Metrics that always measure current events should set the - /// value of . + /// value of . /// - public DateTime TimeStamp { get; private set; } + public DateTime Timestamp { get; private set; } /// /// Gets a value indicating if is observable, which diff --git a/src/library/core/MeasureTransformer.cs b/src/metrics/core/MeasureTransformer.cs similarity index 100% rename from src/library/core/MeasureTransformer.cs rename to src/metrics/core/MeasureTransformer.cs diff --git a/src/library/core/Meter.cs b/src/metrics/core/Meter.cs similarity index 100% rename from src/library/core/Meter.cs rename to src/metrics/core/Meter.cs diff --git a/src/library/core/MetricConfig.cs b/src/metrics/core/MetricConfig.cs similarity index 87% rename from src/library/core/MetricConfig.cs rename to src/metrics/core/MetricConfig.cs index def86c1..278a16a 100644 --- a/src/library/core/MetricConfig.cs +++ b/src/metrics/core/MetricConfig.cs @@ -71,6 +71,16 @@ public MetricConfig WithAdditionalTag(Tag tag) { .Build()); } + /// + /// Gets a copy of the current with an + /// additional . + /// + /// + /// A whose name is equals to + /// and tags is a concatenation of the + /// and a tag which name is and value is + /// . + /// public MetricConfig WithAdditionalTag(string name, string value) { return new MetricConfig(Name, new Tags.Builder(Tags) @@ -141,11 +151,10 @@ public override bool Equals(object obj) { /// ohtherwise, false. /// public bool Equals(MetricConfig config) { - if ((object) config == null) { + if (ReferenceEquals(null, config)) { return false; } - - return (config.Name == Name) && config.Tags.EqualsTo(Tags); + return (config.Name == Name) && config.Tags.Contains(Tags); } /// diff --git a/src/library/core/MetricContext.cs b/src/metrics/core/MetricContext.cs similarity index 77% rename from src/library/core/MetricContext.cs rename to src/metrics/core/MetricContext.cs index afcfb24..f70398b 100644 --- a/src/library/core/MetricContext.cs +++ b/src/metrics/core/MetricContext.cs @@ -1,6 +1,6 @@ using System; -using System.Configuration; using Nohros.Concurrent; +using Nohros.Logging; namespace Nohros.Metrics { @@ -17,7 +17,7 @@ public class MetricContext /// Initializes a new instance of the /// public MetricContext() - : this(new Mailbox(x => x()), new StopwatchClock()) { + : this(new Mailbox(Run), new StopwatchClock()) { } /// @@ -28,7 +28,7 @@ public MetricContext() /// A that can be used to measure the passage of time. /// public MetricContext(Clock clock) - : this(new Mailbox(x => x()), clock) { + : this(new Mailbox(Run), clock) { } /// @@ -63,6 +63,21 @@ static MetricContext() { ForCurrentProcess = new MetricContext(); } + /// + /// Runs the given delegate and ensures that the given + /// is runnable. + /// + /// + /// The delegate to be executed. + /// + static void Run(Action action) { + if (action != null) { + action(); + } else { + MustLogger.ForCurrentProcess.Warn(Resources.EmptyDelegate); + } + } + /// /// Gets the current time tick from the underlying . /// @@ -78,6 +93,9 @@ public long Tick { /// The action to be executed. /// public void Send(Action runnable) { + if (runnable == null) { + throw new ArgumentNullException("runnable"); + } mailbox_.Send(runnable); } diff --git a/src/library/core/MetricType.cs b/src/metrics/core/MetricType.cs similarity index 100% rename from src/library/core/MetricType.cs rename to src/metrics/core/MetricType.cs diff --git a/src/library/core/MinGauge.cs b/src/metrics/core/MinGauge.cs similarity index 100% rename from src/library/core/MinGauge.cs rename to src/metrics/core/MinGauge.cs diff --git a/src/library/core/ResevoirType.cs b/src/metrics/core/ResevoirType.cs similarity index 100% rename from src/library/core/ResevoirType.cs rename to src/metrics/core/ResevoirType.cs diff --git a/src/library/core/Snapshot.cs b/src/metrics/core/Snapshot.cs similarity index 100% rename from src/library/core/Snapshot.cs rename to src/metrics/core/Snapshot.cs diff --git a/src/library/core/SnapshotConfig.cs b/src/metrics/core/SnapshotConfig.cs similarity index 100% rename from src/library/core/SnapshotConfig.cs rename to src/metrics/core/SnapshotConfig.cs diff --git a/src/library/core/StatsTimer.cs b/src/metrics/core/StatsTimer.cs similarity index 100% rename from src/library/core/StatsTimer.cs rename to src/metrics/core/StatsTimer.cs diff --git a/src/library/core/StepCounter.cs b/src/metrics/core/StepCounter.cs similarity index 100% rename from src/library/core/StepCounter.cs rename to src/metrics/core/StepCounter.cs diff --git a/src/library/core/StepMaxGauge.cs b/src/metrics/core/StepMaxGauge.cs similarity index 100% rename from src/library/core/StepMaxGauge.cs rename to src/metrics/core/StepMaxGauge.cs diff --git a/src/library/core/StepMeasureTransformer.cs b/src/metrics/core/StepMeasureTransformer.cs similarity index 100% rename from src/library/core/StepMeasureTransformer.cs rename to src/metrics/core/StepMeasureTransformer.cs diff --git a/src/library/core/StepMinGauge.cs b/src/metrics/core/StepMinGauge.cs similarity index 100% rename from src/library/core/StepMinGauge.cs rename to src/metrics/core/StepMinGauge.cs diff --git a/src/library/core/StopwatchClock.cs b/src/metrics/core/StopwatchClock.cs similarity index 100% rename from src/library/core/StopwatchClock.cs rename to src/metrics/core/StopwatchClock.cs diff --git a/src/library/core/Tag.cs b/src/metrics/core/Tag.cs similarity index 100% rename from src/library/core/Tag.cs rename to src/metrics/core/Tag.cs diff --git a/src/library/core/Tags.cs b/src/metrics/core/Tags.cs similarity index 71% rename from src/library/core/Tags.cs rename to src/metrics/core/Tags.cs index 8061782..b49d42d 100644 --- a/src/library/core/Tags.cs +++ b/src/metrics/core/Tags.cs @@ -15,11 +15,6 @@ public static Tags ToTags(this IEnumerable tags) { /// /// Represents a set of . /// - /// - /// The uses the to compare for - /// equality, which means that there is just one tag with a given name in - /// the set. - /// /// public class Tags : IEnumerable { @@ -154,6 +149,10 @@ public Tags(Tag tag) : this() { /// The collection whose elements are copied to the /// collection. /// + /// + /// If the contain more than one tag with the same + /// name, only the last enumerated tag will be added. + /// public Tags(IEnumerable tags) : this() { foreach (var tag in tags) { tags_[tag.Name] = tag; @@ -161,8 +160,26 @@ public Tags(IEnumerable tags) : this() { } /// - /// Determines whether a object contains all the - /// of the specified tags collection. + /// Determines whether a object contains the + /// specified tags collection. + /// + /// + /// The collection to compare with the current object. + /// + /// + /// true if the current object contains all + /// the of the specified collection. + /// + [Obsolete( + "This method is obsolete. You should use the Contains(IEnumerable) method instead." + , true)] + public bool EquasTo(IEnumerable other) { + return Contains(other); + } + + /// + /// Determines whether a object contains the + /// specified tags collection. /// /// /// The collection to compare with the current object. @@ -171,10 +188,18 @@ public Tags(IEnumerable tags) : this() { /// true if the current object contains all /// the of the specified collection. /// - public bool EqualsTo(IEnumerable other) { + public bool Contains(IEnumerable other) { + if (ReferenceEquals(null, other)) { + return false; + } + + if (ReferenceEquals(this, other)) { + return true; + } return other.All(tag => tags_.ContainsKey(tag.Name)); } + /// IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); @@ -199,7 +224,7 @@ public static Tags Empty { /// /// This should be used only as the /// object id. This field should not be used to compare two tags - /// for equality, because each object will have your own id. + /// for equality, because each object will have its your own id. /// public Guid Id { get; private set; } @@ -210,5 +235,43 @@ public static Tags Empty { public int Count { get { return tags_.Count; } } + + /// + protected bool Equals(Tags other) { + // If the elements of the given tags and the current tags is not equals + // the tags are not the same. + if (other.tags_.Count != tags_.Count) { + return false; + } + return other.All(tag => tags_.ContainsKey(tag.Name)); + } + + /// + public override bool Equals(object obj) { + if (ReferenceEquals(null, obj)) { + return false; + } + + if (ReferenceEquals(this, obj)) { + return true; + } + + if (obj.GetType() != GetType()) { + return false; + } + + return Equals((Tags) obj); + } + + /// + public override int GetHashCode() { + unchecked { + int hash = 17; + foreach (Tag tag in tags_.Values) { + hash = hash*23 + tag.GetHashCode(); + } + return hash; + } + } } } diff --git a/src/library/core/Timer.cs b/src/metrics/core/Timer.cs similarity index 95% rename from src/library/core/Timer.cs rename to src/metrics/core/Timer.cs index 0e0d93d..f59d5a9 100644 --- a/src/library/core/Timer.cs +++ b/src/metrics/core/Timer.cs @@ -14,10 +14,10 @@ namespace Nohros.Metrics public class Timer : AbstractMetric, ICompositeMetric, ITimer { const string kStatistic = "statistic"; - const string kTotal = "total"; + const string kTotal = "total.time"; const string kCount = "count"; - const string kMin = "min"; - const string kMax = "max"; + const string kMin = "min.time"; + const string kMax = "max.time"; readonly TimeUnit unit_; readonly StepCounter count_; diff --git a/src/library/core/TimerContext.cs b/src/metrics/core/TimerContext.cs similarity index 100% rename from src/library/core/TimerContext.cs rename to src/metrics/core/TimerContext.cs diff --git a/src/library/core/UniformResevoir.cs b/src/metrics/core/UniformResevoir.cs similarity index 100% rename from src/library/core/UniformResevoir.cs rename to src/metrics/core/UniformResevoir.cs diff --git a/src/library/core/Unit.cs b/src/metrics/core/Unit.cs similarity index 100% rename from src/library/core/Unit.cs rename to src/metrics/core/Unit.cs diff --git a/src/library/data/TimedQueryExecutor.cs b/src/metrics/data/TimedQueryExecutor.cs similarity index 100% rename from src/library/data/TimedQueryExecutor.cs rename to src/metrics/data/TimedQueryExecutor.cs diff --git a/src/library/metrics.csproj b/src/metrics/metrics.csproj similarity index 94% rename from src/library/metrics.csproj rename to src/metrics/metrics.csproj index e2e1ca8..68df2c2 100644 --- a/src/library/metrics.csproj +++ b/src/metrics/metrics.csproj @@ -35,9 +35,8 @@ $(SolutionDir)bin\release\metrics\nohros.metrics.xml - - False - ..\packages\must.common.1.17.6.0\lib\net40\nohros.dll + + ..\..\packages\must.common.2.2.0.0\lib\net40\nohros.dll @@ -134,7 +133,6 @@ - - \ No newline at end of file diff --git a/src/service/packages.config b/src/service/packages.config deleted file mode 100644 index 47b4e15..0000000 --- a/src/service/packages.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/src/service/properties/AssemblyInfo.cs b/src/service/properties/AssemblyInfo.cs deleted file mode 100644 index fd43ff8..0000000 --- a/src/service/properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("nohros.metrics.service")] -[assembly: AssemblyDescription("nohros.metrics.service")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Nohros Inc.")] -[assembly: AssemblyProduct("nohros.metrics.service")] -[assembly: AssemblyCopyright("Copyright © 2012 by Nohros Inc.")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("cbc09c7e-7b2d-406c-975e-b9192f63c5bd")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.0.1.0")] -[assembly: AssemblyFileVersion("0.0.1.0")] diff --git a/src/service/protos/google/protobuf/csharp_options.proto b/src/service/protos/google/protobuf/csharp_options.proto deleted file mode 100644 index 4718dbe..0000000 --- a/src/service/protos/google/protobuf/csharp_options.proto +++ /dev/null @@ -1,111 +0,0 @@ -// Extra options for C# generator - -import "google/protobuf/descriptor.proto"; - -package google.protobuf; - -message CSharpFileOptions { - - // Namespace for generated classes; defaults to the package. - optional string namespace = 1; - - // Name of the "umbrella" class used for metadata about all - // the messages within this file. Default is based on the name - // of the file. - optional string umbrella_classname = 2; - - // Whether classes should be public (true) or internal (false) - optional bool public_classes = 3 [default = true]; - - // Whether to generate a single file for everything within the - // .proto file (false), or one file per message (true). - // This option is not currently honored; please log a feature - // request if you really want it. - optional bool multiple_files = 4; - - // Whether to nest messages within a single umbrella class (true) - // or create the umbrella class as a peer, with messages as - // top-level classes in the namespace (false) - optional bool nest_classes = 5; - - // Generate appropriate support for Code Contracts - // (Ongoing; support should improve over time) - optional bool code_contracts = 6; - - // Create subdirectories for namespaces, e.g. namespace "Foo.Bar" - // would generate files within [output directory]/Foo/Bar - optional bool expand_namespace_directories = 7; - - // Generate attributes indicating non-CLS-compliance - optional bool cls_compliance = 8 [default = true]; - - // Generate messages/builders with the [Serializable] attribute - optional bool add_serializable = 9 [default = false]; - - // Generates a private ctor for Message types - optional bool generate_private_ctor = 10 [default = true]; - - // The extension that should be appended to the umbrella_classname when creating files. - optional string file_extension = 221 [default = ".cs"]; - - // A nested namespace for the umbrella class. Helpful for name collisions caused by - // umbrella_classname conflicting with an existing type. This will be automatically - // set to 'Proto' if a collision is detected with types being generated. This value - // is ignored when nest_classes == true - optional string umbrella_namespace = 222; - - // The output path for the source file(s) generated - optional string output_directory = 223 [default = "."]; - - // Will ignore the type generations and remove dependencies for the descriptor proto - // files that declare their package to be "google.protobuf" - optional bool ignore_google_protobuf = 224 [default = false]; - - // Controls how services are generated, GENERIC is the deprecated original implementation - // INTERFACE generates service interfaces only, RPCINTEROP generates interfaces and - // implementations using the included Windows RPC interop libarary. - optional CSharpServiceType service_generator_type = 225 [default = NONE]; -} - -enum CSharpServiceType { - // Services are ignored by the generator - NONE = 0; - // Generates the original Java generic service implementations - GENERIC = 1; - // Generates an interface for the service and nothing else - INTERFACE = 2; - // Generates an interface for the service and client/server wrappers for the interface - IRPCDISPATCH = 3; -} - -extend FileOptions { - optional CSharpFileOptions csharp_file_options = 1000; -} - -extend FieldOptions { - optional CSharpFieldOptions csharp_field_options = 1000; -} - -message CSharpFieldOptions { - // Provides the ability to override the name of the property - // generated for this field. This is applied to all properties - // and methods to do with this field, including HasFoo, FooCount, - // FooList etc. - optional string property_name = 1; -} - -message CSharpServiceOptions { - optional string interface_id = 1; -} - -extend ServiceOptions { - optional CSharpServiceOptions csharp_service_options = 1000; -} - -message CSharpMethodOptions { - optional int32 dispatch_id = 1; -} - -extend MethodOptions { - optional CSharpMethodOptions csharp_method_options = 1000; -} \ No newline at end of file diff --git a/src/service/protos/google/protobuf/descriptor.proto b/src/service/protos/google/protobuf/descriptor.proto deleted file mode 100644 index 233f879..0000000 --- a/src/service/protos/google/protobuf/descriptor.proto +++ /dev/null @@ -1,533 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// The messages in this file describe the definitions found in .proto files. -// A valid .proto file can be translated directly to a FileDescriptorProto -// without any other information (e.g. without reading its imports). - - - -package google.protobuf; -option java_package = "com.google.protobuf"; -option java_outer_classname = "DescriptorProtos"; - -// descriptor.proto must be optimized for speed because reflection-based -// algorithms don't work during bootstrapping. -option optimize_for = SPEED; - -// The protocol compiler can output a FileDescriptorSet containing the .proto -// files it parses. -message FileDescriptorSet { - repeated FileDescriptorProto file = 1; -} - -// Describes a complete .proto file. -message FileDescriptorProto { - optional string name = 1; // file name, relative to root of source tree - optional string package = 2; // e.g. "foo", "foo.bar", etc. - - // Names of files imported by this file. - repeated string dependency = 3; - - // All top-level definitions in this file. - repeated DescriptorProto message_type = 4; - repeated EnumDescriptorProto enum_type = 5; - repeated ServiceDescriptorProto service = 6; - repeated FieldDescriptorProto extension = 7; - - optional FileOptions options = 8; - - // This field contains optional information about the original source code. - // You may safely remove this entire field whithout harming runtime - // functionality of the descriptors -- the information is needed only by - // development tools. - optional SourceCodeInfo source_code_info = 9; -} - -// Describes a message type. -message DescriptorProto { - optional string name = 1; - - repeated FieldDescriptorProto field = 2; - repeated FieldDescriptorProto extension = 6; - - repeated DescriptorProto nested_type = 3; - repeated EnumDescriptorProto enum_type = 4; - - message ExtensionRange { - optional int32 start = 1; - optional int32 end = 2; - } - repeated ExtensionRange extension_range = 5; - - optional MessageOptions options = 7; -} - -// Describes a field within a message. -message FieldDescriptorProto { - enum Type { - // 0 is reserved for errors. - // Order is weird for historical reasons. - TYPE_DOUBLE = 1; - TYPE_FLOAT = 2; - TYPE_INT64 = 3; // Not ZigZag encoded. Negative numbers - // take 10 bytes. Use TYPE_SINT64 if negative - // values are likely. - TYPE_UINT64 = 4; - TYPE_INT32 = 5; // Not ZigZag encoded. Negative numbers - // take 10 bytes. Use TYPE_SINT32 if negative - // values are likely. - TYPE_FIXED64 = 6; - TYPE_FIXED32 = 7; - TYPE_BOOL = 8; - TYPE_STRING = 9; - TYPE_GROUP = 10; // Tag-delimited aggregate. - TYPE_MESSAGE = 11; // Length-delimited aggregate. - - // New in version 2. - TYPE_BYTES = 12; - TYPE_UINT32 = 13; - TYPE_ENUM = 14; - TYPE_SFIXED32 = 15; - TYPE_SFIXED64 = 16; - TYPE_SINT32 = 17; // Uses ZigZag encoding. - TYPE_SINT64 = 18; // Uses ZigZag encoding. - }; - - enum Label { - // 0 is reserved for errors - LABEL_OPTIONAL = 1; - LABEL_REQUIRED = 2; - LABEL_REPEATED = 3; - // TODO(sanjay): Should we add LABEL_MAP? - }; - - optional string name = 1; - optional int32 number = 3; - optional Label label = 4; - - // If type_name is set, this need not be set. If both this and type_name - // are set, this must be either TYPE_ENUM or TYPE_MESSAGE. - optional Type type = 5; - - // For message and enum types, this is the name of the type. If the name - // starts with a '.', it is fully-qualified. Otherwise, C++-like scoping - // rules are used to find the type (i.e. first the nested types within this - // message are searched, then within the parent, on up to the root - // namespace). - optional string type_name = 6; - - // For extensions, this is the name of the type being extended. It is - // resolved in the same manner as type_name. - optional string extendee = 2; - - // For numeric types, contains the original text representation of the value. - // For booleans, "true" or "false". - // For strings, contains the default text contents (not escaped in any way). - // For bytes, contains the C escaped value. All bytes >= 128 are escaped. - // TODO(kenton): Base-64 encode? - optional string default_value = 7; - - optional FieldOptions options = 8; -} - -// Describes an enum type. -message EnumDescriptorProto { - optional string name = 1; - - repeated EnumValueDescriptorProto value = 2; - - optional EnumOptions options = 3; -} - -// Describes a value within an enum. -message EnumValueDescriptorProto { - optional string name = 1; - optional int32 number = 2; - - optional EnumValueOptions options = 3; -} - -// Describes a service. -message ServiceDescriptorProto { - optional string name = 1; - repeated MethodDescriptorProto method = 2; - - optional ServiceOptions options = 3; -} - -// Describes a method of a service. -message MethodDescriptorProto { - optional string name = 1; - - // Input and output type names. These are resolved in the same way as - // FieldDescriptorProto.type_name, but must refer to a message type. - optional string input_type = 2; - optional string output_type = 3; - - optional MethodOptions options = 4; -} - -// =================================================================== -// Options - -// Each of the definitions above may have "options" attached. These are -// just annotations which may cause code to be generated slightly differently -// or may contain hints for code that manipulates protocol messages. -// -// Clients may define custom options as extensions of the *Options messages. -// These extensions may not yet be known at parsing time, so the parser cannot -// store the values in them. Instead it stores them in a field in the *Options -// message called uninterpreted_option. This field must have the same name -// across all *Options messages. We then use this field to populate the -// extensions when we build a descriptor, at which point all protos have been -// parsed and so all extensions are known. -// -// Extension numbers for custom options may be chosen as follows: -// * For options which will only be used within a single application or -// organization, or for experimental options, use field numbers 50000 -// through 99999. It is up to you to ensure that you do not use the -// same number for multiple options. -// * For options which will be published and used publicly by multiple -// independent entities, e-mail kenton@google.com to reserve extension -// numbers. Simply tell me how many you need and I'll send you back a -// set of numbers to use -- there's no need to explain how you intend to -// use them. If this turns out to be popular, a web service will be set up -// to automatically assign option numbers. - - -message FileOptions { - - // Sets the Java package where classes generated from this .proto will be - // placed. By default, the proto package is used, but this is often - // inappropriate because proto packages do not normally start with backwards - // domain names. - optional string java_package = 1; - - - // If set, all the classes from the .proto file are wrapped in a single - // outer class with the given name. This applies to both Proto1 - // (equivalent to the old "--one_java_file" option) and Proto2 (where - // a .proto always translates to a single class, but you may want to - // explicitly choose the class name). - optional string java_outer_classname = 8; - - // If set true, then the Java code generator will generate a separate .java - // file for each top-level message, enum, and service defined in the .proto - // file. Thus, these types will *not* be nested inside the outer class - // named by java_outer_classname. However, the outer class will still be - // generated to contain the file's getDescriptor() method as well as any - // top-level extensions defined in the file. - optional bool java_multiple_files = 10 [default=false]; - - // If set true, then the Java code generator will generate equals() and - // hashCode() methods for all messages defined in the .proto file. This is - // purely a speed optimization, as the AbstractMessage base class includes - // reflection-based implementations of these methods. - optional bool java_generate_equals_and_hash = 20 [default=false]; - - // Generated classes can be optimized for speed or code size. - enum OptimizeMode { - SPEED = 1; // Generate complete code for parsing, serialization, - // etc. - CODE_SIZE = 2; // Use ReflectionOps to implement these methods. - LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime. - } - optional OptimizeMode optimize_for = 9 [default=SPEED]; - - - - - // Should generic services be generated in each language? "Generic" services - // are not specific to any particular RPC system. They are generated by the - // main code generators in each language (without additional plugins). - // Generic services were the only kind of service generation supported by - // early versions of proto2. - // - // Generic services are now considered deprecated in favor of using plugins - // that generate code specific to your particular RPC system. Therefore, - // these default to false. Old code which depends on generic services should - // explicitly set them to true. - optional bool cc_generic_services = 16 [default=false]; - optional bool java_generic_services = 17 [default=false]; - optional bool py_generic_services = 18 [default=false]; - - // The parser stores options it doesn't recognize here. See above. - repeated UninterpretedOption uninterpreted_option = 999; - - // Clients can define custom options in extensions of this message. See above. - extensions 1000 to max; -} - -message MessageOptions { - // Set true to use the old proto1 MessageSet wire format for extensions. - // This is provided for backwards-compatibility with the MessageSet wire - // format. You should not use this for any other reason: It's less - // efficient, has fewer features, and is more complicated. - // - // The message must be defined exactly as follows: - // message Foo { - // option message_set_wire_format = true; - // extensions 4 to max; - // } - // Note that the message cannot have any defined fields; MessageSets only - // have extensions. - // - // All extensions of your type must be singular messages; e.g. they cannot - // be int32s, enums, or repeated messages. - // - // Because this is an option, the above two restrictions are not enforced by - // the protocol compiler. - optional bool message_set_wire_format = 1 [default=false]; - - // Disables the generation of the standard "descriptor()" accessor, which can - // conflict with a field of the same name. This is meant to make migration - // from proto1 easier; new code should avoid fields named "descriptor". - optional bool no_standard_descriptor_accessor = 2 [default=false]; - - // The parser stores options it doesn't recognize here. See above. - repeated UninterpretedOption uninterpreted_option = 999; - - // Clients can define custom options in extensions of this message. See above. - extensions 1000 to max; -} - -message FieldOptions { - // The ctype option instructs the C++ code generator to use a different - // representation of the field than it normally would. See the specific - // options below. This option is not yet implemented in the open source - // release -- sorry, we'll try to include it in a future version! - optional CType ctype = 1 [default = STRING]; - enum CType { - // Default mode. - STRING = 0; - - CORD = 1; - - STRING_PIECE = 2; - } - // The packed option can be enabled for repeated primitive fields to enable - // a more efficient representation on the wire. Rather than repeatedly - // writing the tag and type for each element, the entire array is encoded as - // a single length-delimited blob. - optional bool packed = 2; - - - // Is this field deprecated? - // Depending on the target platform, this can emit Deprecated annotations - // for accessors, or it will be completely ignored; in the very least, this - // is a formalization for deprecating fields. - optional bool deprecated = 3 [default=false]; - - // EXPERIMENTAL. DO NOT USE. - // For "map" fields, the name of the field in the enclosed type that - // is the key for this map. For example, suppose we have: - // message Item { - // required string name = 1; - // required string value = 2; - // } - // message Config { - // repeated Item items = 1 [experimental_map_key="name"]; - // } - // In this situation, the map key for Item will be set to "name". - // TODO: Fully-implement this, then remove the "experimental_" prefix. - optional string experimental_map_key = 9; - - // The parser stores options it doesn't recognize here. See above. - repeated UninterpretedOption uninterpreted_option = 999; - - // Clients can define custom options in extensions of this message. See above. - extensions 1000 to max; -} - -message EnumOptions { - - // The parser stores options it doesn't recognize here. See above. - repeated UninterpretedOption uninterpreted_option = 999; - - // Clients can define custom options in extensions of this message. See above. - extensions 1000 to max; -} - -message EnumValueOptions { - // The parser stores options it doesn't recognize here. See above. - repeated UninterpretedOption uninterpreted_option = 999; - - // Clients can define custom options in extensions of this message. See above. - extensions 1000 to max; -} - -message ServiceOptions { - - // Note: Field numbers 1 through 32 are reserved for Google's internal RPC - // framework. We apologize for hoarding these numbers to ourselves, but - // we were already using them long before we decided to release Protocol - // Buffers. - - // The parser stores options it doesn't recognize here. See above. - repeated UninterpretedOption uninterpreted_option = 999; - - // Clients can define custom options in extensions of this message. See above. - extensions 1000 to max; -} - -message MethodOptions { - - // Note: Field numbers 1 through 32 are reserved for Google's internal RPC - // framework. We apologize for hoarding these numbers to ourselves, but - // we were already using them long before we decided to release Protocol - // Buffers. - - // The parser stores options it doesn't recognize here. See above. - repeated UninterpretedOption uninterpreted_option = 999; - - // Clients can define custom options in extensions of this message. See above. - extensions 1000 to max; -} - -// A message representing a option the parser does not recognize. This only -// appears in options protos created by the compiler::Parser class. -// DescriptorPool resolves these when building Descriptor objects. Therefore, -// options protos in descriptor objects (e.g. returned by Descriptor::options(), -// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions -// in them. -message UninterpretedOption { - // The name of the uninterpreted option. Each string represents a segment in - // a dot-separated name. is_extension is true iff a segment represents an - // extension (denoted with parentheses in options specs in .proto files). - // E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents - // "foo.(bar.baz).qux". - message NamePart { - required string name_part = 1; - required bool is_extension = 2; - } - repeated NamePart name = 2; - - // The value of the uninterpreted option, in whatever type the tokenizer - // identified it as during parsing. Exactly one of these should be set. - optional string identifier_value = 3; - optional uint64 positive_int_value = 4; - optional int64 negative_int_value = 5; - optional double double_value = 6; - optional bytes string_value = 7; - optional string aggregate_value = 8; -} - -// =================================================================== -// Optional source code info - -// Encapsulates information about the original source file from which a -// FileDescriptorProto was generated. -message SourceCodeInfo { - // A Location identifies a piece of source code in a .proto file which - // corresponds to a particular definition. This information is intended - // to be useful to IDEs, code indexers, documentation generators, and similar - // tools. - // - // For example, say we have a file like: - // message Foo { - // optional string foo = 1; - // } - // Let's look at just the field definition: - // optional string foo = 1; - // ^ ^^ ^^ ^ ^^^ - // a bc de f ghi - // We have the following locations: - // span path represents - // [a,i) [ 4, 0, 2, 0 ] The whole field definition. - // [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). - // [c,d) [ 4, 0, 2, 0, 5 ] The type (string). - // [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). - // [g,h) [ 4, 0, 2, 0, 3 ] The number (1). - // - // Notes: - // - A location may refer to a repeated field itself (i.e. not to any - // particular index within it). This is used whenever a set of elements are - // logically enclosed in a single code segment. For example, an entire - // extend block (possibly containing multiple extension definitions) will - // have an outer location whose path refers to the "extensions" repeated - // field without an index. - // - Multiple locations may have the same path. This happens when a single - // logical declaration is spread out across multiple places. The most - // obvious example is the "extend" block again -- there may be multiple - // extend blocks in the same scope, each of which will have the same path. - // - A location's span is not always a subset of its parent's span. For - // example, the "extendee" of an extension declaration appears at the - // beginning of the "extend" block and is shared by all extensions within - // the block. - // - Just because a location's span is a subset of some other location's span - // does not mean that it is a descendent. For example, a "group" defines - // both a type and a field in a single declaration. Thus, the locations - // corresponding to the type and field and their components will overlap. - // - Code which tries to interpret locations should probably be designed to - // ignore those that it doesn't understand, as more types of locations could - // be recorded in the future. - repeated Location location = 1; - message Location { - // Identifies which part of the FileDescriptorProto was defined at this - // location. - // - // Each element is a field number or an index. They form a path from - // the root FileDescriptorProto to the place where the definition. For - // example, this path: - // [ 4, 3, 2, 7, 1 ] - // refers to: - // file.message_type(3) // 4, 3 - // .field(7) // 2, 7 - // .name() // 1 - // This is because FileDescriptorProto.message_type has field number 4: - // repeated DescriptorProto message_type = 4; - // and DescriptorProto.field has field number 2: - // repeated FieldDescriptorProto field = 2; - // and FieldDescriptorProto.name has field number 1: - // optional string name = 1; - // - // Thus, the above path gives the location of a field name. If we removed - // the last element: - // [ 4, 3, 2, 7 ] - // this path refers to the whole field declaration (from the beginning - // of the label to the terminating semicolon). - repeated int32 path = 1 [packed=true]; - - // Always has exactly three or four elements: start line, start column, - // end line (optional, otherwise assumed same as start line), end column. - // These are packed into a single field for efficiency. Note that line - // and column numbers are zero-based -- typically you will want to add - // 1 to each before displaying to a user. - repeated int32 span = 2 [packed=true]; - - // TODO(kenton): Record comments appearing before and after the - // declaration. - } -} diff --git a/src/service/protos/local_csharp_proto_parser_generator.py b/src/service/protos/local_csharp_proto_parser_generator.py deleted file mode 100644 index c0a7f50..0000000 --- a/src/service/protos/local_csharp_proto_parser_generator.py +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright (c) 2011 Nohros Inc. All rights reserved. -# Use of this source code is governed by a MIT-style license that can be -# found in the LICENSE file. - -# Call the .proto compiler for a the csharp language using the protobuf-csharp-port -# as the proto compiler. This script was created to be called by double clicking it -# on windows machines. - -import sys -import os -import subprocess - -root = "." - -# Get the subfolders path -subdirs = [subdir for subdir in os.listdir(root) if os.path.isdir(os.path.join(root, subdir))] -subdirs.append('.') -for subdir in subdirs: - if os.path.exists(os.path.join(subdir, 'proto.makefile')): - script = 'proto_parser_generator.py "protogen.exe --include_imports -output_directory=./' + os.path.join(subdir, 'parsers/csharp/') + ' --proto_path=. --proto_path=./'+ subdir + '" ./' + subdir +' .proto' - os.system(script) -os.system('pause') \ No newline at end of file diff --git a/src/service/protos/metrics/metrics.proto b/src/service/protos/metrics/metrics.proto deleted file mode 100644 index 12d311c..0000000 --- a/src/service/protos/metrics/metrics.proto +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2011 Nohros Inc. All rights reserved. -// Use of this source code is governed by a MIT-style license that can be -// found in the LICENSE file. -// - -import "google/protobuf/csharp_options.proto"; -option (google.protobuf.csharp_file_options).namespace = "Nohros.Metrics"; - -package nohros.metrics; -option optimize_for = LITE_RUNTIME; - -enum MessageType { - kStoreMetricsMessage = 100; -} - -// The defintion of a metric. -message MetricProto { - // The name of the metric to store - required string name = 1; - - // The value to store for the metric. - required double value = 2; - - // The timestamp that identify when the metric was collected. - required sint64 timestamp = 3; - - // The unit used to measure the metric. - optional string unit = 4; -} - -// A mesage that is sent to persist the metrics. -message StoreMetricsMessage { - repeated MetricProto metrics = 2; -} \ No newline at end of file diff --git a/src/service/protos/metrics/proto.makefile b/src/service/protos/metrics/proto.makefile deleted file mode 100644 index e69de29..0000000 diff --git a/src/service/protos/proto_parser_generator.py b/src/service/protos/proto_parser_generator.py deleted file mode 100644 index 9da8a93..0000000 --- a/src/service/protos/proto_parser_generator.py +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright (c) 2011 Nohros Inc. All rights reserved. -# Use of this source code is governed by a MIT-style license that can be -# found in the LICENSE file. - -# Call the .proto compiler for a specific language - -import sys -import os -import subprocess - -argv_size = len(sys.argv) -if argv_size != 3 and argv_size != 4: - print("Usage protos_compiler.py PROTO_COMPILER_FILE_PATH [proto dir] [proto extension]") - sys.exit(0) -try: - proto_compiler_file_path = sys.argv[1] - directory = sys.argv[2] - - if argv_size == 4: - extension = sys.argv[3] - else: - extension = ".proto" - - # Find all *.extension files with filter - files = [file for file in os.listdir(directory) if file.endswith(extension)] - - print ("Nohros Inc. Protocol Buffer compiler invocation") - print ("") - print ("Compiling *.protos using: ") - print (" Compiler: " + proto_compiler_file_path) - print (" Proto(s) path: " + directory) - print (" Extension: " + extension) - print (" Amount: " + str(len(files))) - print ("") - - # compile all the proto specified proto files - for file in files: - script = "\"" + proto_compiler_file_path + "\" " + directory + "\\" + file - print ("Executing the compiler script") - print (" " + script) - os.system(script) - -except Exception as inst: - print (inst) - sys.exit(1) \ No newline at end of file diff --git a/src/service/reporting/DynamicServiceReporter.cs b/src/service/reporting/DynamicServiceReporter.cs deleted file mode 100644 index 6505eda..0000000 --- a/src/service/reporting/DynamicServiceReporter.cs +++ /dev/null @@ -1,110 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using Nohros.Concurrent; -using Nohros.Metrics.Reporting; -using Nohros.Ruby; -using Nohros.Ruby.Protocol; -using Nohros.Ruby.Protocol.Control; -using R = Nohros.Resources.StringResources; -using ZmqContext = ZMQ.Context; - -namespace Nohros.Metrics -{ - /// - /// A implementation of the that uses the - /// ruby infrastructure to discover the metrics service. - /// - public class DynamicServiceReporter : IPollingMetricsReporter, - IRubyMessageListener - { - const string kClassName = "Nohros.Metrics.DynamicServiceReporter"; - - readonly MetricsLogger logger_; - readonly IMetricsRegistry registry_; - readonly IRubyServiceHost service_host_; - readonly ZmqContext context_; - - long period_; - MetricPredicate predicate_; - IPollingMetricsReporter reporter_; - TimeUnit period_unit_; - - #region .ctor - public DynamicServiceReporter(IMetricsRegistry registry, - ZmqContext context, IRubyServiceHost service_host) { - service_host_ = service_host; - reporter_ = new NopMetricsReporter(); - period_ = 5; - period_unit_ = TimeUnit.Seconds; - registry_ = registry; - logger_ = MetricsLogger.ForCurrentProcess; - context_ = context; - } - #endregion - - /// - public void Start(long period, TimeUnit unit) { - period_ = period; - period_unit_ = unit; - Start(); - } - - /// - public void Start(long period, TimeUnit unit, MetricPredicate predicate) { - period_ = period; - period_unit_ = unit; - predicate_ = predicate; - Start(); - } - - public void Shutdown(WaitHandle waiter) { - if (reporter_ != null) { - reporter_.Shutdown(waiter); - } - } - - public void Shutdown() { - if (reporter_ != null) { - reporter_.Shutdown(); - } - } - - /// - void IRubyMessageListener.OnMessageReceived(IRubyMessage message) { - switch (message.Type) { - case (int) NodeMessageType.kNodeResponse: - OnQueryResponse(message); - break; - } - } - - void OnQueryResponse(IRubyMessage message) { - try { - ResponseMessage response = ResponseMessage.ParseFrom(message.Message); - KeyValuePair endpoint; - if (KeyValuePairs.Find(RubyStrings.kQueryResponseEndpointKey, - response.ReponsesList, out endpoint)) { - - // create a new reporter using the informations of the found service. - reporter_ = new ServiceReporter(registry_, context_, endpoint.Value); - - if (predicate_ != null) { - reporter_.Start(period_, period_unit_); - } else { - reporter_.Start(period_, period_unit_, predicate_); - } - } - } catch (Exception e) { - logger_.Error( - string.Format(R.Log_MethodThrowsException, "OnQueryResponse", - kClassName), e); - } - } - - /// - void Start() { - service_host_.AddListener(this, Executors.SameThreadExecutor()); - } - } -} diff --git a/src/service/reporting/MetricsLogger.cs b/src/service/reporting/MetricsLogger.cs deleted file mode 100644 index ab02383..0000000 --- a/src/service/reporting/MetricsLogger.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using Nohros.Logging; - -namespace Nohros.Metrics.Reporting -{ - public class MetricsLogger : ForwardingLogger - { - static readonly MetricsLogger current_process_logger_; - - #region .ctor - static MetricsLogger() { - current_process_logger_ = new MetricsLogger(new NOPLogger()); - } - #endregion - - #region .ctor - public MetricsLogger(ILogger logger) : base(logger) { - } - #endregion - - public static MetricsLogger ForCurrentProcess { - get { return current_process_logger_; } - } - } -} diff --git a/src/service/reporting/ServiceReporter.cs b/src/service/reporting/ServiceReporter.cs deleted file mode 100644 index 739e500..0000000 --- a/src/service/reporting/ServiceReporter.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using System.Collections.Generic; -using Nohros.Ruby; -using ZMQ; -using ZmqContext = ZMQ.Context; -using ZmqSocket = ZMQ.Socket; - -namespace Nohros.Metrics.Reporting -{ - /// - /// A simple reporter which sends out application metrics to a metrics - /// service periodically. - /// - public class ServiceReporter : AbstractPollingReporter - { - readonly ZmqContext context_; - readonly string endpoint_; - readonly ZmqSocket socket_; - - #region .ctor - public ServiceReporter(IMetricsRegistry registry, ZmqContext context, - string endpoint) - : base(registry) { - context_ = context; - socket_ = context_.Socket(SocketType.DEALER); - endpoint_ = "tcp://" + endpoint; - } - #endregion - - public override void Start(long period, TimeUnit unit) { - socket_.Connect(endpoint_); - base.Start(period, unit); - } - - public override void Run() { - var registry = MetricsRegistry; - var now = DateTime.UtcNow; - registry.Report(Report, now); - } - - public override void Run(MetricPredicate predicate) { - var registry = MetricsRegistry; - var now = DateTime.UtcNow; - registry.Report(Report, now, predicate); - } - - void Report(KeyValuePair metrics, - DateTime timestamp) { - MetricName name = metrics.Key; - var protos = new StoreMetricsMessage.Builder(); - foreach (MetricValue metric in metrics.Value) { - MetricProto proto = new MetricProto.Builder() - .SetName(metric.Name) - .SetValue(metric.Value) - .SetTimestamp(TimeUnitHelper.ToUnixTime(timestamp.ToUniversalTime())) - .SetUnit(metric.Unit) - .Build(); - protos.AddMetrics(proto); - } - - var packet = RubyMessages.CreateMessagePacket(new byte[0], - (int) MessageType.kStoreMetricsMessage, protos.Build().ToByteArray()); - socket_.Send(packet.ToByteArray(), SendRecvOpt.NOBLOCK); - } - } -} diff --git a/src/service/reporting/ServiceReporterFactory.cs b/src/service/reporting/ServiceReporterFactory.cs deleted file mode 100644 index 1b115a2..0000000 --- a/src/service/reporting/ServiceReporterFactory.cs +++ /dev/null @@ -1,84 +0,0 @@ -using System; -using System.Collections.Generic; -using Nohros.Concurrent; -using Nohros.Ruby; -using R = Nohros.Resources.StringResources; -using ZmqContext = ZMQ.Context; - -namespace Nohros.Metrics.Reporting -{ - public class ServiceReporterFactory : IPollingMetricsReporterFactory - { - delegate IPollingMetricsReporter CreateServiceReporterDelegate( - IDictionary options); - - class Options - { - public string Server { get; set; } - public IMetricsRegistry Registry { get; set; } - } - - public const string kServerEndpoint = "endpoint"; - - readonly CreateServiceReporterDelegate func_; - readonly IMetricsRegistry registry_; - readonly IRubyServiceHost service_host_; - - #region .ctor - /// - /// Initializes a new instance of the . - /// - public ServiceReporterFactory() - : this((IMetricsRegistry) null) { - } - - /// - /// Initializes a new instance of the . - /// - public ServiceReporterFactory(IMetricsRegistry registry) { - registry_ = registry; - func_ = CreateServiceReporter; - } - - public ServiceReporterFactory(IMetricsRegistry registry, - IRubyServiceHost service_host) { - if (service_host == null) { - throw new ArgumentNullException("service_host"); - } - registry_ = registry; - service_host_ = service_host; - func_ = CreateDynamicServiceReporter; - } - - public ServiceReporterFactory(IRubyServiceHost service_host) - : this(null, service_host) { - } - #endregion - - /// - public IPollingMetricsReporter CreatePollingReporter( - IDictionary options) { - return func_(options); - } - - IPollingMetricsReporter CreateServiceReporter( - IDictionary options) { - var context = new ZmqContext(); - string server; - if (!options.TryGetValue(kServerEndpoint, out server)) { - throw new KeyNotFoundException(kServerEndpoint); - } - var registry = registry_ ?? - new AsyncMetricsRegistry(Executors.SameThreadExecutor()); - return new ServiceReporter(registry, context, server); - } - - IPollingMetricsReporter CreateDynamicServiceReporter( - IDictionary options) { - var registry = registry_ ?? - new AsyncMetricsRegistry(Executors.SameThreadExecutor()); - var context = new ZmqContext(); - return new DynamicServiceReporter(registry, context, service_host_); - } - } -} diff --git a/src/service/reporting/metrics.service.reporting.csproj b/src/service/reporting/metrics.service.reporting.csproj deleted file mode 100644 index deeb577..0000000 --- a/src/service/reporting/metrics.service.reporting.csproj +++ /dev/null @@ -1,94 +0,0 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {ECC85468-F9F0-4F95-A4E4-AC3A44FBDEAE} - Library - Properties - Nohros.Metrics - nohros.metrics.service.reporting - v2.0 - 512 - - ..\..\..\..\ - true - - - true - full - false - $(SolutionDir)bin\debug\metrics\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - $(SolutionDir)bin\release\metrics\ - TRACE - prompt - 4 - - - - ..\..\..\..\..\packages\clrzmq.2.2.5\lib\clrzmq.dll - - - ..\..\..\..\..\packages\clrzmq.2.2.5\lib\clrzmq-ext.dll - - - ..\..\..\..\..\packages\Google.ProtocolBuffers.2.4.1.473\lib\net20\Google.ProtocolBuffers.dll - - - ..\..\..\..\..\packages\Google.ProtocolBuffers.2.4.1.473\lib\net20\Google.ProtocolBuffers.Serialization.dll - - - False - ..\..\..\..\..\packages\nohros.ruby.net.0.5.7.2\lib\net20\nohros.ruby.net.dll - - - False - ..\..\..\..\..\packages\nohros.ruby.protos.0.0.3.1\lib\net20\nohros.ruby.protos.dll - - - - - - - - - - - - - - - {903B5354-C424-4ADD-BC2B-892E1AA4342A} - common %28%28base%29\common%29 - - - {EE140ABF-C917-44D7-B89F-D6946332F507} - metrics %28%28metrics%29\metrics%29 - - - - - PreserveNewest - - - - - - - - \ No newline at end of file diff --git a/src/service/reporting/packages.config b/src/service/reporting/packages.config deleted file mode 100644 index 2d3fbf7..0000000 --- a/src/service/reporting/packages.config +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/src/service/reporting/properties/AssemblyInfo.cs b/src/service/reporting/properties/AssemblyInfo.cs deleted file mode 100644 index 97cf2d3..0000000 --- a/src/service/reporting/properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("nohros.metrics.service.reporting")] -[assembly: AssemblyDescription("nohros.metrics.service.reporting")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Nohros Inc")] -[assembly: AssemblyProduct("Nohros Metrics")] -[assembly: AssemblyCopyright("Copyright © 2013 by Nohros Inc")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("0b6d3ecf-dde8-4956-a42a-c8fe447fc86e")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.4.3.0")] -[assembly: AssemblyFileVersion("0.4.3.0")] diff --git a/src/sqlserver/Serie.cs b/src/sqlserver/Serie.cs deleted file mode 100644 index 4959172..0000000 --- a/src/sqlserver/Serie.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Nohros.Metrics.Sql -{ - public class Serie - { - public long Id { get; set; } - public int Hash { get; set; } - public int TagsCount { get; set; } - } -} \ No newline at end of file diff --git a/src/sqlserver/SqlMetricsDao.cs b/src/sqlserver/SqlMetricsDao.cs deleted file mode 100644 index 2b0f024..0000000 --- a/src/sqlserver/SqlMetricsDao.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using Nohros.Data; -using Nohros.Data.SqlServer; - -namespace Nohros.Metrics.Sql -{ - public class SqlMetricsDao - { - readonly SqlConnectionProvider sql_connection_provider_; - readonly SqlQueryExecutor sql_query_executor_; - readonly string schema_; - - public SqlMetricsDao(SqlConnectionProvider sql_connection_provider) { - sql_connection_provider_ = sql_connection_provider; - sql_query_executor_ = new SqlQueryExecutor(sql_connection_provider, - CommandType.StoredProcedure); - schema_ = sql_connection_provider_.Schema; - } - - public IEnumerable GetSeriesIds(string name, int hash, int count) { - using (IQueryMapper mapper = - sql_query_executor_ - .ExecuteQuery(schema_ + ".mtc_get_id_of_serie", - Mappers.Long, - builder => - builder - .AddParameter("@name", name) - .AddParameter("@hash", hash) - .AddParameter("@tags_count", count))) { - return mapper.Map(false); - } - } - - public void RegisterMeasure(long serie_id, double value, DateTime timestamp) { - sql_query_executor_ - .ExecuteNonQuery(schema_ + ".mtc_add_measure", - builder => - builder - .AddParameterWithValue("@measure", value) - .AddParameter("@timestamp", timestamp) - .AddParameter("@serie_id", serie_id)); - } - - public long RegisterSerie(string name, int hash, int count) { - return sql_query_executor_ - .ExecuteScalar(schema_ + ".mtc_add_serie", - builder => - builder - .AddParameter("@name", name) - .AddParameter("@hash", hash) - .AddParameter("@tags_count", count)); - } - - public void RegisterTag(string name, string value, long serie_id) { - sql_query_executor_ - .ExecuteNonQuery(schema_ + ".mtc_add_tag", - builder => - builder - .AddParameter("@name", name) - .AddParameter("@value", value) - .AddParameter("@serie_id", serie_id)); - } - - public bool ContainsTag(string name, string value, long tags_id) { - bool contains; - sql_query_executor_ - .ExecuteScalar(schema_ + ".mtc_serie_contains_tag", - builder => - builder - .AddParameter("@serie_id", tags_id) - .AddParameter("@name", name) - .AddParameter("@value", value), out contains); - return contains; - } - } -} diff --git a/src/sqlserver/SqlMetricsObserver.cs b/src/sqlserver/SqlMetricsObserver.cs deleted file mode 100644 index a178746..0000000 --- a/src/sqlserver/SqlMetricsObserver.cs +++ /dev/null @@ -1,115 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Transactions; -using Nohros.Caching.Providers; -using Nohros.Metrics.Reporting; - -namespace Nohros.Metrics.Sql -{ - public class SqlMetricsObserver : IMeasureObserver - { - const string kClassName = "Nohros.Metrics.SqlMetricsObserver"; - - readonly SqlMetricsDao metrics_dao_; - readonly ICacheProvider cache_; - - /// - /// Initializes a new instance of the - /// by using the given and - /// . - /// - /// - /// A object that can be used to access a sql - /// database. - /// - /// - /// A object that can be used to cache - /// objects. - /// - public SqlMetricsObserver(SqlMetricsDao metrics_dao, ICacheProvider cache) { - metrics_dao_ = metrics_dao; - cache_ = cache; - } - - /// - public void Observe(Measure measure, DateTime timestamp) { - Tags tags = measure.MetricConfig.Tags; - long tags_id = GetTagsId(measure.MetricConfig.Name, tags); - metrics_dao_.RegisterMeasure(tags_id, measure.Value, timestamp); - } - - long GetTagsId(string name, Tags tags) { - long tags_id; - string tags_cache_key = CacheKey(tags); - if (!cache_.Get(tags_cache_key, out tags_id)) { - tags_id = TagsIdFromDatabase(name, tags); - cache_.Set(tags_cache_key, tags_id); - } - return tags_id; - } - - /// - /// Get the id of the from the database or - /// create a new id for the if an id is not found. - /// - /// - /// The name of the that is associated with - /// the . - /// - /// - /// The tags to get the id. - /// - /// - /// A number that uniquely identifies the tags within the metrics database. - /// - long TagsIdFromDatabase(string name, Tags tags) { - int hash = Hash(name, tags); - IEnumerable ids = metrics_dao_.GetSeriesIds(name, hash, tags.Count); - - // The |GetTagsIds| return all the ids that has the same hash and - // number of tags of the given |tags|. We need to find the tags group - // that contains the same tags as |tags|. - foreach (var id in ids) { - if (IsSameTags(id, tags)) { - return id; - } - } - - // A matching tags was not found, lets create a new one. A transaction scope - // is used to endure that all tags related with a given serie is registered. - using (var scope = new TransactionScope(TransactionScopeOption.Required)) { - long serie_id = metrics_dao_.RegisterSerie(name, hash, tags.Count); - foreach (Tag tag in tags) { - metrics_dao_.RegisterTag(tag.Name, tag.Value, serie_id); - } - scope.Complete(); - return serie_id; - } - } - - bool IsSameTags(long serie_id, IEnumerable tags) { - return - tags.All( - tag => - metrics_dao_.ContainsTag(tag.Name, tag.Value, serie_id)); - } - - string CacheKey(Tags tags) { - return kClassName + "::tags::" + tags.Id.ToString("N"); - } - - int Hash(string name, Tags tags) { - var list = tags.ToList(); - list.Sort((a, b) => string.CompareOrdinal(a.Name, b.Name)); - unchecked { - int hash = 17; - hash += name.GetHashCode(); - foreach (var tag in tags) { - hash = hash*31 + tag.GetHashCode(); - } - return hash; - } - } - } -} diff --git a/src/sqlserver/metrics.sqlserver.csproj b/src/sqlserver/metrics.sqlserver.csproj deleted file mode 100644 index a7c1161..0000000 --- a/src/sqlserver/metrics.sqlserver.csproj +++ /dev/null @@ -1,88 +0,0 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {84947A6D-7CD3-4633-BD01-DDABDBEB49F6} - Library - Properties - Nohros.Metrics.Sql - nohros.metrics.sqlserver - v4.0 - 512 - - - true - full - false - $(SolutionDir)bin\debug\metrics - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - $(SolutionDir)bin\release\metrics - TRACE - prompt - 4 - - - - ..\packages\must.common.1.15.10.3\lib\net40\nohros.dll - - - ..\packages\must.data.sqlserver.0.5.8.0\lib\net20\nohros.data.sqlserver.dll - - - - - - - - - - - - - - - - - - - {EA6B35FF-1A1B-46D8-A599-4F9A467C75D1} - common - - - {EE140ABF-C917-44D7-B89F-D6946332F507} - metrics - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/sqlserver/packages.config b/src/sqlserver/packages.config deleted file mode 100644 index 38defe5..0000000 --- a/src/sqlserver/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/sqlserver/properties/AssemblyInfo.cs b/src/sqlserver/properties/AssemblyInfo.cs deleted file mode 100644 index 8784e20..0000000 --- a/src/sqlserver/properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("nohros.metrics.sql")] -[assembly: AssemblyDescription("nohros.metrics.sql")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Nohros Inc")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("Copyright © 2014 by Nohros Inc")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("8ed79398-52ac-4fe4-a64d-180c100cf94d")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.5.0.0")] -[assembly: AssemblyFileVersion("0.5.0.0")] diff --git a/src/sqlserver/scripts/mtc_add_measure.sql b/src/sqlserver/scripts/mtc_add_measure.sql deleted file mode 100644 index d25b9da..0000000 --- a/src/sqlserver/scripts/mtc_add_measure.sql +++ /dev/null @@ -1,47 +0,0 @@ -/* Checks if the current database version is greater - * than the version of this patch. To use this in the - * SSMS the SQLCMD mode should be enabled. - */ -:on error exit - -declare @continue bit, - @objectname varchar(120), - @objectversion int - -set @objectname = 'mtc_add_measure' /* the name of the object related with the script */ -set @objectversion = 1 /* the current object version */ - -exec @continue = nohros_updateversion @objectname=@objectname, @objectversion=@objectversion -if @continue != 1 -begin /* version guard */ - raiserror( - 'The version of the database is greater than the version of this script. The batch will be stopped', 11, 1 - ) -end /* version guard */ - -/* create and empty procedure with the name [@pbjectname]. So, we - * can use the [alter proc [@objectname] statement]. This simulates - * the behavior of the ALTER OR REPLACE statement that exists in other - * datbases products. */ -exec nohros_createproc @name = @objectname -go - -/** - * Copyright (c) 2011 by Nohros Inc, All rights reserved. - */ -alter proc mtc_add_measure ( - @measure float, - @timestamp datetime, - @serie_id bigint -) -as - -insert into mtc_measure ( - measure_value - ,measure_time - ,serie_id -) values ( - @measure - ,@timestamp - ,@serie_id -) \ No newline at end of file diff --git a/src/sqlserver/scripts/mtc_add_serie.sql b/src/sqlserver/scripts/mtc_add_serie.sql deleted file mode 100644 index b09914f..0000000 --- a/src/sqlserver/scripts/mtc_add_serie.sql +++ /dev/null @@ -1,49 +0,0 @@ -/* Checks if the current database version is greater - * than the version of this patch. To use this in the - * SSMS the SQLCMD mode should be enabled. - */ -:on error exit - -declare @continue bit, - @objectname varchar(120), - @objectversion int - -set @objectname = 'mtc_add_serie' /* the name of the object related with the script */ -set @objectversion = 1 /* the current object version */ - -exec @continue = nohros_updateversion @objectname=@objectname, @objectversion=@objectversion -if @continue != 1 -begin /* version guard */ - raiserror( - 'The version of the database is greater than the version of this script. The batch will be stopped', 11, 1 - ) -end /* version guard */ - -/* create and empty procedure with the name [@pbjectname]. So, we - * can use the [alter proc [@objectname] statement]. This simulates - * the behavior of the ALTER OR REPLACE statement that exists in other - * datbases products. */ -exec nohros_createproc @name = @objectname -go - -/** - * Copyright (c) 2011 by Nohros Inc, All rights reserved. - */ -alter proc mtc_add_serie ( - @name varchar(256) - ,@tags_count int - ,@hash int -) -as - -insert into mtc_serie( - serie_name - ,serie_hash - ,serie_tags_count -) values ( - @name - ,@hash - ,@tags_count -) - -select cast(scope_identity() as bigint) \ No newline at end of file diff --git a/src/sqlserver/scripts/mtc_add_tag.sql b/src/sqlserver/scripts/mtc_add_tag.sql deleted file mode 100644 index f347509..0000000 --- a/src/sqlserver/scripts/mtc_add_tag.sql +++ /dev/null @@ -1,75 +0,0 @@ -/* Checks if the current database version is greater - * than the version of this patch. To use this in the - * SSMS the SQLCMD mode should be enabled. - */ -:on error exit - -declare @continue bit, - @objectname varchar(120), - @objectversion int - -set @objectname = 'mtc_add_tag' /* the name of the object related with the script */ -set @objectversion = 1 /* the current object version */ - -exec @continue = nohros_updateversion @objectname=@objectname, @objectversion=@objectversion -if @continue != 1 -begin /* version guard */ - raiserror( - 'The version of the database is greater than the version of this script. The batch will be stopped', 11, 1 - ) -end /* version guard */ - -/* create and empty procedure with the name [@pbjectname]. So, we - * can use the [alter proc [@objectname] statement]. This simulates - * the behavior of the ALTER OR REPLACE statement that exists in other - * datbases products. */ -exec nohros_createproc @name = @objectname -go - -/** - * Copyright (c) 2011 by Nohros Inc, All rights reserved. - */ -alter proc mtc_add_tag ( - @name varchar(800), - @value varchar(800), - @serie_id bigint -) -as - -declare @tag_id bigint - -select @tag_id = tag_id -from mtc_tag -where tag_name = @name - and tag_value = @value - -if (@tag_id is null) -begin - insert into mtc_tag( - tag_name - ,tag_value - ) values ( - @name - ,@value - ) - - set @tag_id = scope_identity() -end - -if not exists( - select tag_id - from mtc_tag_serie - where serie_id = @serie_id - and tag_id = @tag_id -) -begin - insert into mtc_tag_serie( - tag_id - ,serie_id - ) values ( - @tag_id - ,@serie_id - ) -end - -select @tag_id \ No newline at end of file diff --git a/src/sqlserver/scripts/mtc_get_id_of_serie.sql b/src/sqlserver/scripts/mtc_get_id_of_serie.sql deleted file mode 100644 index d0d4a90..0000000 --- a/src/sqlserver/scripts/mtc_get_id_of_serie.sql +++ /dev/null @@ -1,43 +0,0 @@ -/* Checks if the current database version is greater - * than the version of this patch. To use this in the - * SSMS the SQLCMD mode should be enabled. - */ -:on error exit - -declare @continue bit, - @objectname varchar(120), - @objectversion int - -set @objectname = 'mtc_get_id_of_serie' /* the name of the object related with the script */ -set @objectversion = 1 /* the current object version */ - -exec @continue = nohros_updateversion @objectname=@objectname, @objectversion=@objectversion -if @continue != 1 -begin /* version guard */ - raiserror( - 'The version of the database is greater than the version of this script. The batch will be stopped', 11, 1 - ) -end /* version guard */ - -/* create and empty procedure with the name [@pbjectname]. So, we - * can use the [alter proc [@objectname] statement]. This simulates - * the behavior of the ALTER OR REPLACE statement that exists in other - * datbases products. */ -exec nohros_createproc @name = @objectname -go - -/** - * Copyright (c) 2011 by Nohros Inc, All rights reserved. - */ -alter proc mtc_get_id_of_serie ( - @name varchar(256), - @hash int, - @tags_count int -) -as - -select serie_id -from mtc_serie -where serie_hash = @hash - and serie_tags_count = @tags_count - and serie_name = @name \ No newline at end of file diff --git a/src/sqlserver/scripts/mtc_get_id_of_tag.sql b/src/sqlserver/scripts/mtc_get_id_of_tag.sql deleted file mode 100644 index b858109..0000000 --- a/src/sqlserver/scripts/mtc_get_id_of_tag.sql +++ /dev/null @@ -1,41 +0,0 @@ -/* Checks if the current database version is greater - * than the version of this patch. To use this in the - * SSMS the SQLCMD mode should be enabled. - */ -:on error exit - -declare @continue bit, - @objectname varchar(120), - @objectversion int - -set @objectname = 'mtc_get_id_of_tag' /* the name of the object related with the script */ -set @objectversion = 1 /* the current object version */ - -exec @continue = nohros_updateversion @objectname=@objectname, @objectversion=@objectversion -if @continue != 1 -begin /* version guard */ - raiserror( - 'The version of the database is greater than the version of this script. The batch will be stopped', 11, 1 - ) -end /* version guard */ - -/* create and empty procedure with the name [@pbjectname]. So, we - * can use the [alter proc [@objectname] statement]. This simulates - * the behavior of the ALTER OR REPLACE statement that exists in other - * datbases products. */ -exec nohros_createproc @name = @objectname -go - -/** - * Copyright (c) 2011 by Nohros Inc, All rights reserved. - */ -alter proc mtc_get_id_of_tag ( - @name varchar(800), - @value varchar(800) -) -as - -select tag_id -from mtc_tag -where tag_name = @name - and tag_value = @value \ No newline at end of file diff --git a/src/sqlserver/scripts/mtc_measure.sql b/src/sqlserver/scripts/mtc_measure.sql deleted file mode 100644 index ddcde4c..0000000 --- a/src/sqlserver/scripts/mtc_measure.sql +++ /dev/null @@ -1,28 +0,0 @@ -if exists (select name from sys.tables where name = 'mtc_measure') -begin - if (select count(*) from mtc_measure) > 0 - begin - raiserror('A tabela [mtc_measure] contem dados e não pode ser excluida.',16,1) - end - drop table mtc_measure -end -go - -create table mtc_measure ( - serie_id bigint not null, - measure_value float(24) not null, - measure_time datetime2(0) not null -) - -create clustered index IX_mtc_measure_cluster -on mtc_measure ( - measure_time -) - -alter table mtc_measure -add constraint FK_mtc_measure_serie -foreign key ( - serie_id -) references mtc_serie ( - serie_id -) \ No newline at end of file diff --git a/src/sqlserver/scripts/mtc_serie.sql b/src/sqlserver/scripts/mtc_serie.sql deleted file mode 100644 index 457108a..0000000 --- a/src/sqlserver/scripts/mtc_serie.sql +++ /dev/null @@ -1,27 +0,0 @@ -if exists (select name from sys.tables where name = 'mtc_serie') -begin - if (select count(*) from mtc_serie) > 0 - begin - raiserror('A tabela [mtc_serie] contem dados e não pode ser excluida.',16,1) - end - drop table mtc_serie -end -go - -create table mtc_serie ( - serie_id bigint identity(1,1) not null, - serie_name varchar(256) not null, - serie_hash int not null, - serie_tags_count int not null -) - -alter table mtc_serie -add constraint PK_mtc_serie -primary key ( - serie_id -) - -create index IX_mtc_serie_similar -on mtc_serie ( - serie_name, serie_hash, serie_tags_count -) \ No newline at end of file diff --git a/src/sqlserver/scripts/mtc_serie_contains_tag.sql b/src/sqlserver/scripts/mtc_serie_contains_tag.sql deleted file mode 100644 index e81e4f2..0000000 --- a/src/sqlserver/scripts/mtc_serie_contains_tag.sql +++ /dev/null @@ -1,59 +0,0 @@ -/* Checks if the current database version is greater - * than the version of this patch. To use this in the - * SSMS the SQLCMD mode should be enabled. - */ -:on error exit - -declare @continue bit, - @objectname varchar(120), - @objectversion int - -set @objectname = 'mtc_serie_contains_tag' /* the name of the object related with the script */ -set @objectversion = 1 /* the current object version */ - -exec @continue = nohros_updateversion @objectname=@objectname, @objectversion=@objectversion -if @continue != 1 -begin /* version guard */ - raiserror( - 'The version of the database is greater than the version of this script. The batch will be stopped', 11, 1 - ) -end /* version guard */ - -/* create and empty procedure with the name [@pbjectname]. So, we - * can use the [alter proc [@objectname] statement]. This simulates - * the behavior of the ALTER OR REPLACE statement that exists in other - * datbases products. */ -exec nohros_createproc @name = @objectname -go - -/** - * Copyright (c) 2011 by Nohros Inc, All rights reserved. - */ -alter proc mtc_serie_contains_tag ( - @name varchar(800), - @value varchar(800), - @serie_id bigint -) -as - -declare @tag_id bigint - -select @tag_id = tag_id -from mtc_tag -where tag_name = @name - and tag_value = @value - -if @tag_id is not null - and exists( - select tag_id - from mtc_tag_serie - where tag_id = @tag_id - and serie_id = @serie_id - ) -begin - select cast(1 as bit) -end -else -begin - select cast(0 as bit) -end \ No newline at end of file diff --git a/src/sqlserver/scripts/mtc_tag.sql b/src/sqlserver/scripts/mtc_tag.sql deleted file mode 100644 index 426e8e4..0000000 --- a/src/sqlserver/scripts/mtc_tag.sql +++ /dev/null @@ -1,27 +0,0 @@ -if exists (select name from sys.tables where name = 'mtc_tag') -begin - if (select count(*) from mtc_tag) > 0 - begin - raiserror('A tabela [mtc_tag] contem dados e não pode ser excluida.',16,1) - end - drop table mtc_tag -end -go - -create table mtc_tag ( - tag_id bigint identity(1,1) not null, - tag_name varchar(64) not null, - tag_value varchar(128) not null -) - -alter table mtc_tag -add constraint PK_mtc_tag -primary key ( - tag_id -) - -create unique nonclustered index IX_mtc_tag_natural -on mtc_tag ( - tag_name - ,tag_value -) diff --git a/src/sqlserver/scripts/mtc_tag_serie.sql b/src/sqlserver/scripts/mtc_tag_serie.sql deleted file mode 100644 index 57dd2d4..0000000 --- a/src/sqlserver/scripts/mtc_tag_serie.sql +++ /dev/null @@ -1,35 +0,0 @@ -if exists (select name from sys.tables where name = 'mtc_tag_serie') -begin - if (select count(*) from mtc_tag_serie) > 0 - begin - raiserror('A tabela [mtc_tag_serie] contem dados e não pode ser excluida.',16,1) - end - drop table mtc_tag_serie -end -go - -create table mtc_tag_serie ( - serie_id bigint, - tag_id bigint -) - -alter table mtc_tag_serie -add constraint FK_mtc_tag_serie_serie -foreign key ( - serie_id -) references mtc_serie ( - serie_id -) - -alter table mtc_tag_serie -add constraint FK_mtc_tag_serie_tag -foreign key ( - tag_id -) references mtc_tag ( - tag_id -) - -create unique nonclustered index IX_mtc_tag_serie_natural -on mtc_tag_serie ( - tag_id, serie_id -) \ No newline at end of file diff --git a/src/tests/Program.cs b/src/tests/Program.cs deleted file mode 100644 index 824f768..0000000 --- a/src/tests/Program.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using Nohros.Metrics.Benchmarks; - -namespace Nohros.Metrics.Tests -{ - public class Program - { - public static int Main(string[] args) { - var options = BenchmarkOptions.FromCommandLine(); - var handler = new ConsoleResultHandler(options.DisplayRawResults); - var runner = new BenchmarkRunner(options, handler); - runner.Run(typeof (Program).Assembly); - return 1; - } - } -} diff --git a/src/tests/Program2.cs b/src/tests/Program2.cs deleted file mode 100644 index 43ccd6d..0000000 --- a/src/tests/Program2.cs +++ /dev/null @@ -1,158 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Runtime.InteropServices; -using System.Threading; -using Nohros.Concurrent; -using Nohros.Extensions; - -namespace Nohros.Metrics.Tests -{ - public class Program2 - { - public static void Main2(string[] args) { - /*var test = new Test(); - var watch = new Stopwatch(); - - var measures = new List(); - for (int p = 1; p < Environment.ProcessorCount + 1; ++p) { - for (int i = 0; i < 10; i++) { - test.Run(watch, p); - measures.Add(watch.ElapsedMilliseconds); - } - Console.WriteLine("With {0} threads:{1}".Fmt(p, measures.Average())); - }*/ - var timer = BucketTimer.Create("tests", new long[] {10, 100, 500}); - Thread thread = new Thread(Run); - thread.Start(timer); - - var t = new System.Timers.Timer(30000); - t.Elapsed += (sender, event_args) => Poll(timer); - t.Start(); - - Console.WriteLine("Done"); - Console.WriteLine(); - Console.ReadLine(); - - t.Stop(); - } - - static void Poll(IEnumerable metrics) { - foreach (var metric in metrics) { - var composite = metric as ICompositeMetric; - if (composite != null) { - Poll(composite); - } else { - metric.GetMeasure(measure => { - var tags = - measure - .MetricConfig - .Tags - .Select(x=>x.Name + "=" + x.Value) - .Aggregate((t1, t2) => t1 + " " + t2); - Console.WriteLine(tags + " value=" + measure.Value.ToString()); - }); - - //var step = metric as IStepMetric; - //if (step != null) - //step.OnStep(); - } - } - } - - static void Run(object obj) { - BucketTimer timer = obj as BucketTimer; - while (true) { - timer.Time(() => Thread.Sleep(300)); - } - } - - public class Test - { - Mailbox mailbox_1_; - ConcurrentQueue concurrent_; - readonly AutoResetEvent sync_; - - public Test() { - sync_ = new AutoResetEvent(false); - } - - SemaphoreSlim semaphore_; - public void Run(Stopwatch watch, int concurrency) { - mailbox_1_ = new Mailbox(message => {}); - concurrent_ = new ConcurrentQueue(); - semaphore_ = new SemaphoreSlim(concurrency); - - for (int i = 0; i < concurrency - 1; i++) { - new BackgroundThreadFactory() - .CreateThread(new ParameterizedThreadStart(Loop)) - .Start(concurrency); - } - //mailbox_1_.Send(() => Start(watch)); - Start(watch); - Loop(concurrency); - semaphore_.Wait(); - Stop(watch); - //mailbox_1_.Send(() => Stop(watch)); - //sync_.WaitOne(); - } - - void Start(Stopwatch watch) { - watch.Restart(); - } - - void Stop(Stopwatch watch) { - watch.Stop(); - sync_.Set(); - } - - void Loop(object threads) { - semaphore_.Wait(); - for (int i = 0; i < 10000000/(int)threads; i++) { - UpdateAsync(i); - //UpdateAtomic(i); - //Update(i); - //Interlocked.CompareExchange(ref max_, i, i-1); - //Interlocked.Increment(ref max_); - //Interlocked.Increment(ref max_); - //concurrent_.Enqueue(i); - } - semaphore_.Release(); - } - - long max_ = 0; - - void UpdateAsync(long v) { - mailbox_1_.Send(() => Update(v)); - } - - struct Param { - public int method; - public long value; - } - - void Run(Param param) { - switch (param.method) { - case 0: - Update(param.value); - break; - } - } - - void Update(long v) { - max_ += v; - } - - void UpdateAtomic(long v) { - long value = Interlocked.Read(ref max_); - long new_value = value + v; - while (Interlocked.CompareExchange(ref max_, new_value, value) != value) { - value = Interlocked.Read(ref max_); - new_value = value + v; - } - } - } - } -} diff --git a/src/tests/benchmarks/CounterBenchmarks.cs b/src/tests/benchmarks/CounterBenchmarks.cs deleted file mode 100644 index bd0a724..0000000 --- a/src/tests/benchmarks/CounterBenchmarks.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Threading; -using Nohros.Concurrent; -using Nohros.Metrics.Benchmarks; - -namespace Nohros.Metrics.Tests.benchmarks -{ - public class CounterBenchmarks - { - long count_; - readonly Random rand_; - readonly Mailbox mailbox_; - - public CounterBenchmarks() { - rand_ = new Random(); - mailbox_ = new Mailbox(runnable => runnable()); - } - - [Benchmark] - [Category("Atomic")] - public void Atomic() { - Interlocked.Add(ref count_, rand_.Next()); - } - - [Benchmark] - [Category("Mailbox")] - public void Mailbox() { - mailbox_.Send(() => { - count_ += rand_.Next(); - }); - } - } -} diff --git a/src/tests/benchmarks/InterlockedBenchmarks.cs b/src/tests/benchmarks/InterlockedBenchmarks.cs deleted file mode 100644 index be6ad8b..0000000 --- a/src/tests/benchmarks/InterlockedBenchmarks.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Threading; -using Nohros.Concurrent; -using Nohros.Metrics.Benchmarks; - -namespace Nohros.Metrics.Tests.Benchmarks -{ - [Category("Atomic")] - public class InterlockedBenchmarks - { - long curr_count_; - long curr_tick_; - long prev_count_; - long prev_tick_; - double measure_; - readonly object sync_; - readonly Mailbox mailbox_; - - public InterlockedBenchmarks() { - prev_count_ = 0; - curr_count_ = 0; - prev_tick_ = curr_tick_ = 10000; - measure_ = 0; - sync_= new object(); - mailbox_ = new Mailbox(runnable => runnable()); - } - - public void AtomicRead() { - long curr_count = Interlocked.Read(ref curr_count_); - long prev_tick = Interlocked.Read(ref prev_tick_); - long prev_count = Interlocked.Read(ref prev_count_); - Interlocked.Exchange(ref curr_tick_, 10000); - double delta = curr_tick_ - prev_tick; - double measure = (curr_count - prev_count) / delta; - Interlocked.Exchange(ref measure_, measure); - } - - public void ReadWithLock() { - lock (sync_) { - curr_tick_ = Clock.NanoTime; - double delta = curr_tick_ - prev_tick_; - measure_ = (curr_count_ - prev_count_) / (delta + 1); - } - } - - public void ReadWithMailbox() { - long curr_count = curr_count_; - mailbox_.Send(() => { - curr_tick_ = Clock.NanoTime; - double delta = curr_tick_ - prev_tick_; - measure_ = (curr_count - prev_count_) / (delta + 1); - }); - } - - public void Update (int delta) { - Interlocked.Add(ref curr_count_, delta); - } - - public void OnStep(int delta) { - Interlocked.Exchange(ref prev_count_, curr_count_); - Interlocked.Exchange(ref prev_tick_, curr_tick_); - } - } -} diff --git a/src/tests/benchmarks/MaxGaugeBenchmarks.cs b/src/tests/benchmarks/MaxGaugeBenchmarks.cs deleted file mode 100644 index 4432ff6..0000000 --- a/src/tests/benchmarks/MaxGaugeBenchmarks.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Threading; -using Nohros.Concurrent; -using Nohros.Metrics.Benchmarks; - -namespace Nohros.Metrics.Tests.Benchmarks -{ - public class MaxGaugeBenchmarks - { - readonly Mailbox mailbox_; - long max_; - readonly Random rand_; - - public MaxGaugeBenchmarks() { - max_ = 0; - rand_ = new Random(); - mailbox_ = new Mailbox(runnable => runnable()); - } - - [Benchmark] - [Category("Atomic")] - public void Atomic() { - long value = Interlocked.Read(ref max_); - long new_value = value + rand_.Next(); - while (Interlocked.CompareExchange(ref max_, new_value, value) != value) { - value = Interlocked.Read(ref max_); - new_value = value + 10; - } - } - - [Benchmark] - [Category("Mailbox")] - public void Mailbox() { - mailbox_.Send(() => { - long value = rand_.Next(); - if (value > max_) { - max_ = value; - } - }); - } - } -} diff --git a/src/tests/core/BucketTimerTests.cs b/src/tests/core/BucketTimerTests.cs index c38065a..44caa1e 100644 --- a/src/tests/core/BucketTimerTests.cs +++ b/src/tests/core/BucketTimerTests.cs @@ -25,7 +25,7 @@ public void should_measure_the_total_time_per_step() { timer .Metrics .First( - x => x.Config.Tags.FirstOrDefault(t => t.Value == "total") != null); + x => x.Config.Tags.FirstOrDefault(t => t.Value == "total.time") != null); clock.TickNow(1); diff --git a/src/tests/core/StepCounterTests.cs b/src/tests/core/StepCounterTests.cs index ae40f2b..f5b34de 100644 --- a/src/tests/core/StepCounterTests.cs +++ b/src/tests/core/StepCounterTests.cs @@ -23,11 +23,11 @@ public void should_report_the_rate_of_change() { clock.TickNow(1); clock.TickNow(1); - counter.Increment(10); + counter.Increment(20); measure = Testing.Sync(counter, counter.GetMeasure, counter.context_, true); - Assert.That(measure.Value, Is.EqualTo(5d), + Assert.That(measure.Value, Is.EqualTo(10d), "Should report the same value as previously, since the rate was the same."); clock.TickNow(1); diff --git a/src/tests/core/TimerTests.cs b/src/tests/core/TimerTests.cs index 04db267..3479fcf 100644 --- a/src/tests/core/TimerTests.cs +++ b/src/tests/core/TimerTests.cs @@ -18,7 +18,7 @@ public void should_measure_the_percentage_of_total_time_spent() { timer .Metrics .First( - x => x.Config.Tags.FirstOrDefault(t => t.Value == "total") != null); + x => x.Config.Tags.FirstOrDefault(t => t.Value == "total.time") != null); clock.TickNow(1); @@ -78,7 +78,7 @@ public void should_measure_the_maximum_value_per_interval() { timer .Metrics .First( - x => x.Config.Tags.FirstOrDefault(t => t.Value == "max") != null); + x => x.Config.Tags.FirstOrDefault(t => t.Value == "max.time") != null); clock.TickNow(1); @@ -108,7 +108,7 @@ public void should_measure_the_minimum_value_per_interval() { timer .Metrics .First( - x => x.Config.Tags.FirstOrDefault(t => t.Value == "min") != null); + x => x.Config.Tags.FirstOrDefault(t => t.Value == "min.time") != null); clock.TickNow(1); diff --git a/src/tests/metrics.tests.csproj b/src/tests/metrics.tests.csproj index 8b3e555..c34ec1e 100644 --- a/src/tests/metrics.tests.csproj +++ b/src/tests/metrics.tests.csproj @@ -6,7 +6,7 @@ 8.0.30703 2.0 {876848CE-99F0-4AA1-8468-365204B77123} - Exe + Library Properties Nohros.Metrics.Tests nohros.metrics.tests @@ -42,9 +42,6 @@ - - - Code @@ -63,8 +60,6 @@ - - @@ -74,10 +69,10 @@ - ..\packages\must.common.1.15.10.3\lib\net40\nohros.dll + ..\..\packages\must.common.2.2.0.0\lib\net40\nohros.dll - ..\packages\NUnit.2.6.4\lib\nunit.framework.dll + ..\..\packages\NUnit.3.2.1\lib\net40\nunit.framework.dll @@ -86,11 +81,7 @@ - - {27BA651C-7219-4AE5-8C3D-61B046D9DA5B} - metrics.benchmarks - - + {EE140ABF-C917-44D7-B89F-D6946332F507} metrics diff --git a/src/tests/packages.config b/src/tests/packages.config index 73fb877..1201f4a 100644 --- a/src/tests/packages.config +++ b/src/tests/packages.config @@ -1,5 +1,5 @@  - - + + \ No newline at end of file