• Stars
    star
    1,738
  • Rank 26,795 (Top 0.6 %)
  • Language
    CoffeeScript
  • License
    MIT License
  • Created about 11 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Collect performance data from the client

Bucky

Bucky is a client and server for sending performance data from the client into statsd+graphite, OpenTSDB, or any other stats aggregator of your choice.

It can automatically measure how long your pages take to load, how long AJAX requests take and how long various functions take to run. Most importantly, it's taking the measurements on actual page loads, so the data has the potential to be much more valuable than in vitro measurements.

If you already use statsd or OpenTSDB, you can get started in just a few minutes. If you're not collecting stats, you should start! What gets measured gets managed.

Server

You can play with Bucky just using the client, but if you'd like to start collecting data, see the Server Instructions.

Setup

From The Client

Include bucky.js on your page, the only required config can be done right in the script tag:

<script src="bucky.js" data-bucky-host="/bucky" data-bucky-page data-bucky-requests></script>

That config will automatically log the performance of your page and all the requests you make to a server running at /bucky. It will automatically decide the right key name based on the url of the page. If you'd like, you can also specify it manually:

<script src="bucky.js" data-bucky-host="/bucky" data-bucky-page="index" data-bucky-requests="index"></script>

The Bucky object will be available globally, but there is nothing you need to call for basic usage.

Bucky can also be loaded with AMD or Browserify (see the methods below).

From Node

npm install bucky
bucky = require('bucky')

Configuring

Before sending any data, call setOptions if you're not using the data- attribute based configuration:

Bucky.setOptions({
  host: 'http://myweb.site:9999/bucky'
});

Some options you might be interested in:

  • host: Where we can reach your Bucky server, including the APP_ROOT.

    The Bucky server has a very liberal CORS config, so we should be able to connect to it even if it's on a different domain, but hosting it on the same domain and port will save you some preflight requests.

  • active: Should Bucky actually send data? Use this to disable Bucky during local dev for example.

  • sample: What fraction of clients should actually send data? Use to subsample your clients if you have too much data coming in.

Take a look at the source for a full list of options.

Sending Page Performance

Modern browsers log a bunch of page performance data, bucky includes a method for writing all of this in one go. It won't do anything on browsers which don't support the performance.timing api. Call it whenever, it will bind an event if the data isn't ready yet.

Bucky.sendPagePerformance('where.the.data.should.go')

Setting data-bucky-page triggers this automatically.

The two most relevant stats provided are responseEnd which is the amount of time it took for the original page to be loaded and domInteractive which is the amount of time before the page has finished loaded and can be interacted with by the user.

As a reminder: this data is browser specific, so it will likely skew lower than what users on old browsers see.

If you're using Backbone, it might be a good idea to send your data based on route:

Backbone.history.on 'route', (router, route) ->
   # Will only send on the initial page load:
   Bucky.sendPagePerformance("some.location.page.#{ route }")

The data collected will look something like this:

pages.contactDetail.timing.connectEnd: "172.000|ms"
pages.contactDetail.timing.connectStart: "106.000|ms"
pages.contactDetail.timing.domComplete: "1029.000|ms"
pages.contactDetail.timing.domContentLoadedEventEnd: "1019.000|ms"
pages.contactDetail.timing.domContentLoadedEventStart: "980.000|ms"
pages.contactDetail.timing.domInteractive: "980.000|ms"
pages.contactDetail.timing.domLoading: "254.000|ms"
pages.contactDetail.timing.domainLookupEnd: "106.000|ms"
pages.contactDetail.timing.domainLookupStart: "106.000|ms"
pages.contactDetail.timing.fetchStart: "103.000|ms"
pages.contactDetail.timing.loadEventEnd: "1030.000|ms"
pages.contactDetail.timing.loadEventStart: "1029.000|ms"
pages.contactDetail.timing.navigationStart: "0.000|ms"
pages.contactDetail.timing.requestStart: "173.000|ms"
pages.contactDetail.timing.responseEnd: "243.000|ms"
pages.contactDetail.timing.responseStart: "235.000|ms"
pages.contactDetail.timing.secureConnectionStart: "106.000|ms"

