Skip to content

Instantly share code, notes, and snippets.

@asmuth
Created January 3, 2012 21:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save asmuth/1557137 to your computer and use it in GitHub Desktop.
Save asmuth/1557137 to your computer and use it in GitHub Desktop.
FnordMetric: setting user picture/name and unique gauges
# i hope this helps...
# to set the username and picture send these events to fm
# -> you don't need to define any event handlers
# -> the session token (_session) could be your unique session id
# or the unique user id (it's hashed)
# set the user name
{ "_type": "_set_name", "name": "Tingle Tangle Bob", "_session": "mysessiontoken" }
# set the user picture
{ "_type": "_set_picture", "url": "http://myhost/123.jpg", "_session": "mysessiontoken" }
# track a pageview
{ "_type": "_pageview", "url": "http://myhost/mypath", "_session": "mysessiontoken" }
# if you want to count action/events unique per session you can
# set up an event handler like this:
gauge :myaction_uniqe,
:tick => 1.day.to_i,
:unique => true
event :myaction do
incr :myaction_uniqe
end
# and send events like this one:
{ "_type": "myaction", "_session": "mysesstiontoken" }
# the gauge will only be incremented once per session token (and tick/interval)
# so this gauge would show "daily unique myactions"
# if you want e.g. the average body size of all users on a given day:
gauge :average_body_size,
:tick => 1.day.to_i,
:unique => true,
:average => true
event :user_body_info do
incr :average_body_size, data[:body_size]
end
# events:
{ "_type": "user_body_info", "body_size": 186, "_session": "userid_1" }
{ "_type": "user_body_info", "body_size": 162, "_session": "userid_2" }
{ "_type": "user_body_info", "body_size": 173, "_session": "userid_3" }
@kirs
Copy link

kirs commented Jan 14, 2012

You made my day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment