[banshee] [Hyena.Metrics] New system for instrumenting apps



commit 0023016df1b25d07bdd53f421b829cb129c38c04
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Fri Dec 11 23:11:24 2009 -0800

    [Hyena.Metrics] New system for instrumenting apps

 src/Libraries/Hyena/Hyena.Metrics/DbSampleStore.cs |   57 +++++++++++++++
 src/Libraries/Hyena/Hyena.Metrics/HttpPoster.cs    |   71 ++++++++++++++++++
 src/Libraries/Hyena/Hyena.Metrics/ISampleStore.cs  |   38 ++++++++++
 .../Hyena/Hyena.Metrics/MemorySampleStore.cs       |   52 +++++++++++++
 src/Libraries/Hyena/Hyena.Metrics/Metric.cs        |   53 ++++++++++++++
 .../Hyena/Hyena.Metrics/MetricsCollection.cs       |   77 ++++++++++++++++++++
 src/Libraries/Hyena/Hyena.Metrics/Sample.cs        |   53 ++++++++++++++
 .../Hyena/Hyena.Metrics/Tests/MetricsTests.cs      |   62 ++++++++++++++++
 src/Libraries/Hyena/Hyena.csproj                   |   10 +++
 src/Libraries/Hyena/Hyena/PlatformDetection.cs     |    7 ++
 src/Libraries/Hyena/Makefile.am                    |    8 ++
 11 files changed, 488 insertions(+), 0 deletions(-)
