// QueuedSpansCount returns the number of queued spans
//   Used only in tests currently.
487079
func (r *Recorder) QueuedSpansCount() int {
	r.RLock()
	defer r.RUnlock()
	return len(r.spans)
}
207255
func countPsubs(subs []*Subscriber) int {
	n := 0
	for _, p := range subs {
		n += len(p.patterns)
	}
	return n
}
854671
func (t *Tracer) StartSpanFromContext(ctx context.Context, operationName string) (tracing.Span, context.Context) {
	var opts []opentracing.StartSpanOption
	if parent := opentracing.SpanFromContext(ctx); parent != nil {
		opts = append(opts, opentracing.ChildOf(parent.Context()))
	}
	span := t.tracer.StartSpan(operationName, opts...)
	return span, opentracing.ContextWithSpan(ctx, span)
}
580937
func NetworkCount() (count int, err error) {
	err = mgr.Do(func(ctx context.Context, cli *client.Client) (err error) {
		var networks []types.NetworkResource
		networks, err = cli.NetworkList(ctx, types.NetworkListOptions{})
		if err == nil {
			count = len(networks)
		}
		return
	})
	return
}
387939
func (p *pool) Count() int {
	p.RLock()
	defer p.RUnlock()
	return len(p.plugins)
}
302004
func (r *InMemoryReporter) GetSpans() []opentracing.Span {
	r.lock.Lock()
	defer r.lock.Unlock()
	copied := make([]opentracing.Span, len(r.spans))
	copy(copied, r.spans)
	return copied
}
1042957
func (r *InMemorySpanRecorder) RecordSpan(span RawSpan) {
	r.Lock()
	defer r.Unlock()
	r.spans = append(r.spans, span)
}
317800
func (t *Tracer) StartSpan(
	operationName string,
	options ...opentracing.StartSpanOption,
) opentracing.Span {
	sso := opentracing.StartSpanOptions{}
	for _, o := range options {
		o.Apply(&sso)
	}
	return t.startSpanWithOptions(operationName, sso)
}
244509
func (ar AggregatedSendResult) AckCount() int {
	c := 0
	for _, ack := range ar {
		if ack.error == nil {
			c++
		}
	}
	return c
}
723350
func (c *T) Counts() conntracker.ConnectionStats {
	c.mu.Lock()
	defer c.mu.Unlock()

	return conntracker.ConnectionStats{
		http.StateNew:    c.copy(c.new),
		http.StateActive: c.copy(c.active),
		http.StateIdle:   c.copy(c.idle),
	}
}
1099613
func (a *AdditionalSpanTags) AddSpans(ctx context.Context, spans []*trace.Span) error {
	for _, s := range spans {
		if s.Tags == nil {
			s.Tags = make(map[string]string, len(a.tags))
		}

		for k, v := range a.tags {
			s.Tags[k] = v
		}
	}
	return a.next.AddSpans(ctx, spans)
}
68702
func (ns *Namespace) RuneCount(s interface{}) (int, error) {
	ss, err := cast.ToStringE(s)
	if err != nil {
		return 0, _errors.Wrap(err, "Failed to convert content to string")
	}
	return utf8.RuneCountInString(ss), nil
}
393151
func (a *AsyncMultiTokenSink) AddSpansWithToken(token string, spans []*trace.Span) (err error) {
	var channelID int64
	if channelID, err = a.getChannel(token, len(a.evChannels)); err == nil {
		var worker = a.spanChannels[channelID]
		_ = atomic.AddInt64(&a.spansBuffered, int64(len(spans)))
		var m = &spanMsg{
			token: token,
			data:  spans,
		}
		select {
		// check if the sink is closing and return if so
		// reading from a.closing will only return a value if the a.closing channel is closed
		case <-a.closing:
			err = fmt.Errorf("unable to add spans: the worker has been stopped")
		default:
			select {
			case worker.input <- m:
				atomic.AddInt64(&a.stats.TotalSpansBuffered, int64(len(spans)))
			default:
				err = fmt.Errorf("unable to add spans: the input buffer is full")
			}
		}

	} else {
		err = fmt.Errorf("unable to add spans: there was an error while hashing the token to a worker. %v", err)
	}

	return
}
177317
func ServiceCount() (count int, err error) {
	err = mgr.Do(func(ctx context.Context, cli *client.Client) (err error) {
		var services []swarm.Service
		if services, err = cli.ServiceList(ctx, types.ServiceListOptions{}); err == nil {
			count = len(services)
		}
		return
	})
	return
}
1252378
func StartSpan(ctx context.Context, operationName string, opts ...opentracing.StartSpanOption) (opentracing.Span, context.Context) {
	parent := opentracing.SpanFromContext(ctx)
	tracer := opentracing.Tracer(&opentracing.NoopTracer{})
	if parent != nil {
		tracer = parent.Tracer()
		opts = append(opts, opentracing.ChildOf(parent.Context()))
	}
	span := tracer.StartSpan(operationName, opts...)
	if parent != nil {
		return span, opentracing.ContextWithSpan(ctx, span)
	}
	return span, ctx
}
699174
func (s *server) MemberCount() int {
	s.mutex.RLock()
	defer s.mutex.RUnlock()
	return len(s.peers) + 1
}
324402
func (f *File) LineCount() int {
	f.set.mutex.RLock()
	n := len(f.lines)
	f.set.mutex.RUnlock()
	return n
}