async def on_guild_remove(self, guild): servers = len(self.bot.guilds) try: statsd.gauge('thehammer.guilds.total', servers) statsd.decrement('thehammer.guilds.joins', tags=["guild:{}".format(guild.id)]) except BaseException as e: self.bot.sentry.captureException()
def end_tracking(proc_item): """ :param proc_item: :type proc_item: ProcItem """ # TODO check that proc_item.db_item.log.debug('ending tracking') del proc_lst[proc_item.db_item.id] if statsd: statsd.decrement('python.breeze.running_jobs')
def end_tracking(proc_item): """ :param proc_item: :type proc_item: ProcItem """ # TODO check that proc_item.db_item.log.debug("ending tracking") del proc_lst[proc_item.db_item.id] if statsd: statsd.decrement("python.breeze.running_jobs")
def end_tracking(proc_item): # proc_item): """ :param proc_item: :type proc_item: ProcItem """ # TODO check that # proc_item.db_item.breeze_stat = JobStat.DONE get_logger().debug('%s%s : ending tracking' % proc_item.db_item.short_id) a = proc_item.db_item.is_r_successful # proc_item.process.terminate() del proc_lst[proc_item.db_item.id] if statsd: statsd.decrement('python.breeze.running_jobs')
def main(args): if len(args) < 2: print usage elif args[0] == 'i': statsd.increment(args[1]) elif args[0] == 'd': statsd.decrement(args[1]) elif args[0] == 'g': statsd.gauge(args[1], float(args[2])) elif args[0] == 'e': api.Event.create(title=args[1], text=args[2], tags=args[3]) else: print usage
def DataDogCmd(cmd): args = shlex.split(cmd) print args if len(args) < 2: print usage return False elif args[0] == 'i': statsd.increment(args[1]) elif args[0] == 'd': statsd.decrement(args[1]) elif args[0] == 'g': statsd.gauge(args[1], float(args[2])) elif args[0] == 'e': api.Event.create(title=args[1], text=args[2], tags=args[3]) else: print usage return False return True
def close(self, current_price): self.status = "CLOSED" self.close_time = datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S') if self.trade_type.upper() == "BUY": # Make oppostie trade type to close self._handle_exit_order('sell', current_price) elif self.trade_type.upper() == "SELL": # Make oppostie trade type to close self._handle_exit_order('buy', current_price) statsd.increment('close.order', tags=['name:{}'.format(BOT_NAME), 'pair:{}'.format(self.pair), 'type:{}'.format(self.trade_type), 'order:{}'.format(self.order_type), 'volume:{}'.format(self.bid_volume), 'cur_price:{}'.format(current_price), 'bot_name:{}.bot_id:{}'.format(BOT_NAME, BOT_ID)]) statsd.event(title='Order Close', text='{}/{} - {} {} @ {} / Cost: {}'.format(self.close_order_id, self.pair, self.trade_type, self.bid_volume, self.exit_price, self.exit_cost), alert_type='success', tags=['bot_name:{}.bot_id:{}'.format(BOT_NAME, BOT_ID)]) self.output.log("{c1}{trade_type} Trade closed - order_id: {order_id}{c2}".format(c1=Yellow, trade_type=self.trade_type.upper(), order_id=self.close_order_id, c2=White)) if self.profit >= 0.0: self.output.log("Profit/Loss before fees {}".format(self.profit)) statsd.increment('bottrade.profit', self.profit, tags=['bot_name:{}.bot_id:{}'.format(BOT_NAME, BOT_ID)]) statsd.increment('bottrade.win_rate', 1, tags=['bot_name:{}.bot_id:{}'.format(BOT_NAME, BOT_ID)]) else: self.output.log("Profit/Loss before fees {}".format(self.profit)) # Decrement by the absolute value if profit is negative statsd.decrement('bottrade.profit', abs(self.profit), tags=['bot_name:{}.bot_id:{}'.format(BOT_NAME, BOT_ID)]) statsd.decrement('bottrade.win_rate', 1, tags=['bot_name:{}.bot_id:{}'.format(BOT_NAME, BOT_ID)]) self.output.log("Trade fees at closing: {}".format(self.fees)) statsd.increment('trading_fees', self.fees, tags=['bot_name:{}.bot_id:{}'.format(BOT_NAME, BOT_ID)])
from datadog import initialize, statsd import time import random options = { 'statsd_host': '127.0.0.1', 'statsd_port': 8125 } initialize(**options) statsd.increment('example_metric.increment', tags=["environment:dev"]) statsd.decrement('example_metric.decrement', tags=["environment:dev"]) statsd.gauge('example_metric.gauge', 40, tags=["environment:dev"]) statsd.set('example_metric.set', 40, tags=["environment:dev"]) statsd.histogram('example_metric.histogram', random.randint(0, 20), tags=["environment:dev"]) with statsd.timed('example_metric.timer', tags=["environment:dev"]): # do something to be measured time.sleep(random.randint(0, 10)) statsd.distribution('example_metric.distribution', random.randint(0, 20), tags=["environment:dev"])
from datadog import initialize, statsd import time options = {'statsd_host': '127.0.0.1', 'statsd_port': 8125} initialize(**options) while (1): statsd.increment('example5_metric.increment', tags=["env:dev", "dummy:123"]) statsd.decrement('example5_metric.decrement', tags=["env:dev", "dummy:123"]) time.sleep(10)
def decr(key, value=1, tags=None): statsd.decrement(metric=key, value=value, tags=tags)