Snowplow Golang Tracker 0.1.0 released

Share

We are pleased to announce the release of the Snowplow Golang Tracker. The Tracker is designed to work asynchronously within your Golang code to provide great performance in your applications and servers, even under heavy load, while also storing all of your events persistently in the event of network failure.

It will also be used as a building block for a number of projects, including a new daemon to support robust asynchronous sending for the PHP Tracker.

In the rest of this post we will cover:

  1. How to install the tracker
  2. How to use the tracker
  3. Core features
  4. Roadmap
  5. Documentation
  6. Getting help

1. How to install the tracker

The release version of this Tracker is available directly from the GitHub repo and you can download it by running the following:

$ go get gopkg.in/snowplow/snowplow-golang-tracker.v1/tracker

We are using gopkg.in as a way of providing easy versioning within the Golang environment.

Please check out the Golang Tracker setup guide on our wiki for more information on setup.

That’s it! You’re now ready to start using the Tracker.

2. How to use the tracker

To setup the Go Tracker you first need to import the package into your code:

import "gopkg.in/snowplow/snowplow-golang-tracker.v1/tracker"
// You can also import the package with a shorter name...
import sp "gopkg.in/snowplow/snowplow-golang-tracker.v1/tracker"

You can then instantiate and start a new tracker like so:

emitter := sp.InitEmitter(sp.RequireCollectorUri("com.acme"))
tracker := sp.InitTracker(sp.RequireEmitter(emitter))

You are now ready to Track events, so let’s send a screen view event:

tracker.TrackScreenView(sp.ScreenViewEvent{
  Id: sp.NewString("Screen ID"),
})

And that’s all there is to it! Please check out the Golang Tracker technical documentation on our wiki for the Tracker’s full API.

3. Core features

The core features of the Snowplow Go Tracker include:

The general flow of the Tracker as an event goes through:

This model is very closely related to the one used in the Android, Objective-C and Unity Trackers, which are all backed by Sqlite databases.

If you absolutely have to have the Tracker be non-blocking from end to end you can use the go keyword to track events within another go routine. The Tracker is thread-safe and will behave as normal; however in load-testing the Tracker better performance was actually found with the blocking approach to adding the event to the database.

In our tests sending 6,000 events to a Snowplow Mini collector instance:

As the database can only accept one insert at a time the creation of go routines for individual Track invocations actually results in worse performance.

The Tracker also contains full support for secure event sending by both GET and POST request types, and the ability to combine events, for POST, up to a configurable byte limit. This yields much better performance versus our old approach of buffer limits.

4. Roadmap

We have big plans for the Snowplow Golang Tracker at Snowplow, including:

5. Documentation

6. Getting help

We hope that you find the Snowplow Golang Tracker useful – of course, this is only its first release, so don’t be afraid to get in touch or raise an issue on GitHub!

Share

Related articles