lukevenediger / statsd.net

A high-performance stats collection service that feeds into Graphite and aimed at small- to large-scale windows environments.
MIT License
123 stars 25 forks source link

Add support for plugable backends #20

Closed joshclark closed 10 years ago

joshclark commented 10 years ago

Adding support for defining backends in an external DLL (rather than in the main code shipped with statsd.net). This code looks for implementations of IBackend in any DLLs located in the same folder as the exe. We could look for plugins in a "plugins" folder, but that seemed more confusing. It seems simpler to just look in the same folder.

In order to extract all the backend functionality I had to change how the configuration is loaded. The backend implementation is now responsible for loading its config settings from the XElement passed in (this is the XML entry from the config file).

I added a sample File Backend that appends to a text file as a proof of concept. Just add the DLL to the main bin directory to make it available (a list of available backends is written to the log file). To enable a backend, just add the configuration to the config file.

(This is my first gitthub pull request so I apologize in advance if a screw something up :) )

lukevenediger commented 10 years ago

Thanks Josh! I'll take a look tonight.

On Monday, December 30, 2013, Josh Clark wrote:

Adding support for defining backends in an external DLL (rather than in the main code shipped with statsd.net). This code looks for implementations of IBackend in any DLLs located in the same folder as the exe. We could look for plugins in a "plugins" folder, but that seemed more confusing. It seems simpler to just look in the same folder.

In order to extract all the backend functionality I had to change how the configuration is loaded. The backend implementation is now responsible for loading its config settings from the XElement passed in (this is the XML entry from the config file).

I added a sample File Backend that appends to a text file as a proof of concept. Just add the DLL to the main bin directory to make it available (a list of available backends is written to the log file). To enable a backend, just add the configuration to the config file.

(This is my first gitthub pull request so I apologize in advance if a

screw something up :) )

You can merge this Pull Request by running

git pull https://github.com/joshclark/statsd.net plugable-backends

Or view, comment on, or merge it at:

https://github.com/lukevenediger/statsd.net/pull/20 Commit Summary

  • Moved configuration to IBackend
  • Added MEF support for backends
  • Added Example External Backend assembly

File Changes

  • D .nuget/packages.confighttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-0(4)
  • A ExampleExternalBackend/ExampleExternalBackend.csprojhttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-1(74)
  • A ExampleExternalBackend/FileBackend.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-2(65)
  • A ExampleExternalBackend/Properties/AssemblyInfo.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-3(36)
  • A ExampleExternalBackend/packages.confighttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-4(4)
  • M statsd.net-Tests/Infrastructure/BucketOutputBlock.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-5(4)
  • M statsd.net-Tests/Infrastructure/GraphiteLineOutputBlock.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-6(3)
  • M statsd.net-Tests/Infrastructure/InAppBackend.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-7(16)
  • M statsd.net-Tests/MessageParserBlockTests.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-8(1)
  • M statsd.net-Tests/StatsdTestSuite.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-9(2)
  • M statsd.net-Tests/TimedLatencyAggregatorBlockTests.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-10(1)
  • M statsd.net-Tests/statsd.net-Tests.csprojhttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-11(6)
  • A statsd.net.core/Backends/IBackend.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-12(14)
  • A statsd.net.core/ISystemMetricsService.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-13(9)
  • R statsd.net.core/Messages/GraphiteLine.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-14(16)
  • A statsd.net.core/Properties/AssemblyInfo.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-15(36)
  • R statsd.net.core/Structures/Bucket.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-16(10)
  • A statsd.net.core/Structures/BucketType.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-17(12)
  • A statsd.net.core/packages.confighttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-18(4)
  • A statsd.net.core/statsd.net.core.csprojhttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-19(64)
  • D statsd.net.shared/Backends/IBackend.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-20(17)
  • M statsd.net.shared/Factories/MessageParserBlockFactory.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-21(3)
  • M statsd.net.shared/Listeners/HttpStatsListener.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-22(1)
  • M statsd.net.shared/Listeners/StatsdnetTcpListener.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-23(1)
  • M statsd.net.shared/Listeners/TcpStatsListener.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-24(3)
  • M statsd.net.shared/Listeners/UdpStatsListener.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-25(3)
  • M statsd.net.shared/Services/SystemMetricsService.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-26(10)
  • D statsd.net.shared/Structures/BucketType.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-27(18)
  • M statsd.net.shared/Structures/CounterBucket.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-28(4)
  • M statsd.net.shared/Structures/GaugesBucket.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-29(4)
  • M statsd.net.shared/Structures/LatencyBucket.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-30(4)
  • M statsd.net.shared/Structures/PercentileBucket.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-31(4)
  • M statsd.net.shared/Structures/RawBucket.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-32(4)
  • M statsd.net.shared/Structures/SetsBucket.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-33(4)
  • M statsd.net.shared/Utility.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-34(35)
  • M statsd.net.shared/statsd.net.shared.csprojhttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-35(13)
  • M statsd.net.slnhttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-36(13)
  • M statsd.net/Backends/ConsoleBackend.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-37(14)
  • M statsd.net/Backends/GraphiteBackend.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-38(26)
  • M statsd.net/Backends/Librato/LibratoBackend.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-39(38)
  • M statsd.net/Backends/SqlServer/SqlServerBackend.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-40(45)
  • M statsd.net/Backends/Statsdnet/StatsdnetBackend.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-41(26)
  • M statsd.net/Backends/Statsdnet/StatsdnetForwardingClient.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-42(1)
  • M statsd.net/Configuration/BackendConfiguration.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-43(3)
  • M statsd.net/Configuration/ConfigurationFactory.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-44(60)
  • M statsd.net/Configuration/StatsdnetConfiguration.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-45(82)
  • M statsd.net/Framework/PassThroughBlockFactory.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-46(1)
  • M statsd.net/Framework/TimedCounterAggregatorBlockFactory.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-47(1)
  • M statsd.net/Framework/TimedGaugeAggregatorBlockFactory.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-48(1)
  • M statsd.net/Framework/TimedLatencyAggregatorBlockFactory.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-49(1)
  • M statsd.net/Framework/TimedLatencyPercentileAggregatorBlockFactory.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-50(1)
  • M statsd.net/ServiceWrapper.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-51(16)
  • M statsd.net/Statsd.cshttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-52(59)
  • M statsd.net/log4net.confighttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-53(2)
  • M statsd.net/packages.confighttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-54(1)
  • M statsd.net/statsd.net.csprojhttps://github.com/lukevenediger/statsd.net/pull/20/files#diff-55(12)

Patch Links:

lukevenediger commented 10 years ago

Sorry about the delay, I'm looking at this now.

lukevenediger commented 10 years ago

Thanks for the pull request!

After reviewing the changes there are a few things we could refactor in general (not related to your changes)

Thanks again Josh.