Skip to content

Instantly share code, notes, and snippets.

@caevyn
Created July 22, 2013 06:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caevyn/6051595 to your computer and use it in GitHub Desktop.
Save caevyn/6051595 to your computer and use it in GitHub Desktop.
ServiceStack AppHost Configure for metrics.
public override void Configure(Funq.Container container)
{
const string statsdPrefix = "Qas.Web";
//common config shared with tests
Config.Configure();
container.Register<IStatsd>(c => new Statsd(new StatsdUDP("localhost", 8125)));
Plugins.Add(new MetricsFeature(container.Resolve<IStatsd>(), statsdPrefix));
var statsd = container.Resolve<IStatsd>();
statsd.Send<Statsd.Counting>(string.Format("{0}.{1}", statsdPrefix,"Started"), 1);
ServiceExceptionHandler =
(req, ex) =>
{
statsd.Add<Statsd.Counting>(string.Format("{0}.{1}", statsdPrefix, "Error.Total"), 1);
statsd.Add<Statsd.Counting>(string.Format("{0}.{1}.{2}", statsdPrefix, "Error", ex.GetType()), 1);
statsd.Send();
return DtoUtils.HandleException(this, req, ex);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment