{"id":24552407,"url":"https://github.com/peschuster/graphite-client","last_synced_at":"2025-04-06T18:16:58.354Z","repository":{"id":2993157,"uuid":"4009757","full_name":"peschuster/graphite-client","owner":"peschuster","description":"Windows (.NET) library and tools for feeding data into Graphite and statsD.","archived":false,"fork":false,"pushed_at":"2023-05-31T18:49:56.000Z","size":2376,"stargazers_count":84,"open_issues_count":10,"forks_count":27,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-05-29T14:12:29.830Z","etag":null,"topics":["graphite","metrics","statsd"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peschuster.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-04-12T21:54:24.000Z","updated_at":"2024-06-18T17:07:04.968Z","dependencies_parsed_at":"2023-07-06T07:29:46.341Z","dependency_job_id":null,"html_url":"https://github.com/peschuster/graphite-client","commit_stats":{"total_commits":149,"total_committers":8,"mean_commits":18.625,"dds":"0.22818791946308725","last_synced_commit":"3406aa01738d6577042cd1bfa630aaa523dffbc5"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peschuster%2Fgraphite-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peschuster%2Fgraphite-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peschuster%2Fgraphite-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peschuster%2Fgraphite-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peschuster","download_url":"https://codeload.github.com/peschuster/graphite-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247526768,"owners_count":20953143,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graphite","metrics","statsd"],"created_at":"2025-01-23T01:31:29.283Z","updated_at":"2025-04-06T18:16:58.313Z","avatar_url":"https://github.com/peschuster.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# graphite-client\n\nWindows (.NET) library and tools for feeding data into [Graphite](http://readthedocs.org/docs/graphite/en/latest/overview.html \"Graphite is an enterprise-scale monitoring tool\") and [statsD](https://github.com/etsy/statsd \"StatsD - a network daemon for aggregating statistics\").\n\n## Current status\n\n[![Build status](https://ci.appveyor.com/api/projects/status/owo6sm3llyujpxiw?svg=true)](https://ci.appveyor.com/project/peschuster/graphite-client)\n\n- Base library (Graphite.dll)\n- Monitoring service for [PerformanceCounters](http://www.codeproject.com/Articles/8590/An-Introduction-To-Performance-Counters) (PerfCounterMonitor.exe)\n- Basic instrumentation of ASP.NET MVC apps (inspired by MiniProfiler, Graphite.Mvc.dll)\n- Instrumentation of WCF services (Graphite.Wcf.dll)\n- Sending stats from inside SQL Server using TSQL / a stored procedure (Graphite.TSql.dll)\n- MSBuild task for sending stats to Graphite and StatsD  (MSBuild.Graphite.dll)\n- [ELMAH](http://code.google.com/p/elmah/) [error filter](http://code.google.com/p/elmah/wiki/ErrorFiltering) for logging all exception to Graphite or StatsD (Graphite.Elmah.dll)\n\n## Published NuGet packages\n\n - [Graphite](http://nuget.org/packages/Graphite)\n - [Graphite.Wcf](http://nuget.org/packages/Graphite.Wcf)\n - [Graphite.Elmah](http://nuget.org/packages/Graphite.Elmah)\n\n## Quickstart\n\n1. Install NugGet package [Graphite](http://nuget.org/packages/Graphite) (for standalone applications) or [Graphite.Wcf](http://nuget.org/packages/Graphite.Wcf) for WCF applications or Reference Graphite.Mvc.dll (currently not on NuGet) for ASP.NET MVC applications.\n\n2. Add configuration for the base Graphite DLL to your App.config/Web.config:\n\n```\n\u003cconfigSections\u003e\n  \u003csection name=\"graphite\" type=\"Graphite.Configuration.GraphiteConfiguration, Graphite\" /\u003e\n\u003c/configSections\u003e\n\u003cgraphite xmlns=\"http://github.com/peschuster/Graphite/Configuration\"\u003e\n  \u003c!--\u003cgraphite address=\"127.0.0.1\" port=\"2003\" transport=\"Tcp\" /\u003e--\u003e\n  \u003cstatsd address=\"127.0.0.1\" port=\"8125\" prefixKey=\"test\" /\u003e\n\u003c/graphite\u003e\n```\n\nIt is also possible to set the base configuration inside the `connectionStrings` section. The `graphite` \"configSection\" must not be defined for these connection string configurations to take effect.\n\n```\n\u003cconnectionStrings\u003e\n  \u003cadd name=\"graphite\" connectionString=\"address=127.0.0.1;port=2003;transport=Tcp\" /\u003e\n  \u003cadd name=\"statsd\" connectionString=\"address=127.0.0.1;port=8125;prefixKey=test\" /\u003e\n\u003c/connectionStrings\u003e\n```\n\n3. Add a `using` directive for *Graphite*: `using Graphite;`\n\n4. [For standalone apps] Create a profiler instance on application start: `StaticMetricsPipeProvider.Instance.Start();` and stop it on application exit: `StaticMetricsPipeProvider.Instance.Stop();`.\n\n5. Use Graphite in your code: `MetricsPipe.Current.Count(\"exception\");`\n\n## Features/Documentation\n\n### General\n\nThe architecture of the *Graphite* system is inspired by [MiniProfiler](http://github.com/SamSaffron/MiniProfiler):\n\nAn `IMetricsPipeProvider` manages the current profiler instance. The implementation of this provider differs depending on the context of the application: ASP.NET/Web, WCF and \"standalone\"/simple exe file.\n\nAccessing the profiler works always the same through `MetricsPipe.Current`\n\n#### Metric Types\n\nThere are three different metric types:\n\n - `counter` - all values in one flush interval are summed up and submitted as is and as \"per second\" value by *StatsD* to the underlying backend (e.g. *Graphite*) (only for *StatsD*)\n - `timing` - all values in one flush interval are aggregated by several statistical operations (mean, upper, lower, ...) (only for *StatsD*)\n - `gauge` - for *StatsD* the latest, reported value is taken, for *Graphite* the value is reported as is to the *Graphite* server (for *StatsD* and *Graphite*)\n\n### Code instrumentation\n\u003e Graphite.dll\n\nReporting metrics to *Graphite* or *StatsD* can be done by calling one of the extension methods on `MetricsPipe.Current`. Therefore a `using` directive for the `Graphite` namespace is required:\n\n    using Graphite;\n\nThe available extension methods correspond to the metric types described in *General*.\n\n**StatsD**:\n\n - `void Timing(this MetricsPipe profiler, string key, int value)` - for direct submission of *timing* values\n - `IDisposable Step(this MetricsPipe profiler, string key)` - for profiling code segements\n - `void Count(this MetricsPipe profiler, string key, int value = 1, float sampling = 1)` - for reporting *counter* values\n - `void Gauge(this MetricsPipe profiler, string key, int value)` - for reporting *gauges*\n\n\n**Graphite**:\n\n - `void Raw(this MetricsPipe profiler, string key, int value)` - for directly reporting values to Graphite\n\nAn extension method can be called like this:\n\n    MetricsPipe.Current.Count(\"exception\");\n\nThe `Step` method is a special method which measures the time till `Dispose()` is called on the returned `IDisposable`. This can be done best with a `using` statement:\n\n    using (MetricsPipe.Current.Step(\"duration\"))\n    {\n\t    // Do some work here...\n\t}\n\nThe strength of extension methods is that they also work without throwing a `NullReferenceException`, when `MetricsPipe.Current` is `null` - i.e. not initialized.\n\n#### Standalone Applications\n\nThe `MetricsPipe` can be used in standalone applications (e.g. console or windows applications) after starting the profiler with the following line of code:\n\n    StaticMetricsPipeProvider.Instance.Start();\n\nEverything is disposed and cleaned up after calling\n\n    StaticMetricsPipeProvider.Instance.Stop();\n\n### System Metrics\n\u003e PerfCounterMonitor.exe (Graphite.System)\n\nBesides profiling and instrumenting your code manually you can report various system parameters to *StatsD* and *Graphite*, too. This can be accomplished with the `Graphite.System` block, respectively `PerfCounterMonitor.exe`.\n\n`Graphite.System` enables reporting values from the following sources:\n\n - Performance counters\n - Event log\n - IIS Application Pools\n\nSee the complete [documentation](http://github.com/peschuster/graphite-client/wiki/System-Metrics) for `PerfCounterMonitor.exe`.\n\n**You can download the binaries of *Graphite.System* here:** [Graphite.System v1.1.0](https://github.com/peschuster/graphite-client/releases/tag/Graphite.System_1-1-0-0)\n\n\n### WCF\n\u003e Graphite.Wcf.dll\n\nWCF services can be instrumented for reporting hit counts and execution times. Therefore an attribute needs to be added to the service instance:\n\n    [ServiceBehavior]\n    [MetricsPipeBehavior(true, true, fixedRequestTimeKey: null, requestTimePrefix: \"service.example\", fixedHitCountKey: null, hitCountPrefix: \"service.example\")]\n    public class ExampleGraphiteService\n    {\n        public void Test()\n        {\n        }\n    }\n\nThe attribute has the following parameters:\n\n - `bool reportRequestTime` - enable reporting of execution time\n - `bool reportHitCount` - enable reporting of hit counts\n - `string fixedRequestTimeKey = null` - fixed metric key for execution time metrics\n - `string requestTimePrefix = null` - prefix key for execution time metrics\n - `string fixedHitCountKey = null` - fixed metric key for hit count metrics\n - `string hitCountPrefix = null` - prefix key for hit count metrics\n\nEither the `fixed...Key` or `...Prefix` parameter must be set for an enabled metric.\n\nOn setting the `fixed...Key` parameter, this metric is reported with the specified key as is.\n\nOn setting the  `...Prefix` parameter, this metric is reported with a metric key in the following format:\n\n    [prefixKey].[servicename].[operation_name]\n\n### MSBuild Tasks\n\u003e MSBuild.Graphite.dll\n\nReporting metrics from within MSBuild scripts is possible utilizing the tasks in `MSBuild.Graphite.dll`\n\n  \t\u003cUsingTask TaskName=\"MSBuild.Graphite.Tasks.Graphite\" AssemblyFile=\".\\MSBuild.Graphite.dll\"\u003e\u003c/UsingTask\u003e\n\t\n\t  \u003cTarget Name=\"graphite\"\u003e\n\t    \u003cMSBuild.Graphite.Tasks.Graphite\n\t        Address=\"192.168.2.100\"\n\t        Transport=\"Tcp\"\n\t        PrefixKey=\"stats.events\"\n\t        Key=\"deploys.test\"\n\t        Value=\"1\" /\u003e\n\t  \u003c/Target\u003e\n\n### ELMAH\n\u003e Graphite.Elmah.dll\n\nExceptions captured by [ELMAH](http://code.google.com/p/elmah/) can be reported using an ELMAH error filter defined in `Graphite.Elmah.dll`.\n\nThis can be accomplished by the following settings in your `web.config` file:\n\n\t\u003cconfigSections\u003e\n\t    \u003csection name=\"graphite.elmah\" type=\"Graphite.Configuration.GraphiteElmahConfiguration, Graphite.Elmah\"/\u003e\n\t\u003c/configSections\u003e\n\t\u003cgraphite.elmah\n\t    xmlns=\"http://github.com/peschuster/Graphite/Configuration\"\n\t    key=\"elmah_errors\"\n\t    type=\"counter\"\n\t    target=\"statsd\" /\u003e\n\t\u003celmah\u003e\n\t    \u003cerrorFilter\u003e\n\t        \u003ctest\n\t            xmlns:my=\"http://schemas.microsoft.com/clr/nsassem/Graphite/Graphite.Elmah\"\u003e\n\t            \u003cmy:log /\u003e\n\t        \u003c/test\u003e\n\t    \u003c/errorFilter\u003e\n\t\u003c/elmah\u003e\n\nOn using the NuGet package [`Graphite.Elmah`](http://nuget.org/packages/Graphite.Elmah) all required settings are added to your project automatically during installation.\n\n### SQL Server\n\u003e Graphite.TSql.dll\n\nFrom within SQL Server, metrics can be reported by calling a stored procedure:\n\n    exec sp_graphitesend N'192.168.0.1', 2003, 'stats.events.myserver.test', 1\n\nThis stored procedure can be installed using the provided sql script: [sp_graphitesend.sql](http://github.com/peschuster/graphite-client/blob/master/source/Graphite.TSql/sp_graphitesend.sql)\n\n(see also [Sending stats to Graphite from within SQL Server](http://www.peschuster.de/2012/07/sending-stats-to-graphite-from-within-sql-server/))\n\n## TODO\n\n- Instrumentation of ASP.NET MVC applications\n- Montioring log files\n- ...\n\n## Building...\n\nHow to build:\n \n1. Go to `\\build` directory\n2. Execute `go.bat`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeschuster%2Fgraphite-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeschuster%2Fgraphite-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeschuster%2Fgraphite-client/lists"}