Giter VIP home page Giter VIP logo

go-template_metrics's Introduction

go-template_metrics

Instrument template rendering

Usage

import (
  "html/template" // or "text/template"
  "github.com/sonots/go-template_metrics"
)

func main() {
  // formTmpl := template.Must(template.ParseFiles("views/base.html", "views/form.html"))
  formTmpl := template_metrics.WrapTemplate("form", template.Must(template.ParseFiles("views/base.html", "views/form.html")))

  // Use as usual
  formTmpl.Execute(w, data)
  // or
  formTmpl.ExecuteTemplate(w, "base", data)

  template_metrics.Verbose = true // print metrics on each rendering
  template_metrics.Print(1) // print metrics on each 1 second
  // template_metrics.Enable = false // turn off the instrumentation
}

Output Example (LTSV format):

time:2014-09-08 05:06:57.99249161 +0900 JST     template:form   base:base    count:1 max:0.000301    mean:0.000301   min:0.000301    percentile95:0.000301   duration:1

Verbose Output Example (LTSV format):

time:2014-09-08 05:06:57.22659252 +0900 JST     template:form   base:base    elapsed:0.000301

API

Print

Print summarized metrics on each specified second:

template_metrics.Print(60)

Verbose

Print metrics on each rendering:

template_metrics.Verbose = true

Enable

Diable instrumentation as:

template_metrics.Enable = false

Flush()

Flush metrics on arbitrary timing by calling Flush() as:

template_metrics.Flush()

ToDo

  • Write tests

Contribution

Copyright

go-template_metrics's People

Contributors

sonots avatar

Stargazers

 avatar KUBOTA Shota avatar

Watchers

Yosuke Furukawa avatar Spring_MT avatar nikushi avatar  avatar

Forkers

ieee0824

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.