// Newrelic returns a middleware function for newrelic monitoring.
350243
func Newrelic(opts ...*NewrelicOpts) fibre.MiddlewareFunc {
	return func(h fibre.HandlerFunc) fibre.HandlerFunc {
		return func(c *fibre.Context) error {

			var config *NewrelicOpts

			switch len(opts) {
			case 0:
				return h(c)
			default:
				config = opts[0]
			}

			// This is a socket
			if c.IsSocket() {
				return h(c)
			}

			// No config has been set
			if len(config.Name) == 0 || len(config.License) == 0 {
				return h(c)
			}

			if agent == nil {
				config := newrelic.NewConfig(config.Name, config.License)
				agent, _ = newrelic.NewApplication(config)
			}

			txn := agent.StartTransaction(c.Request().URL().Path, c.Response(), c.Request().Request)

			defer txn.End()

			return h(c)

		}
	}
}
327143
func NewDefaultRocR() (indicator *RocR, err error) {
	timePeriod := 10
	return NewRocR(timePeriod, gotrade.UseClosePrice)
}
1304917
func (p *statsdProvider) NewCounter(name string) metrics.Counter {
	return p.s.NewCounter(name, 1.0)
}
833774
func (this *FcmClient) newDevicesList(list []string) *FcmClient {
	this.Message.RegistrationIds = make([]string, len(list))
	copy(this.Message.RegistrationIds, list)

	return this

}
316285
func NewRegistry(s Storage, status, internal rest.Updater) Registry {
	return &storage{Storage: s, status: status, internal: internal}
}
108306
func NewBasic(ctx context.Context, next http.Handler, authConfig config.BasicAuth, name string) (http.Handler, error) {
	middlewares.GetLogger(ctx, name, basicTypeName).Debug("Creating middleware")
	users, err := getUsers(authConfig.UsersFile, authConfig.Users, basicUserParser)
	if err != nil {
		return nil, err
	}

	ba := &basicAuth{
		next:         next,
		users:        users,
		headerField:  authConfig.HeaderField,
		removeHeader: authConfig.RemoveHeader,
		name:         name,
	}

	realm := defaultRealm
	if len(authConfig.Realm) > 0 {
		realm = authConfig.Realm
	}
	ba.auth = goauth.NewBasicAuthenticator(realm, ba.secretBasic)

	return ba, nil
}
559671
func NewMonitor(defaultCheckHost string, defaultCheckEndpoint string) *Monitor {
	monitor := Monitor{
		Checks:               make(map[string]*Check, 5),
		CheckInterval:        HEALTH_INTERVAL,
		DefaultCheckHost:     defaultCheckHost,
		DefaultCheckEndpoint: defaultCheckEndpoint,
	}
	return &monitor
}
100894
func newRecord(key string, rls *rspb.Release) *record {
	var lbs labels

	lbs.init()
	lbs.set("NAME", rls.Name)
	lbs.set("OWNER", "TILLER")
	lbs.set("STATUS", rspb.Status_Code_name[int32(rls.Info.Status.Code)])
	lbs.set("VERSION", strconv.Itoa(int(rls.Version)))

	return &record{key: key, lbs: lbs, rls: proto.Clone(rls).(*rspb.Release)}
}
1138049
func NewDefaultRoc() (indicator *Roc, err error) {
	timePeriod := 10
	return NewRoc(timePeriod, gotrade.UseClosePrice)
}
203040
func NewMiddlewareFromLogger(logger *logrus.Logger, name string) *Middleware {
	return &Middleware{
		Logger: logger,
		Name:   name,
		Before: DefaultBefore,
		After:  DefaultAfter,

		logStarting: true,
		clock:       &realClock{},
	}
}
408539
func (l *LiteBackend) NewWatcher(ctx context.Context, watch backend.Watch) (backend.Watcher, error) {
	if l.EventsOff {
		return nil, trace.BadParameter("events are turned off for this backend")
	}
	select {
	case <-l.watchStarted.Done():
	case <-ctx.Done():
		return nil, trace.ConnectionProblem(ctx.Err(), "context is closing")
	}
	return l.buf.NewWatcher(ctx, watch)
}
522803
func (pgb *ChainDBRPC) NewChainMonitor(ctx context.Context, wg *sync.WaitGroup,
	blockChan chan *chainhash.Hash, reorgChan chan *txhelpers.ReorgData) *ChainMonitor {
	if pgb == nil {
		return nil
	}
	return &ChainMonitor{
		ctx:            ctx,
		db:             pgb,
		wg:             wg,
		blockChan:      blockChan,
		reorgChan:      reorgChan,
		ConnectingLock: make(chan struct{}, 1),
		DoneConnecting: make(chan struct{}),
	}
}
16641
func New() *GCNotifier {
	n := &gcnotifier{
		gcCh:   make(chan struct{}, 1),
		doneCh: make(chan struct{}, 1),
	}
	// sentinel is dead immediately after the call to SetFinalizer
	runtime.SetFinalizer(&sentinel{gcCh: n.gcCh, doneCh: n.doneCh}, finalizer)
	// n will be dead when the GCNotifier that wraps it (see the return below) is dead
	runtime.SetFinalizer(n, autoclose)
	// we wrap the internal gcnotifier object in a GCNotifier so that we can
	// safely call autoclose when the GCNotifier becomes unreachable
	return &GCNotifier{n: n}
}
356385
func NewListener(t string, config map[string]interface{}, logger io.Writer, ui cli.Ui) (net.Listener, map[string]string, reload.ReloadFunc, error) {
	f, ok := BuiltinListeners[t]
	if !ok {
		return nil, nil, nil, fmt.Errorf("unknown listener type: %q", t)
	}

	return f(config, logger, ui)
}
1238572
func (cw *CloudWatch) NewGauge(name string) metrics.Gauge {
	return convert.NewCounterAsGauge(cw.NewCounter(name))
}
211256
func NewObserver(metricsFactory metrics.Factory, normalizer NameNormalizer) *Observer {
	return &Observer{
		metricsByEndpoint: newMetricsByEndpoint(
			metricsFactory,
			normalizer,
			defaultMaxNumberOfEndpoints,
		),
	}
}
695959
func NewIntErr(f func(string) (int, error), s string) *IntErr {
	this := &IntErr{}
	this.I, this.E = f(s)
	return this
}