---
diff --git a/src/Libraries/Hyena/Hyena.Metrics/DbSampleStore.cs b/src/Libraries/Hyena/Hyena.Metrics/DbSampleStore.cs
new file mode 100644
index 0000000..76e5b62
--- /dev/null
+++ b/src/Libraries/Hyena/Hyena.Metrics/DbSampleStore.cs
@@ -0,0 +1,57 @@
+//
+// DbSampleStore.cs
+//
+// Author:
+//   Gabriel Burt <gabriel burt gmail com>
+//
+// Copyright (c) 2010 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using Hyena.Data.Sqlite;
+using System.Collections.Generic;
+
+namespace Hyena.Metrics
+{
+    public class DbSampleStore : SqliteModelProvider<Sample>, ISampleStore
+    {
+        private HyenaSqliteConnection conn;
+
+        public DbSampleStore (HyenaSqliteConnection conn, string tableName) : base(conn, tableName, true)
+        {
+            this.conn = conn;
+        }
+
+        public void Add (Sample sample)
+        {
+            Save (sample);
+        }
+
+        public IEnumerable<Sample> GetFor (Metric metric)
+        {
+            return FetchAllMatching ("MetricName = ? ORDER BY Stamp ASC", metric.Name);
+        }
+
+        public void Clear ()
+        {
+            conn.Execute ("DELETE FROM {0}", TableName);
+        }
+    }
+}
diff --git a/src/Libraries/Hyena/Hyena.Metrics/HttpPoster.cs b/src/Libraries/Hyena/Hyena.Metrics/HttpPoster.cs
new file mode 100644
index 0000000..1a37613
--- /dev/null
+++ b/src/Libraries/Hyena/Hyena.Metrics/HttpPoster.cs
@@ -0,0 +1,71 @@
+//
+// HttpPoster.cs
+//
+// Author:
+//   Gabriel Burt <gabriel burt gmail com>
+//
+// Copyright (c) 2010 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using System.IO;
+using System.Net;
+
+/*namespace Hyena.Metrics
+{
+    public class HttpPoster
+    {
+        private string url;
+        private MetricsCollection metrics;
+
+        public void HttpPoster (string url, MetricsCollection metrics)
+        {
+            this.url = url;
+            this.metrics = metrics;
+        }
+
+        public bool Post ()
+        {
+            var request = (HttpWebRequest) WebRequest.Create (url);
+            request.Timeout = 30 * 1000;
+            request.Method = "POST";
+            request.KeepAlive = false;
+            request.ContentType = "text/json";
+            request.AllowAutoRedirect = true;
+
+            try {
+                using (var stream = request.GetRequestStream ()) {
+                    using (var writer = new StreamWriter (stream)) {
+                        foreach (var metric in metrics.Metrics) {
+                            writer.Write (metric.ToString ());
+                        }
+                    }
+                }
+
+                var response = (HttpWebResponse) request.GetResponse ();
+                return response.StatusCode == HttpStatusCode.OK;
+            } catch (Exception e) {
+                Log.Exception ("Error posting metrics", e);
+            }
+
+            return false;
+        }
+    }
+}*/
diff --git a/src/Libraries/Hyena/Hyena.Metrics/ISampleStore.cs b/src/Libraries/Hyena/Hyena.Metrics/ISampleStore.cs
new file mode 100644
index 0000000..40c3c41
--- /dev/null
+++ b/src/Libraries/Hyena/Hyena.Metrics/ISampleStore.cs
@@ -0,0 +1,38 @@
+//
+// ISampleStore.cs
+//
+// Author:
+//   Gabriel Burt <gabriel burt gmail com>
+//
+// Copyright (c) 2010 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using System.Collections.Generic;
+
+namespace Hyena.Metrics
+{
+    public interface ISampleStore
+    {
+        void Add (Sample sample);
+        IEnumerable<Sample> GetFor (Metric metric);
+        void Clear ();
+    }
+}
diff --git a/src/Libraries/Hyena/Hyena.Metrics/MemorySampleStore.cs b/src/Libraries/Hyena/Hyena.Metrics/MemorySampleStore.cs
new file mode 100644
index 0000000..00ad1a4
--- /dev/null
+++ b/src/Libraries/Hyena/Hyena.Metrics/MemorySampleStore.cs
@@ -0,0 +1,52 @@
+//
+// MemorySampleStore.cs
+//
+// Author:
+//   Gabriel Burt <gabriel burt gmail com>
+//
+// Copyright (c) 2010 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using System.Collections.Generic;
+
+namespace Hyena.Metrics
+{
+    public class MemorySampleStore : Dictionary<string, List<Sample>>, ISampleStore
+    {
+        public MemorySampleStore ()
+        {
+        }
+
+        public void Add (Sample sample)
+        {
+            if (!ContainsKey (sample.MetricName)) {
+                this[sample.MetricName] = new List<Sample> ();
+            }
+
+            this[sample.MetricName].Add (sample);
+        }
+
+        public IEnumerable<Sample> GetFor (Metric metric)
+        {
+            return this[metric.Name];
+        }
+    }
+}
diff --git a/src/Libraries/Hyena/Hyena.Metrics/Metric.cs b/src/Libraries/Hyena/Hyena.Metrics/Metric.cs
new file mode 100644
index 0000000..41b78b7
--- /dev/null
+++ b/src/Libraries/Hyena/Hyena.Metrics/Metric.cs
@@ -0,0 +1,53 @@
+//
+// Metric.cs
+//
+// Author:
+//   Gabriel Burt <gabriel burt gmail com>
+//
+// Copyright (c) 2010 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using System.Collections.Generic;
+
+namespace Hyena.Metrics
+{
+    public sealed class Metric
+    {
+        public string Category { get; private set; }
+        public string Name { get; private set; }
+
+        private Func<object> sample_func;
+        private ISampleStore store;
+
+        internal Metric (string category, string name, ISampleStore store, Func<object> sampleFunc)
+        {
+            Category = category;
+            Name = name;
+            this.store = store;
+            sample_func = sampleFunc;
+        }
+
+        public void TakeSample ()
+        {
+            store.Add (new Sample (this, sample_func ()));
+        }
+    }
+}
diff --git a/src/Libraries/Hyena/Hyena.Metrics/MetricsCollection.cs b/src/Libraries/Hyena/Hyena.Metrics/MetricsCollection.cs
new file mode 100644
index 0000000..c3bf367
--- /dev/null
+++ b/src/Libraries/Hyena/Hyena.Metrics/MetricsCollection.cs
@@ -0,0 +1,77 @@
+//
+// MetricsCollection.cs
+//
+// Author:
+//   Gabriel Burt <gabriel burt gmail com>
+//
+// Copyright (c) 2010 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using System.Linq;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Hyena.Metrics
+{
+    public sealed class MetricsCollection : List<Metric>
+    {
+        public string UniqueUserId { get; private set; }
+        public ISampleStore Store { get; private set; }
+
+        public MetricsCollection (string uniqueUserId, ISampleStore store)
+        {
+            UniqueUserId = uniqueUserId;
+            Store = store;
+        }
+
+        public void Add (string category, string metricName, Func<object> sampleFunc)
+        {
+            Add (new Metric (category, metricName, Store, sampleFunc));
+        }
+
+        public override string ToString ()
+        {
+            var sb = new StringBuilder ();
+
+            foreach (var category in this.GroupBy<Metric, string> (m => m.Category)) {
+                sb.AppendFormat ("{0}:\n", category.Key);
+                foreach (var metric in category) {
+                    sb.AppendFormat ("  {0}\n", metric.Name);
+                    foreach (var sample in Store.GetFor (metric)) {
+                        sb.AppendFormat ("    {0}\n", sample.Value);
+                    }
+                }
+            }
+
+            return sb.ToString ();
+        }
+
+        public void AddDefaults ()
+        {
+            Add ("Env", "OS Platform",          () => PlatformDetection.SystemName);
+            Add ("Env", "OS Version",           () => System.Environment.OSVersion);
+            Add ("Env", "Processor Count",      () => System.Environment.ProcessorCount);
+            Add ("Env", ".NET Runtime Version", () => System.Environment.Version);
+            Add ("Env", "Debugging",            () => ApplicationContext.Debugging);
+            Add ("Env", "CultureInfo",          () => System.Globalization.CultureInfo.CurrentCulture.Name);
+        }
+    }
+}
diff --git a/src/Libraries/Hyena/Hyena.Metrics/Sample.cs b/src/Libraries/Hyena/Hyena.Metrics/Sample.cs
new file mode 100644
index 0000000..77adf75
--- /dev/null
+++ b/src/Libraries/Hyena/Hyena.Metrics/Sample.cs
@@ -0,0 +1,53 @@
+//
+// Metric.cs
+//
+// Author:
+//   Gabriel Burt <gabriel burt gmail com>
+//
+// Copyright (c) 2010 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using Hyena.Data.Sqlite;
+
+namespace Hyena.Metrics
+{
+    public class Sample
+    {
+        [DatabaseColumn]
+        public string MetricName { get; protected set; }
+
+        [DatabaseColumn]
+        public DateTime Stamp { get; protected set; }
+
+        [DatabaseColumn]
+        public string Value { get; protected set; }
+
+        // For SqliteModelProvider's use
+        internal Sample () {}
+
+        public Sample (Metric metric, object value)
+        {
+            MetricName = metric.Name;
+            Stamp = DateTime.Now;
+            Value = value == null ? "" : value.ToString ();
+        }
+    }
+}
diff --git a/src/Libraries/Hyena/Hyena.Metrics/Tests/MetricsTests.cs b/src/Libraries/Hyena/Hyena.Metrics/Tests/MetricsTests.cs
new file mode 100644
index 0000000..7d9beac
--- /dev/null
+++ b/src/Libraries/Hyena/Hyena.Metrics/Tests/MetricsTests.cs
@@ -0,0 +1,62 @@
+//
+// MetricsTests.cs
+//
+// Author:
+//   Gabriel Burt <gburt novell com>
+//
+// Copyright (C) 2010 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if ENABLE_TESTS
+
+using System;
+using System.IO;
+using NUnit.Framework;
+
+using Hyena;
+using Hyena.Metrics;
+
+namespace Hyena.Tests
+{
+    [TestFixture]
+    public class MetricsTests
+    {
+        [Test]
+        public void MetricsCollection ()
+        {
+            var metrics = new MetricsCollection ("myuniqueid", new MemorySampleStore ());
+            Assert.AreEqual ("myuniqueid", metrics.UniqueUserId);
+
+            metrics.AddDefaults ();
+            Assert.IsTrue (metrics.Count > 0);
+
+            foreach (var metric in metrics) {
+                metric.TakeSample ();
+            }
+
+            // tests/Makefile.am runs the tests with Locale=it_IT
+            Assert.IsTrue (metrics.ToString ().Contains ("it-IT"));
+        }
+    }
+}
+
+#endif
diff --git a/src/Libraries/Hyena/Hyena.csproj b/src/Libraries/Hyena/Hyena.csproj
index e929cf5..0e72bc8 100644
--- a/src/Libraries/Hyena/Hyena.csproj
+++ b/src/Libraries/Hyena/Hyena.csproj
@@ -34,6 +34,7 @@
     <WarningLevel>4</WarningLevel>
     <Optimize>false</Optimize>
     <OutputPath>..\..\..\bin</OutputPath>
