Documentation ¶
Overview ¶
Package apinalytics_client sends events to apinalytics asynchronously in batches.
To get started go to http://apinalytics.tanktop.tv/u/ and login with your github account. This will give you an ApplicationId, a Write key (which you need to send events) and a Read key (which you need to query events).
You can then send events using our Goji middleware (https://github.com/apinalytics/apinalytics_client/goji), or directly by creating a Sender (see NewSender), then calling Sender.Queue() to send the events.
To see the data take a look over at github.com/apinalytics/apinalytics where you can find an example html dashboard.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnalyticsEvent ¶
type AnalyticsEvent struct { // Timestamp for this event in seconds since 1 Jan 1970 UTC Timestamp int64 `json:"timestamp"` // Identifier for the API consumer ConsumerId string `json:"consumer_id"` // HTTP Method used ("GET", "POST", etc.) Method string `json:"method"` // Url used (including parameters) Url string `json:"url"` // Name of the function invoked. Function string `json:"function",omitempty` // API response time in microseconds ResponseUS int `json:"response_us"` // HTTP status code StatusCode int `json:"status_code"` // Arbitrary key, value pairs to report. Not yet implemented Data map[string]string `json:"data",omitempty` }
AnalyticsEvent records an API call.
type Sender ¶
type Sender struct {
// contains filtered or unexported fields
}
Sender is used to send events to apinalytics. Create a sender using NewSender.
func NewSender ¶
NewSender creates a new Sender.
This creates a background goroutine to aggregate and send your events.
applicationId - Identifies the application generating the events. writeKey - Your apinalytics write key url - URL of the Apinalytics service (usually http://apinalytics.tanktop.tv)
func (*Sender) Close ¶
func (sender *Sender) Close()
Close the sender and wait for queued events to be sent
func (*Sender) Queue ¶
func (sender *Sender) Queue(event *AnalyticsEvent)
Queue events to be sent to Apinalytics
info can be anything that is JSON serializable. Events are immediately queued to a background goroutine for sending. The background routine will send everything that's queued to it in a batch, then wait for new data.
The upshot is that if you send events slowly they will be sent immediately and individually, but if you send events quickly they will be batched
type StatusTrackingResponseWriter ¶
type StatusTrackingResponseWriter struct { http.ResponseWriter // http status code written Status int }
A version of http.ResponseWriter that lets you see the status code writtern to the response
func (*StatusTrackingResponseWriter) WriteHeader ¶
func (w *StatusTrackingResponseWriter) WriteHeader(status int)