A description of what each datapoint represents is included in the spec.

Sending AJAX Request Time

Bucky can automatically log all ajax requests made by hooking into XMLHttpRequest and doing some transformations on the url to try and create a graphite key from it. Enable it as early in your app's load as is possible:

Bucky.requests.monitor('my.project.requests')

Setting data-bucky-requests calls this automatically.

The data collected will look something like this for a GET request to api.hubapi.com/automation/v2/workflows:

contacts.web.prod.requests.api.hubapi.automation.v2.workflows.get: "656.794|ms"
contacts.web.prod.requests.api.hubapi.automation.v2.workflows.get.2xx: "1|c"
contacts.web.prod.requests.api.hubapi.automation.v2.workflows.get.200: "1|c"
contacts.web.prod.requests.api.hubapi.automation.v2.workflows.get.headers: "436.737|ms"
contacts.web.prod.requests.api.hubapi.automation.v2.workflows.get.receiving: "0.182|ms"
contacts.web.prod.requests.api.hubapi.automation.v2.workflows.get.sending: "0.059|ms"
contacts.web.prod.requests.api.hubapi.automation.v2.workflows.get.waiting: "206.035|ms"

Prefixing

You can build a client which will prefix all of your datapoints by calling bucky as a function:

myBucky = Bucky('awesome.app.view')

# You can then use all of the normal methods:
myBucky.send('data.point', 5)

You can repeatedly call clients to add more prefixes:

contactsBucky = bucky('contacts')
cwBucky = contactsBucky('web')

cwBucky.send('x', 1) # Data goes in contacts.web.x

Counting Things

By default send sends absolute values, this is rarely what you want when working from the client, incrementing a counter is usually more helpful:

bucky.count('my.awesome.thing')
bucky.count('number.of.chips.eaten', 5)

Timing Things

You can manually send ms durations using timer.send:

bucky.timer.send('timed.thing', 55)

Bucky includes a method to time async functions:

bucky.timer.time 'my.awesome.function', (done) ->
  asyncThingy ->
    done()

You can also manually start and stop your timer:

bucky.timer.start 'my.awesome.function'

asyncThingy ->
  bucky.timer.stop 'my.awesome.function'

You can time synchronous functions as well:

bucky.timer.timeSync 'my.awesome.function', ->
  Math.sqrt(100)

The time and timeSync functions also accept a context and arguments to pass to the called function:

bucky.timer.timeSync 'my.render.function', @render, @, arg1, arg2

You can wrap existing functions using wrap:

func = bucky.timer.wrap('func.time', func)

It also supports a special syntax for methods:

class SomeClass
  render: bucky.timer.wrap('render') ->
    # Normal render stuff

Note that this wrapping does not play nice with CoffeeScript super calls.

Bucky also includes a function for measuring the time since the navigationStart event was fired (the beginning of the request):

bucky.timer.mark('my.thing.happened')

It acts like a timer where the start is always navigation start.

The stopwatch method allows you to begin a timer which can be stopped multiple times:

watch = bucky.stopwatch('some.prefix.if.you.want')

You can then call watch.mark('key') to send the time since the stopwatch started, or watch.split('key') to send the time since the last split.

Sending Points

If you want to send absolute values (rare from the client), you can use send directly.

The one use we've had for this is sending +new Date from every client to get an idea of how skewed their clocks are.

Bucky.send 'my.awesome.datapoint', 2432.43434

Your Stats

You can find your stats in the stats and stats.timing folders in graphite, or as written in OpenTSDB.

Send Frequency

