Skip to content

midumitrescu/go-zmonmetrics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

package zmonmetrics
    import (
        zmon2 "github.com/zalando/go-zmonmetrics"
        ...
    )

    go package for use with goat (https://github.com/bahlo/goat) and zmon
    (https://github.com/zalando/zmon) to collect metrics

FUNCTIONS

func Handler(h http.Handler, u func(r *http.Request, c int) string) http.Handler
    this one needs to be wrapped in main like

	func ZMon2Metrics (h http.Handler) http.Handler {
	   return zmon2.Handler(h, url2key)
	}

	// this is the default if the func is nil:
	func url2key(r *http.Request, code int) (url string) {
	   // bare minimum is to replace all "/" by ".":
	   url = strings.Replace(r.URL.Path, "//", "/", -1)[1:] // exclude leading "/"
	   url = strings.Replace(url, "/", ".", -1)
	   return
	}

    ... and use it:

	func main() {
	  ...
	  r.Use(ZMon2Metrics)
	  r.Get("/metrics", "ZMon2 Metrics", zmon2.MetricsHandler)
	}

func MetricsHandler(w http.ResponseWriter, r *http.Request, p goat.Params)

TYPES

type Metrics struct {
    UrlToKey func(r *http.Request, c int) string
    // contains filtered or unexported fields
}

func (m *Metrics) ServeHTTP(w http.ResponseWriter, r *http.Request)

---------

Copyright 2015 Zalando SE

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Releases

No releases published

Packages

No packages published

Languages