// NewDistanceSensor returns a new DistanceSensor
172590
func NewDistanceSensor(TIME_BOOT_MS uint32, MIN_DISTANCE uint16, MAX_DISTANCE uint16, CURRENT_DISTANCE uint16, TYPE uint8, ID uint8, ORIENTATION uint8, COVARIANCE uint8) *DistanceSensor {
	m := DistanceSensor{}
	m.TIME_BOOT_MS = TIME_BOOT_MS
	m.MIN_DISTANCE = MIN_DISTANCE
	m.MAX_DISTANCE = MAX_DISTANCE
	m.CURRENT_DISTANCE = CURRENT_DISTANCE
	m.TYPE = TYPE
	m.ID = ID
	m.ORIENTATION = ORIENTATION
	m.COVARIANCE = COVARIANCE
	return &m
}
227796
func (s *Server) newSorterByDistanceFrom(cs lib.CoordinateSet, subj interface{}) (sort.Interface, error) {
	switch v := subj.(type) {
	case structs.Nodes:
		return s.newNodeSorter(cs, v)
	case structs.ServiceNodes:
		return s.newServiceNodeSorter(cs, v)
	case structs.HealthChecks:
		return s.newHealthCheckSorter(cs, v)
	case structs.CheckServiceNodes:
		return s.newCheckServiceNodeSorter(cs, v)
	default:
		panic(fmt.Errorf("Unhandled type passed to newSorterByDistanceFrom: %#v", subj))
	}
}
888830
func (p *dogstatsdProvider) NewCounter(name string) metrics.Counter {
	return p.d.NewCounter(name, 1.0)
}
946502
func (a Aggregations) GeoDistance(name string) (*AggregationBucketRangeItems, bool) {
	if raw, found := a[name]; found {
		agg := new(AggregationBucketRangeItems)
		if raw == nil {
			return agg, true
		}
		if err := json.Unmarshal(raw, agg); err == nil {
			return agg, true
		}
	}
	return nil, false
}
920539
func NewDetector(location string, pool *redis.Pool, strategy Strategy) Detector {
	return SimpleDetector{
		location: location,
		pool:     pool,
		strategy: strategy,
	}
}
1304917
func (p *statsdProvider) NewCounter(name string) metrics.Counter {
	return p.s.NewCounter(name, 1.0)
}
397296
func newRangeIterator(index *ShapeIndex) *rangeIterator {
	r := &rangeIterator{
		it: index.Iterator(),
	}
	r.refresh()
	return r
}
22015
func (p *Point) PointDistanceSquared(p2 Point) float32 {
	return (p.X-p2.X)*(p.X-p2.X) + (p.Y-p2.Y)*(p.Y-p2.Y)
}
624400
func NewListener(l net.Listener, pkfile, certfile string) (net.Listener, error) {
	return NewListenerAddr(l, l.Addr().String(), pkfile, certfile)
}
1096633
func (c *Characteristic) NewDescriptor(u UUID) *Descriptor {
	return c.AddDescriptor(&Descriptor{UUID: u})
}
612177
func New(addr string) *Metrics {
	met := &Metrics{
		Addr:    addr,
		Reg:     prometheus.NewRegistry(),
		zoneMap: make(map[string]struct{}),
	}
	// Add the default collectors
	met.MustRegister(prometheus.NewGoCollector())
	met.MustRegister(prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{}))

	// Add all of our collectors
	met.MustRegister(buildInfo)
	met.MustRegister(vars.Panic)
	met.MustRegister(vars.RequestCount)
	met.MustRegister(vars.RequestDuration)
	met.MustRegister(vars.RequestSize)
	met.MustRegister(vars.RequestDo)
	met.MustRegister(vars.RequestType)
	met.MustRegister(vars.ResponseSize)
	met.MustRegister(vars.ResponseRcode)
	met.MustRegister(vars.PluginEnabled)

	return met
}
566134
func NewIDAllocator(nextID uint32, maxID uint32) *IDAllocator {
	return &IDAllocator{
		entitiesID: map[uint32]*loadbalancer.L3n4AddrID{},
		entities:   map[string]uint32{},
		nextID:     nextID,
		maxID:      maxID,
		initNextID: nextID,
		initMaxID:  maxID,
	}
}
695634
func newDistanceSet() *distanceSet {
	return &distanceSet{
		MinDistance: math.MaxFloat64,
		Distances:   make(map[int]float64, 500), // adding 500 was a 20% performance win
	}
}
89082
func NewMetricsServer(addr string, appLister applister.ApplicationLister) *MetricsServer {
	mux := http.NewServeMux()
	appRegistry := NewAppRegistry(appLister)
	appRegistry.MustRegister(prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{}))
	appRegistry.MustRegister(prometheus.NewGoCollector())
	mux.Handle(MetricsPath, promhttp.HandlerFor(appRegistry, promhttp.HandlerOpts{}))

	syncCounter := prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "argocd_app_sync_total",
			Help: "Number of application syncs.",
		},
		append(descAppDefaultLabels, "phase"),
	)
	appRegistry.MustRegister(syncCounter)
	k8sRequestCounter := prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "argocd_app_k8s_request_total",
			Help: "Number of kubernetes requests executed during application reconciliation.",
		},
		append(descAppDefaultLabels, "response_code"),
	)
	appRegistry.MustRegister(k8sRequestCounter)

	reconcileHistogram := prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Name: "argocd_app_reconcile",
			Help: "Application reconciliation performance.",
			// Buckets chosen after observing a ~2100ms mean reconcile time
			Buckets: []float64{0.25, .5, 1, 2, 4, 8, 16},
		},
		append(descAppDefaultLabels),
	)

	appRegistry.MustRegister(reconcileHistogram)

	return &MetricsServer{
		Server: &http.Server{
			Addr:    addr,
			Handler: mux,
		},
		syncCounter:        syncCounter,
		k8sRequestCounter:  k8sRequestCounter,
		reconcileHistogram: reconcileHistogram,
	}
}
394715
func NewListener(net, laddr string) (net.Listener, error) {
	switch net {
	case "unix":
		return newUnixListener(laddr)
	case "tcp", "": // an empty net means tcp
		return newTCPListener(laddr)
	default:
		return nil, fmt.Errorf("unknown address type %s", net)
	}
}
960238
func NewTemperatureSensor(info Info, temp, min, max, steps float64) *Thermometer {
	acc := Thermometer{}
	acc.Accessory = New(info, TypeThermostat)
	acc.TempSensor = service.NewTemperatureSensor()
	acc.TempSensor.CurrentTemperature.SetValue(temp)
	acc.TempSensor.CurrentTemperature.SetMinValue(min)
	acc.TempSensor.CurrentTemperature.SetMaxValue(max)
	acc.TempSensor.CurrentTemperature.SetStepValue(steps)

	acc.AddService(acc.TempSensor.Service)

	return &acc
}
211256
func NewObserver(metricsFactory metrics.Factory, normalizer NameNormalizer) *Observer {
	return &Observer{
		metricsByEndpoint: newMetricsByEndpoint(
			metricsFactory,
			normalizer,
			defaultMaxNumberOfEndpoints,
		),
	}
}