Commit 2a703f31 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

doc: added hacking page

parent 9f7e899b
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -36,9 +36,9 @@ sitemap:
    -
      title: "Examples"
      url: "/classic_examples"
    #-
    #  title: "Hacking"
    #  url: "/classic_hacking"
    -
      title: "Hacking"
      url: "/classic_hacking"


  #fnordmetric_enterprise:
+70 −9
Original line number Diff line number Diff line
Hacking
-------

here be dragons
This is a random collection of short tips.


### Config in multiple files

here be dragons
You can easily split up your config into multiple files like this:

*fnordmetric_main.rb*

### Writing custom widgets / views
    FnordMetric.namespace :myapp do
      instance_eval(&MY_FNORDMETRIC_MODULE1)
      instance_eval(&MY_FNORDMETRIC_MODULE2)
    end

here be dragons
*fnordmetric_module1.rb*

    MY_FNORDMETRIC_MODULE1 = proc {

### Mounting as Rails app
      # DSL statements go here

    }

here be dragons
<br />


### Redis Memory usage

...disable active users, larger flush_timeout
If you want to reduce redis memory you can do it by using larger
flush_timeouts. Apart from that there are two few low hanging
fruits:

**Disable active users plugin**

    FnordMetric.options = {
      :enable_active_users => false
    }


**Drastically reduce queue TTLs**

    FnordMetric.options = {
      :event_queue_ttl => 60,
      :event_data_ttl => 60,
      :session_data_ttl => 1
    }

<br />


### Writing custom widgets / views

There is one straightforward hack that you can use to build
your own widgets without having to understand the full FnordMetric
source:

### StatsD interoparability
Save this to a file blubb_widget.rb

    class FnordMetric::BlubbWidget < FnordMetric::Widget

      def render
        data.merge(:klass => "HtmlWidget", :html => my_html)
      end

      def my_html
        "<h1>Yay, I can render custom HTML in FnordMetric. The current time is: #{Time.now.to_s}</h1>"
      end

    end

and then use it like this:

    require "blubb_widget.rb"

    widget "My Dashboard",
      :title => "My custom widget",
      :type => :blubb,
      :width => 100

<br />


### Mounting as Rails app

...
I currently don't know how this can be done, since FnordMetric
uses rack-websockets, but it *should* be possible. If somebody
has done this, please send a Pull Request for this page on
github :)