+    <DefineConstants>ENABLE_TESTS</DefineConstants>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Windows|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
@@ -168,6 +169,14 @@
     <Compile Include="System.Web\Helpers.cs" />
     <Compile Include="System.Web\HttpUtility.cs" />
     <Compile Include="Hyena\PlatformDetection.cs" />
+    <Compile Include="Hyena.Metrics\Sample.cs" />
+    <Compile Include="Hyena.Metrics\MetricsCollection.cs" />
+    <Compile Include="Hyena.Metrics\HttpPoster.cs" />
+    <Compile Include="Hyena.Metrics\Metric.cs" />
+    <Compile Include="Hyena.Metrics\DbSampleStore.cs" />
+    <Compile Include="Hyena.Metrics\ISampleStore.cs" />
+    <Compile Include="Hyena.Metrics\Tests\MetricsTests.cs" />
+    <Compile Include="Hyena.Metrics\MemorySampleStore.cs" />
   </ItemGroup>
   <ItemGroup>
     <Reference Include="Mono.Posix">
@@ -182,6 +191,7 @@
     </Reference>
     <Reference Include="System.Data" />
     <Reference Include="System.Xml" />
+    <Reference Include="nunit.core, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\Mono.Data.Sqlite\Mono.Data.Sqlite.csproj">
diff --git a/src/Libraries/Hyena/Hyena/PlatformDetection.cs b/src/Libraries/Hyena/Hyena/PlatformDetection.cs
index 26e2b20..303ce79 100644
--- a/src/Libraries/Hyena/Hyena/PlatformDetection.cs
+++ b/src/Libraries/Hyena/Hyena/PlatformDetection.cs
@@ -40,6 +40,7 @@ namespace Hyena
         public static readonly bool IsMoblin;
 
         public static readonly string PosixSystemName;
