Skip to content
This repository has been archived by the owner on Jun 8, 2022. It is now read-only.
/ cppmetrics Public archive
forked from ultradns/cppmetrics

C++ port of the codahale/dropwizard metrics library

License

Notifications You must be signed in to change notification settings

noam1023/cppmetrics

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

##Background

cppmetrics is a C++ port of the DropWizard metrics!. The library implements the standard metrics primitives like Gauge, Counter, Histogram, Meter and Timer and the provides the reporter implementations like the ConsoleReporter, GraphiteRepoter out of the box. Its written in C++98 to make the integration into existing pre-C++11 codebases easier and should be portable across different platforms but being used only in linux environment.

Build Status

Build dependencies

  • Pocolib ( >= 1.7.2)
  • gtest (>= 1.6.0, dependency for the unit tests only.)

How to build

make sudo make install

##Sample code snippet

// ------ using namespace std; typedef cppmetrics::core::CounterPtr Counter; class CppMetricsWrapper{ sample::Controller controller; public: void configureAndStartGraphiteReporter(string h, int p, int period, string prefix){ sample::GraphiteReporterOptions opt; opt.port_ = p; opt.host_ = h; opt.interval_in_secs_ = period; opt.prefix_ = prefix; controller.configureAndStartGraphiteReporter(opt); }

Counter counter(string name){
	return controller.getRegistry()->counter(name);
}

};

// show how to use the wrapper class CppMetricsWrapper M; void demo_cppmetrics2(){

M.configureAndStartGraphiteReporter("localhost", 2003, 1 , "_");
Counter numSheeps = M.counter("sheeps");
for (size_t i = 0; i < 10; ++i) {
	numSheeps->increment();
	usleep(500*1000);
}

}

int main(){ printf(" run a graphite server with:\nwhile [ 1 ]; do nc -l 2003;echo ===; done\n"); //demo_cppmetrics(); demo_cppmetrics2(); usleep(310001000); return 0;

}

###TODO

  • Currently the Timer and Meter resolutions are in millis and per-minute respectively, make this configurable.
  • Provide more reporters out of the box.

About

C++ port of the codahale/dropwizard metrics library

Topics

Resources

License

Stars

Watchers

Forks

Languages

  • C++ 96.0%
  • Makefile 2.3%
  • Shell 1.7%