 	registry: registry
 
 	metric: (type, name) ->
-		registry.getSingleMetric(name) || new MetricWrapper(type, name)
+		metrics.get(name) || new MetricWrapper(type, name)
 
 	collectDefaultMetrics: prom.collectDefaultMetrics
 
 
 class MetricWrapper
 	constructor: (type, name) ->
-		metrics[name] = this
+		metrics.set(name, this)
 		@name = name
-		@instances = {}
+		@instances = new Map()
 		@lastAccess = new Date()
 		@metric = switch type
 			when "counter"

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




	sweep: () ->
		thresh = new Date(Date.now() - 1000 * 60 * PromWrapper.ttlInMinutes)
		@instances.forEach (instance, key) =>
			if thresh > instance.time
				if process.env['DEBUG_METRICS']
					console.log("Sweeping stale metric instance", @name, opts: instance.opts, key)
				@metric.remove(optsAsArgs(instance.opts, @metric.labelNames)...)

		if thresh > @lastAccess
			if process.env['DEBUG_METRICS']
				console.log("Sweeping stale metric", @name, thresh, @lastAccess)
			metrics.delete(@name)
			registry.removeSingleMetric(@name)

	_execMethod: (method, opts, value) ->
		opts = extendOpts(opts, @metric.labelNames)
		key = optsKey(opts)
		@instances.set(key, { time: new Date(), opts }) unless key == ''
		@lastAccess = new Date()
		@metric[method](opts, value)

