[banshee] [extras/metrics] New project to load/analyze metrics data
- From: Gabriel Burt <gburt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] [extras/metrics] New project to load/analyze metrics data
- Date: Fri, 19 Feb 2010 01:59:46 +0000 (UTC)
commit c97c1b70083f556681b119b60ef8158009977926
Author: Gabriel Burt <gabriel burt gmail com>
Date: Fri Feb 12 22:01:16 2010 -0800
[extras/metrics] New project to load/analyze metrics data
Includes a fetch-metrics script to tar/fetch the metrics from
banshee-project.org, and some C# for parsing the metrics and putting
them into a sqlite db.
Banshee.sln | 9 ++++
extras/metrics/CreateMetricsDb.cs | 78 +++++++++++++++++++++++++++++++++++++
extras/metrics/MultiUserSample.cs | 69 ++++++++++++++++++++++++++++++++
extras/metrics/fetch-metrics | 11 +++++
extras/metrics/metrics.csproj | 45 +++++++++++++++++++++
5 files changed, 212 insertions(+), 0 deletions(-)
---
diff --git a/Banshee.sln b/Banshee.sln
index da65a82..097b525 100644
--- a/Banshee.sln
+++ b/Banshee.sln
@@ -142,10 +142,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Data.Sqlite", "src\Lib
EndProject
Project("{2857B73E-F847-4B02-9238-064979017E93}") = "libbanshee", "libbanshee\libbanshee.cproj", "{6B781836-AB65-49EF-BECD-CCC193C5D589}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "metrics", "extras\metrics\metrics.csproj", "{6D17167C-AC3F-4D40-A652-46627276A9A1}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Windows|Any CPU = Windows|Any CPU
+ Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0092BF81-ECAB-4D0C-8691-6D19FB7E04A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
@@ -247,6 +250,12 @@ Global
{6B781836-AB65-49EF-BECD-CCC193C5D589}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6B781836-AB65-49EF-BECD-CCC193C5D589}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6B781836-AB65-49EF-BECD-CCC193C5D589}.Windows|Any CPU.ActiveCfg = Debug|Any CPU
+ {6D17167C-AC3F-4D40-A652-46627276A9A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6D17167C-AC3F-4D40-A652-46627276A9A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6D17167C-AC3F-4D40-A652-46627276A9A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6D17167C-AC3F-4D40-A652-46627276A9A1}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6D17167C-AC3F-4D40-A652-46627276A9A1}.Windows|Any CPU.ActiveCfg = Debug|Any CPU
+ {6D17167C-AC3F-4D40-A652-46627276A9A1}.Windows|Any CPU.Build.0 = Debug|Any CPU
{6FF6F049-9DAB-48A7-BC4B-F7F3ED0EBA63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6FF6F049-9DAB-48A7-BC4B-F7F3ED0EBA63}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6FF6F049-9DAB-48A7-BC4B-F7F3ED0EBA63}.Windows|Any CPU.ActiveCfg = Windows|Any CPU
diff --git a/extras/metrics/CreateMetricsDb.cs b/extras/metrics/CreateMetricsDb.cs
new file mode 100644
index 0000000..4a76bc5
--- /dev/null
+++ b/extras/metrics/CreateMetricsDb.cs
@@ -0,0 +1,78 @@
+//
+// CreateMetricsDb.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;
+using Hyena.Metrics;
+using Hyena.Data.Sqlite;
+using Hyena.Json;
+
+namespace metrics
+{
+ public class CreateMetricsDb
+ {
+ public static void Main ()
+ {
+ string db_path = "metrics.db";
+ System.IO.File.Delete (db_path);
+ using (var db = new HyenaSqliteConnection (db_path)) {
+ MultiUserSample.Provider = new SqliteModelProvider<MultiUserSample> (db, "Samples", true);
+ foreach (var file in System.IO.Directory.GetFiles ("data")) {
+ Log.InformationFormat ("Importing {0}", file);
+
+ try {
+ var o = new Deserializer (System.IO.File.ReadAllText (file)).Deserialize () as JsonObject;
+
+ string user_id = (string) o["ID"];
+ int format_version = (int) o["FormatVersion"];
+ if (format_version != MetricsCollection.FormatVersion) {
+ Log.WarningFormat ("Ignoring user report with old FormatVersion: {0}", format_version);
+ continue;
+ }
+
+ var metrics = o["Metrics"] as JsonObject;
+ db.BeginTransaction ();
+ try {
+ foreach (string metric_name in metrics.Keys) {
+ var samples = metrics[metric_name] as JsonArray;
+ foreach (JsonArray sample in samples) {
+ MultiUserSample.Import (user_id, metric_name, (string)sample[0], (object)sample[1]);
+ }
+ }
+ db.CommitTransaction ();
+ } catch {
+ db.RollbackTransaction ();
+ throw;
+ }
+ } catch (Exception e) {
+ Log.Exception (String.Format ("Failed to read {0}", file), e);
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/extras/metrics/MultiUserSample.cs b/extras/metrics/MultiUserSample.cs
new file mode 100644
index 0000000..a96e0cd
--- /dev/null
+++ b/extras/metrics/MultiUserSample.cs
@@ -0,0 +1,69 @@
+//
+// MultiUserSample.cs
+//
+// Author:
+// Gabriel Burt <gabriel burt gmail com>
+//
+// Copyright (c) 2010 Gabriel Burt
+//
+// 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;
+using Hyena.Metrics;
+using Hyena.Data.Sqlite;
+using Hyena.Json;
+
+namespace metrics
+{
+ public class MultiUserSample : Sample
+ {
+ public static SqliteModelProvider<MultiUserSample> Provider;
+
+ [DatabaseColumn]
+ public string UserId;
+
+ public MultiUserSample ()
+ {
+ }
+
+ public static void Import (string user_id, string metric_name, string stamp, object val)
+ {
+ var sample = new MultiUserSample ();
+ sample.UserId = user_id;
+ sample.MetricName = metric_name;
+
+ DateTime stamp_dt;
+ if (DateTimeUtil.TryParseInvariant (stamp, out stamp_dt)) {
+ sample.Stamp = stamp_dt;
+ }
+
+ DateTime value_dt;
+ if (DateTimeUtil.TryParseInvariant (val as string, out value_dt)) {
+ // We want numeric dates to compare with
+ sample.Value = DateTimeUtil.ToTimeT (value_dt).ToString ();
+ } else {
+ sample.SetValue (val);
+ }
+
+ Provider.Save (sample);
+ }
+ }
+}
\ No newline at end of file
diff --git a/extras/metrics/fetch-metrics b/extras/metrics/fetch-metrics
new file mode 100755
index 0000000..a1998aa
--- /dev/null
+++ b/extras/metrics/fetch-metrics
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+rm -fr data
+mkdir data/
+ssh bansheeweb banshee-project org "cd download.banshee-project.org/metrics/data; tar -cf metrics.tar *.gz"
+scp bansheeweb banshee-project org:~/download.banshee-project.org/metrics/data/metrics.tar data/
+ssh bansheeweb banshee-project org "cd download.banshee-project.org/metrics/data; rm metrics.tar"
+cd data
+tar -xvf metrics.tar
+rm metrics.tar
+gunzip *.gz
diff --git a/extras/metrics/metrics.csproj b/extras/metrics/metrics.csproj
new file mode 100644
index 0000000..82b4e68
--- /dev/null
+++ b/extras/metrics/metrics.csproj
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.21022</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{6D17167C-AC3F-4D40-A652-46627276A9A1}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>metrics</RootNamespace>
+ <ReleaseVersion>1.3</ReleaseVersion>
+ <AssemblyName>metrics</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>.</OutputPath>
+ <DefineConstants>DEBUG</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>none</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>.</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="CreateMetricsDb.cs" />
+ <Compile Include="MultiUserSample.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\src\Libraries\Hyena\Hyena.csproj">
+ <Project>{95374549-9553-4C1E-9D89-667755F90E12}</Project>
+ <Name>Hyena</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+</Project>
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]