How to use hot-shots - 10 common examples

To help you get started, we’ve selected a few hot-shots examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mozilla / fxa / packages / fxa-event-broker / bin / worker.ts View on Github external
Config.get('clientCapabilityFetch.refreshInterval'),
    db
  );
  const pubsub = new PubSub();

  // Extract region for SQS object
  const serviceNotificationQueueUrl = Config.get('serviceNotificationQueueUrl');
  const region = extractRegionFromUrl(serviceNotificationQueueUrl);
  if (!region) {
    logger.error('invalidServiceUrl', {
      message: 'Cant find region in service url',
      serviceNotificationQueueUrl
    });
    process.exit(8);
  }
  const metrics = new StatsD(Config.get('metrics'));
  const processor = new ServiceNotificationProcessor(
    logger,
    db,
    metrics,
    capabilityService,
    webhookService,
    pubsub,
    Config.get('topicPrefix'),
    serviceNotificationQueueUrl,
    new SQS({ region })
  );
  logger.info('startup', { message: 'Starting event broker...' });
  processor.start();
  logger.info('startup', { message: 'Starting proxy server...' });
  const server = await proxyServerInit(
    {
github Xetera / HifumiOld / src / events / systemStartup.ts View on Github external
let hifumi = new Cleverbot();
    let database = new Database();
    let muteQueue = new MuteQueue();
    let tracklist = new Tracklist();
    // probably not a good place to have this side effect but whatever
    let messageQueue = new MessageQueue(muteQueue, database, tracklist);
    let commandHandler = new CommandHandler();
    return {
        bot: bot,
        hifumi: hifumi,
        muteQueue: muteQueue,
        database: database,
        messageQueue: messageQueue,
        commandHandler: commandHandler,
        trackList: tracklist,
        stats: new StatsD(),
        heroku: new Heroku({token: process.env.HEROKU_API_TOKEN}),
        // this is to be able to eval through the context of all the instances
        eval: (message: Message, x: any) => {
            try {
                return eval(x);
            }
            catch (e) {
                return e.toString();
            }
        }
    }

}
github NotAWeebDev / Misaki / structures / MisakiClient.js View on Github external
constructor(options) {
    super(options);

    this.config = require("../config.js");
    this.console = new MisakiConsole(this);
    this.responses = require("../assets/responses.js");
    this.botStats = new StatsHandler(this);
    
    this.dogstats = new StatsD("localhost", 8125);
    this.idiotAPI = new idioticApi(process.env.IDIOTAPI, { dev: true });
    this.commands = new CommandStore(this);
    this.events = new EventStore(this);
    this.upvoters = [];
    this.levelCache = {};
    this.methods = {
      util: require("../util/util.js"),
      errors: require("../util/CustomError")
    };

    // Enmap
    this.settings = new Enmap({ provider: new EnmapLevel({ name: "settings" }) });
    this.blacklist = new Enmap({ provider: new EnmapLevel({ name: "blacklist" }) });
    this.reminders = new Enmap({ provider: new EnmapLevel({ name: "reminders" }) });
    this.points = new Enmap({ provider: new EnmapLevel({ name: "points" }) });
    this.store = new Enmap({ provider: new EnmapLevel({ name: "shop" }) });
github kinecosystem / marketplace-server / scripts / src / metrics.ts View on Github external
import { StatsD } from "hot-shots";
import { getConfig } from "./config";

import { MarketplaceError } from "./errors";
import { Order, OrderFlowType, OrderOrigin } from "./models/orders";
import { BlockchainVersion } from "./models/offers";

// XXX can add general tags to the metrics (i.e. - public/ internal, machine name etc)
const statsd = new StatsD(Object.assign({ prefix: "marketplace_" }, getConfig().statsd));

export function destruct() {
	return new Promise(resolve => statsd.close(() => resolve()));
}

export function userRegister(newUser: boolean, appId: string) {
	statsd.increment("user_register", 1, { new_user: newUser.toString(), app_id: appId });
}

export function walletAddressUpdate(appId: string, newWallet: boolean) {
	statsd.increment("wallet_address_update_succeeded", 1, { app_id: appId, new_wallet: newWallet.toString() });
}

// no use in /scripts or /tests
export function userActivate(newUser: boolean) {
	statsd.increment("user_activate", 1, { new_user: "true" });
github ppy / osu-notification-server / src / index.ts View on Github external
if (userSession == null) {
    logger.info(`authentication failed from ${ip}: ${failReason || 'missing authentication header/cookie'}`);

    throw new Error('Authentication failed');
  }

  userSession.ip = ip;

  return userSession;
};

// variables
const authenticationFailedMessage = JSON.stringify({ error: 'authentication failed' });
const db = mysql.createPool(config.db);
const dogstatsd = new StatsD({ prefix: 'osu.notification.' });
const redisSubscriber = new RedisSubscriber({ dogstatsd, redisConfig: config.redis.notification });
const oAuthVerifier = new OAuthVerifier({ baseDir: config.baseDir, db });
const laravelSession = new LaravelSession({ appKey: config.appKey, redisConfig: config.redis.app });

// initialise server
const wss = new WebSocket.Server(config.server);
logger.info(`listening on ${config.server.host}:${config.server.port}`);

wss.on('connection', async (ws: WebSocket, req: http.IncomingMessage) => {
  let session;

  try {
    session = await getUserSession(req);
  } catch (err) {
    ws.send(authenticationFailedMessage, noop);
    ws.terminate();
github wikimedia / service-runner / lib / statsd.js View on Github external
childClient() {
        return new LogStatsD(
            this._logger,
            this._serviceName
        );
    }
}

const timingMixin = {
    endTiming(names, startTime, samplingInterval) {
        return this.timing(names, Date.now() - startTime, samplingInterval);
    }
};

// Also add a small utility to send a delta given a startTime
Object.assign(StatsD.prototype, timingMixin);
Object.assign(LogStatsD.prototype, timingMixin);

// Minimal StatsD wrapper
function makeStatsD(options, logger) {
    let statsd;
    const srvName = options._prefix ? options._prefix : normalizeName(options.name);
    const statsdOptions = {
        host: options.host,
        port: options.port,
        prefix: `${srvName}.`,
        suffix: '',
        globalize: false,
        cacheDns: false,
        mock: false
    };
github AdityaTD / PenguBot / src / lib / structures / PenguClient.js View on Github external
this.music = new MusicManager();
        this.topCache = [];
        this.health = Object.seal({
            commands: {
                temp: {
                    count: 0,
                    ran: {}
                },
                cmdCount: new Array(60).fill({
                    count: 0,
                    ran: {}
                })
            }
        });
        this.emotes = { check: "<:penguSuccess:435712876506775553>", cross: "<:penguError:435712890884849664>", loading: "" };
        this.dogstats = new StatsD("localhost", 8125);

        this.version = "2.0.0";
        this.userAgent = `PenguBot/${this.version}/${this.options.production ? "Production" : "Development"}`;
    }
github atomist / automation-client / lib / spi / statsd / statsdClient.ts View on Github external
public create(clientOptions: StatsDClientOptions): StatsDClient {
        const options: HotShots.ClientOptions = {
            prefix: clientOptions.prefix,
            host: clientOptions.host,
            port: clientOptions.port,
            globalTags: clientOptions.globalTags,
            cacheDns: true,
        };

        return new HotShots.StatsD(options);
    }
github AdityaTD / PenguBot / lib / structures / PenguClient.js View on Github external
this.health = Object.seal({
            commands: {
                temp: {
                    count: 0,
                    ran: {}
                },
                cmdCount: new Array(60).fill({
                    count: 0,
                    ran: {}
                })
            }
        });
        this.rawEvents = new RawEventStore(this);
        this.registerStore(this.rawEvents);
        this.emotes = { check: "<:penguSuccess:435712876506775553>", cross: "<:penguError:435712890884849664>", loading: "" };
        this.dogstats = new StatsD("localhost", 8125);
    }
github Shopify / quilt / packages / statsd / src / client.ts View on Github external
this.logger = logger;
    }

    this.options = {
      ...options,
      errorHandler: options.errorHandler
        ? options.errorHandler
        : (error: Error) => {
            this.logger.log(
              `Error occurred in the StatsD client:\n${error.stack ||
                error.message}`,
            );
          },
    };

    this.statsd = new StatsD(this.options);
  }

hot-shots

Node.js client for StatsD, DogStatsD, and Telegraf

MIT
Latest version published 1 month ago

Package Health Score

83 / 100
Full package analysis