From a1f4f3eec2c27f5a8653278137c5497fc8108e85 Mon Sep 17 00:00:00 2001 From: "Matt T. Proud" Date: Mon, 21 May 2012 10:43:21 +0200 Subject: [PATCH] - Extract main out of the package root and into the examples/ hierarchy. --- examples/simple/main.go | 22 ++++++++++++++++++++++ main.go | 13 ------------- export/registry.go => registry.go | 4 ++-- 3 files changed, 24 insertions(+), 15 deletions(-) create mode 100644 examples/simple/main.go delete mode 100644 main.go rename export/registry.go => registry.go (98%) 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()