#!/usr/bin/env python
# coding=utf-8

from Handler import Handler
import urllib2


class HttpPostHandler(Handler):

# Inititalize Handler with url and batch size
    def __init__(self, config=None):
        Handler.__init__(self, config)
        self.metrics = []
        self.batch_size = int(self.config.get('batch', 100))
        self.url = self.config.get('url')

# Join batched metrics and push to url mentioned in config
    def process(self, metric):
        self.metrics.append(str(metric))
        if len(self.metrics) >= self.batch_size:
            req = urllib2.Request(self.url, "\n".join(self.metrics))
            urllib2.urlopen(req)
            self.metrics = []

@@ -31,16 +31,241 @@
 =utf-8%0A%0A
+%22%22%22%0ASend metrics to a http endpoint via POST%0A%0A#### Dependencies%0A%0A * urllib2%0A%0A%0A#### Configuration%0AEnable this handler%0A%0A * handers = diamond.handler.httpHandler.HttpPostHandler%0A %0A * url = http://www.example.com/endpoint%0A %0A%22%22%22%0A%0A
 from Han

Add in basic HttpPostHandler docs