+        public static readonly string SystemName;
 
         [DllImport ("libc")]
         private static extern int uname (IntPtr utsname);
@@ -52,6 +53,7 @@ namespace Hyena
             IsWindows = p < 4;
 
             if (IsWindows) {
+                SystemName = "Windows";
                 return;
             }
 
@@ -75,6 +77,9 @@ namespace Hyena
             }
 
             if (PosixSystemName == null) {
+                if (IsUnix) {
+                    SystemName = "Unix";
+                }
                 return;
             }
 
@@ -83,6 +88,8 @@ namespace Hyena
                 case "Linux": IsLinux = true; break;
             }
 
+            SystemName = PosixSystemName;
+
             // FIXME: probe the root X11 window for Moblin properties
         }
     }
diff --git a/src/Libraries/Hyena/Makefile.am b/src/Libraries/Hyena/Makefile.am
index e36b92c..814e47a 100644
--- a/src/Libraries/Hyena/Makefile.am
+++ b/src/Libraries/Hyena/Makefile.am
@@ -66,6 +66,14 @@ SOURCES =  \
 	Hyena.Json/Token.cs \
 	Hyena.Json/Tokenizer.cs \
 	Hyena.Json/TokenType.cs \
+	Hyena.Metrics/DbSampleStore.cs \
+	Hyena.Metrics/HttpPoster.cs \
+	Hyena.Metrics/ISampleStore.cs \
+	Hyena.Metrics/MemorySampleStore.cs \
+	Hyena.Metrics/Metric.cs \
+	Hyena.Metrics/MetricsCollection.cs \
+	Hyena.Metrics/Sample.cs \
+	Hyena.Metrics/Tests/MetricsTests.cs \
 	Hyena.Query/AliasedObjectSet.cs \
 	Hyena.Query/DateQueryValue.cs \
 	Hyena.Query/EnumQueryValue.cs \



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]