diff --git a/examples/simple/main.go b/examples/simple/main.go new file mode 100644 index 0000000..61d1a6f --- /dev/null +++ b/examples/simple/main.go @@ -0,0 +1,22 @@ +// Copyright (c) 2012, Matt T. Proud +// All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// main.go provides a simple skeletal example of how this instrumentation +// framework is registered and invoked. + +package main + +import ( + "github.com/matttproud/golang_instrumentation" + "net/http" +) + +func main() { + exporter := registry.DefaultRegistry.YieldExporter() + + http.Handle("/metrics.json", exporter) + http.ListenAndServe(":8080", nil) +} diff --git a/main.go b/main.go deleted file mode 100644 index 851c50f..0000000 --- a/main.go +++ /dev/null @@ -1,13 +0,0 @@ -package main - -import ( - "github.com/matttproud/golang_instrumentation/export" - "net/http" -) - -func main() { - exporter := export.DefaultRegistry.YieldExporter() - - http.Handle("/metrics.json", exporter) - http.ListenAndServe(":8080", nil) -} diff --git a/export/registry.go b/registry.go similarity index 98% rename from export/registry.go rename to registry.go index 2b3ca53..ad28469 100644 --- a/export/registry.go +++ b/registry.go @@ -7,7 +7,7 @@ // registry.go provides a container for centralization exposition of metrics to // their prospective consumers. -package export +package registry import ( "encoding/json" @@ -94,7 +94,7 @@ func (r *Registry) Register(name string, metric metrics.Metric) { // Create a http.HandlerFunc that is tied to r Registry such that requests // against it generate a representation of the housed metrics. -func (registry *Registry) YieldExporter() *http.HandlerFunc { +func (registry *Registry) YieldExporter() http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var instrumentable metrics.InstrumentableCall = func() { requestCount.Increment()