 prom = require('prom-client')
 registry = require('prom-client').register
-metrics = {}
+metrics = new Map()
 
 
 optsKey = (opts) ->

			if PromWrapper.ttlInMinutes
				if process.env['DEBUG_METRICS']
					console.log("Sweeping metrics")
				for key in Object.keys(metrics)
					metrics[key].sweep()
	60000)



	registry: registry

	metric: (type, name) ->
		metrics.get(name) || new MetricWrapper(type, name)

	collectDefaultMetrics: prom.collectDefaultMetrics


class MetricWrapper
	constructor: (type, name) ->
		metrics.set(name, this)
		@name = name
		@instances = new Map()
		@lastAccess = new Date()
		@metric = switch type
			when "counter"