Bucky will send your data in bulk from the client either five seconds after the last datapoint is added, or thirty seconds after the last send, whichever comes first. If you log multiple datapoints within this send frequency, the points will be averaged (and the appropriate frequency information will be sent to statsd) (with the exception of counters, they are incremented). This means that the max and min numbers you get from statsd actually represent the max and min 5-30 second bucket. Note that this is per-client, not for the entire bucky process (it's generally only important on the server where you might be pushing out many points with the same key).

Bucky Object

The Bucky object provides a couple extra properties you can access:

  • Bucky.history: The history of all datapoints ever sent.
  • Bucky.active: Is Bucky sending data? This can change if you change the active or sample settings.
  • Bucky.flush(): Send the Bucky queue immediately
  • Bucky.timer.now(): A clock based on the most precise time available (not guarenteed to be from the epoch)

URL -> Key Transformation

request.monitor attempts to automatically transform your urls into keys. It does a bunch of transformations with the goal of removing anything which will vary per-request, so you end up with stats per-endpoint. These tranformations include:

  • Stripping GUIDS, IDs, SHA1s, MD5s
  • Stripping email addresses
  • Stripping domains

If you find these tranformations too invasive, or not invasive enough, you can modify them.

// You can diable tranforms with `.disable`
Bucky.requests.transforms.disable('guid');

// You can enable transforms with `.enable`
Bucky.requests.tranforms.enable('guid');

// `.enable` can also be used to add a new tranform:
Bucky.requests.transforms.enable('my-ids', /[0-9]{4}-[0-9]{12}/g)

// The third argument defines what the match is replaced with (rather than just eliminating it):
Bucky.requests.transforms.enable('campaign', /campaigns\/\w{15}/ig, '/campaigns')

// You can also just provide a function which takes in the url, and returns it modified:
Bucky.request.transforms.enable('soup', function(url){ return url.split('').reverse().join(''); })

Enabled tests will be added to the beginning of the enabled list, meaning they will be executed before any other tranform. Edit the Bucky.requests.tranforms.enabled array if you need more specific control.

The order of the transforms is very important. If you, for example, were to run the id transform before the guid one, the guid transform wouldn't match any guid which began with a number (as the number would have already been stripped out, making the guid the wrong length).

When you first enable request monitoring, it's a good idea to keep an eye on the Bucky logs to get an idea of what sort of data points are being created.

App Server

This project pushes data to the Bucky Server.

Server Documentation

<script src="http://github.hubspot.com/BuckyClient/bucky.js"></script>

More Repositories

1

youmightnotneedjquery

Astro
14,118
star
2

offline

Automatically display online/offline indication to your users
CSS
8,679
star
3

odometer

Smoothly transitions numbers with ease. #hubspot-open-source
CSS
7,259
star
4

vex

A modern dialog library which is highly configurable and easy to style. #hubspot-open-source
CSS
6,927
star
5

messenger

Growl-style alerts and messages for your app. #hubspot-open-source
JavaScript
4,024
star
6

drop

A library for creating dropdowns and other floating elements. #hubspot-open-source
CSS
2,360
star
7

sortable

Drop-in script to make tables sortable
CSS
1,322
star
8

select

Styleable select elements built on Tether. #hubspot-open-source
JavaScript
1,197
star
9

humanize

A simple utility library for making the web more humane. #hubspot-open-source
JavaScript
907
star
10

Singularity

Scheduler (HTTP API and webapp) for running Mesos tasksβ€”long running processes, one-off tasks, and scheduled jobs. #hubspot-open-source
Java
816
star
11

tooltip

CSS Tooltips built on Tether. #hubspot-open-source
CSS
711
star
12

jinjava

Jinja template engine for Java
Java
687
star
13

signet

Display a unique seal in the developer console of your page
CoffeeScript
564
star
14

draft-convert

Extensibly serialize & deserialize Draft.js ContentState with HTML.
JavaScript
483
star
15

hubspot-php

HubSpot PHP API Client
PHP
342
star
16

hubspot-api-python

HubSpot API Python Client Libraries for V3 version of the API
Python
323
star
17

cms-theme-boilerplate

A straight-forward starting point for building a great website on the HubSpot CMS
HTML
320
star
18

hubspot-api-nodejs

HubSpot API NodeJS Client Libraries for V3 version of the API
TypeScript
304
star
19

react-select-plus

Fork of https://github.com/JedWatson/react-select with option group support
JavaScript
281
star
20

SlimFast

Slimming down jars since 2016
Java
270
star
21

dropwizard-guice

Adds support for Guice to Dropwizard
Java
268
star
22

gc_log_visualizer

Generate multiple gnuplot graphs from java gc log data
Python
200
star
23

BuckyServer

Node server that receives metric data over HTTP & forwards to your service of choice
CoffeeScript
195
star
24

hubspot-api-php

HubSpot API PHP Client Libraries for V3 version of the API
PHP
191
star
25

general-store

Simple, flexible store implementation for Flux. #hubspot-open-source
JavaScript
173
star
26

hubspot-cli

A CLI for HubSpot
JavaScript
153
star
27

facewall

Grid visualization of Gravatars for an organization
CoffeeScript
138
star
28

jackson-datatype-protobuf

Java
116
star
29

draft-extend

Build extensible Draft.js editors with configurable plugins and integrated serialization.
JavaScript
116
star
30

prettier-maven-plugin

Java
116
star
31

slack-client

An asynchronous HTTP client for Slack's web API
Java
114
star
32

hubspot-api-ruby

HubSpot API Ruby Client Libraries for V3 version of the API
Ruby
113
star
33

Rosetta

Java library that leverages Jackson to take the pain out of mapping objects to/from the DB, designed to integrate seamlessly with jDBI
Java
110
star
34

Baragon

Load balancer API
Java
105
star
35

mixen

Combine Javascript classes on the fly
CoffeeScript
85
star
36

jquery-zoomer

Zoom up your iFrames
JavaScript
81
star
37

oauth-quickstart-nodejs

A Node JS app to get up and running with the HubSpot API using OAuth 2.0
JavaScript
79
star
38

hapipy

A Python wrapper for the HubSpot APIs #hubspot-open-source
Python
78
star
39

ui-extensions-examples

This repository contains code examples of UI extensions built with HubSpot CRM development tools beta
TypeScript
76
star
40

oneforty-data

Open data on 4,000+ social media apps from oneforty.com #hubspot-open-source
Ruby
70
star
41

cms-react-boilerplate

JavaScript
69
star
42

sample-workflow-custom-code

Sample code snippets for the custom code workflow action.
68
star
43

hubspot-cms-vscode

A HubL language extension for the Visual Studio Code IDE, allowing for πŸš€ fast local HubSpot CMS Platform development.
TypeScript
64
star
44

Blazar-Archive

An out-of-this world build system!
Java
62
star
45

haPiHP

An updated PHP client for the HubSpot API
PHP
61
star
46

sanetime

A sane date/time python interface #hubspot-open-source
Python
60
star
47

BidHub-CloudCode

The Parse-based brains behind BidHub, our open-source silent auction app.
JavaScript
50
star
48

teeble

A tiny table plugin
JavaScript
49
star
49

hubspot.github.com

HubSpot Open Source projects.
JavaScript
46
star
50

calling-extensions-sdk

A JavaScript SDK for integrating calling apps into HubSpot.
JavaScript
45
star
51

BidHub-iOS

iOS client for BidHub, our open-source silent auction app.
Objective-C
44
star
52

dropwizard-guicier

Java
42
star
53

hubspot-cms-deploy-action

GitHub Action to deploy HubSpot CMS projects
HTML
40
star
54

live-config

Live configuration for Java applications #hubspot-open-source
Java
37
star
55

executr

Let your users execute the CoffeeScript in your documentation
JavaScript
35
star
56

transmute

kind of like lodash but works with Immutable
JavaScript
35
star
57

NioImapClient

High performance, async IMAP client implementation
Java
34
star
58

colorshare

Style up your social share buttons
CSS
32
star
59

recruiting-agency-graphql-theme

A theme based off of the HubSpot CMS Boilerplate. This theme includes modules and templates that demonstrate how to utilize GraphQL as part of a website built with HubSpot CMS and Custom CRM Objects.
HTML
32
star
60

integration-examples-php

PHP
32
star
61

cms-event-registration

JavaScript
32
star
62

ChromeDevToolsClient

A java websocket client for the Chrome DevTools Protocol
Java
31
star
63

canvas

HubSpot Canvas is the design system that we at HubSpot use to build our products.
JavaScript
31
star
64

integration-examples-nodejs

JavaScript
31
star
65

cms-react

A repo to expose CMS react examples, React defaults modules, and more to CMS devs
JavaScript
30
star
66

sample-apps-list

The list of Sample applications using HubSpot Public API
28
star
67

NioSmtpClient

Smtp Client based on Netty
Java
28
star
68

vee

A personal proxy server for web developers
CoffeeScript
28
star
69

cms-js-building-block-examples

DEPRECATED, go to https://github.com/HubSpot/cms-react instead
JavaScript
28
star
70

prettier-plugin-hubl

HTML
25
star
71

jackson-jaxrs-propertyfiltering

Java
25
star
72

local-cms-server-cli

Command line tools for local cms development
CSS
22
star
73

astack

Simple stacktrace analysis tool for the JVM
Python
22
star
74

Horizon

Java
20
star
75

rHAPI

Ruby wrapper for the HubSpot API (HAPI)
Ruby
20
star
76

integrate

Confirm that your application works.
CoffeeScript
20
star
77

moxie

A TCP proxy guaranteed to make you smile. #hubspot-open-source
Python
18
star
78

BidHub-WebAdmin

Keep an eye on BidHub while it's doing its thing.
HTML
18
star
79

sample-apps-webhooks

Sample code and reference for processing HubSpot webhooks
JavaScript
17
star
80

hubspot-immutables

Java
17
star
81

cms-custom-objects-example

CSS
17
star
82

hubspot-academy-tutorials

JavaScript
17
star
83

hbase-support

Supporting configs and tools for HBase at HubSpot
Java
17
star
84

cms-vue-boilerplate

Boilerplate Vue project for creating apps using modules on the HubSpot CMS
JavaScript
17
star
85

sprocket

A better REST API framework for django
Python
17
star
86

sample-apps-manage-crm-objects

Sample application in PHP, Python, Ruby and JavaScript demonstrating HubSpot API to manage CRM Objects
JavaScript
17
star
87

react-decorate

Build composable, stateful decorators for React.
JavaScript
16
star
88

maven-snapshot-accelerator

System to speed up dependency resolution when using Maven snapshots #hubspot-open-source
Java
16
star
89

algebra

Simple abstract data types (wrapping derive4j) in Java
Java
15
star
90

sample-apps-oauth

Sample application demonstrating OAuth 2.0 flow with HubSpot API
Ruby
15
star
91

httpQL

A small library for converting URL query arguments into SQL queries.
Java
15
star
92

cms-webpack-serverless-boilerplate

Boilerplate for bundling serverless functions with webpack locally, prior to uploading to the CMS.
JavaScript
13
star
93

virtualenvchdir

Easily chdir into different virtualenvs #hubspot-open-source
Shell
12
star
94

HubspotEmailTemplate

How to convert a regular html coded email template into ones that use HubSpot jinja tags.
12
star
95

hubstar

CSS
12
star
96

private-app-starter

Boilerplates apps using HubSpot API
PHP
12
star
97

chrome_extension_workshop

Chrome extension workshop
JavaScript
11
star
98

serverless-function-examples

A collection of HubSpot related serverless functions examples.
JavaScript
11
star
99

cos_uploader

A python script for syncing a file tree to the HubSpot COS
Python
11
star
100

collectd-gcmetrics

Python
10
star