collector

command module
v0.0.0-...-5ef1b56 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2014 License: MIT Imports: 11 Imported by: 0

README

Collector

Build Status

Why?

On a side project, I wanted to track data from javascript. Ajax calls, DOM rendering time, ... Much like analytics at github, but in a much simpler way, because this is a hobby project and I don't have as much traffic as github.

Installing

Collector is meant to run on heroku. Installing it is pretty easy.

heroku create
heroku config:set BUILDPACK_URL=https://github.com/kr/heroku-buildpack-go.git#go1.2
heroku config:set LIBRATO_EMAIL=<your librato email>
heroku config:set LIBRATO_TOKEN=<your librato token>
git push heroku

That's all!

Usage

I'm using Collector with Javascript only (when using it on a server-side app, I can just make calls to librato. No need for this).
Here's the small method I'm using:

window.collector = {
  host: 'http://<app_name>.herokuapp,com/',
  collect: function(kind, key, value) {
    var host;
    host = this.host;
    return jQuery.ajax({
      url: "" + host + "/collect",
      method: "POST",
      data: {
        metric: {
          key: key,
          value: value,
          kind: kind
        }
      }
    });
  }
};

This method can be called like this:

collector.collect('meter', 'app.pageview', 1)

Which will send an app.pageview metric with the value '1' to your collector instance. This data will be sent to librato, where you can view it afterwards.

That's all, nothing complicated. Though you should be able to build powerful javascript frameworks to send more data if you need to.

Contributing

If you think Collector is great but can be improved, feel free to contribute. To do so, you can :

  • Fork the project
  • Do your changes and commit them to your repository
  • Test your changes. We won't accept any untested contributions (except if they're not testable).
  • Create an issue with a link to your commits.

And that's it! I'll soon take a look at your issue and review your changes.

Author and Credits

Damien MATHIEU :: 42 (AT|CHEZ) dmathieu.com

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL