// Extract delegates to opentracing.Tracer.
12101
func (t *Tracing) Extract(format interface{}, carrier interface{}) (opentracing.SpanContext, error) {
	return t.tracer.Extract(format, carrier)
}
1022297
func (mr *MockExtractorMockRecorder) Extract(arg0 interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Extract", reflect.TypeOf((*MockExtractor)(nil).Extract), arg0)
}
464785
func Tracer(tracer opentracing.Tracer) macaron.Handler {
	return func(macCtx *macaron.Context) {
		path := pathSlug(macCtx.Req.URL.Path)
		// graphite cluster requests use local=1
		// this way we can differentiate "full" render requests from client to MT (encompassing data processing, proxing to graphite, etc)
		// from "subrequests" where metrictank is called by graphite and graphite does the processing and returns to the client
		if macCtx.Req.Request.Form.Get("local") == "1" {
			path += "-local"
		}

		spanCtx, _ := tracer.Extract(opentracing.HTTPHeaders, opentracing.HTTPHeadersCarrier(macCtx.Req.Header))
		span := tracer.StartSpan("HTTP "+macCtx.Req.Method+" "+path, ext.RPCServerOption(spanCtx))

		ext.HTTPMethod.Set(span, macCtx.Req.Method)
		ext.HTTPUrl.Set(span, macCtx.Req.URL.String())
		ext.Component.Set(span, "metrictank/api")

		macCtx.Req = macaron.Request{macCtx.Req.WithContext(opentracing.ContextWithSpan(macCtx.Req.Context(), span))}
		macCtx.Resp = &TracingResponseWriter{
			ResponseWriter: macCtx.Resp,
		}
		macCtx.MapTo(macCtx.Resp, (*http.ResponseWriter)(nil))

		rw := macCtx.Resp.(*TracingResponseWriter)

		// if tracing is enabled (context is not a opentracing.noopSpanContext)
		// store traceID in output headers
		if spanCtx, ok := span.Context().(jaeger.SpanContext); ok {
			traceID := spanCtx.TraceID().String()
			headers := macCtx.Resp.Header()
			headers["Trace-Id"] = []string{traceID}
		}

		// call next handler. This will return after all handlers
		// have completed and the request has been sent.
		macCtx.Next()

		// if tracing has been disabled we return directly without calling
		// span.Finish()
		if noTrace, ok := macCtx.Data["noTrace"]; ok && noTrace.(bool) {
			return
		}

		status := rw.Status()
		ext.HTTPStatusCode.Set(span, uint16(status))
		if status >= 200 && status < 300 {
			span.SetTag("http.size", rw.Size())
		}
		if status >= 400 {
			tracing.Error(span, errors.New(string(rw.errBody)))
			if status >= http.StatusInternalServerError {
				tracing.Failure(span)
			}
		}
		span.Finish()
	}
}
545680
func (g *Group) Trace(path string, h HandlerFunc, opts ...HandlerOption) {
	g.add(path, h, opts, http.MethodTrace)
}
755510
func Tracer(sampleRate int, spanIDFunc, traceIDFunc IDFunc) goa.Middleware {
	return NewTracer(SamplingPercent(sampleRate), SpanIDFunc(spanIDFunc), TraceIDFunc(traceIDFunc))
}
1344287
func ExtractTo(srcPath, destPath string, entries ...string) (err error) {
	return ExtractToFunc(srcPath, destPath, defaultExtractFunc, entries...)
}
587746
func (tz *TzArchive) ExtractToFunc(destPath string, fn cae.HookFunc, entries ...string) (err error) {
	destPath = strings.Replace(destPath, "\\", "/", -1)
	isHasEntry := len(entries) > 0
	if Verbose {
		fmt.Println("Extracting " + tz.FileName + "...")
	}
	os.MkdirAll(destPath, os.ModePerm)

	// Copy post-added files.
	for _, f := range tz.files {
		if !cae.IsExist(f.absPath) {
			continue
		}

		relPath := path.Join(destPath, f.Name)
		os.MkdirAll(path.Dir(relPath), os.ModePerm)
		if err := cae.Copy(relPath, f.absPath); err != nil {
			return err
		}
	}

	tr, f, err := openFile(tz.FileName)
	if err != nil {
		return err
	}
	defer f.Close()

	for {
		h, err := tr.Next()
		if err == io.EOF {
			break
		} else if err != nil {
			return err
		}

		h.Name = strings.Replace(h.Name, "\\", "/", -1)

		// Directory.
		if h.Typeflag == tar.TypeDir {
			if isHasEntry {
				if cae.IsEntry(h.Name, entries) {
					if err = fn(h.Name, h.FileInfo()); err != nil {
						continue
					}
					os.MkdirAll(path.Join(destPath, h.Name), os.ModePerm)
				}
				continue
			}
			if err = fn(h.Name, h.FileInfo()); err != nil {
				continue
			}
			os.MkdirAll(path.Join(destPath, h.Name), os.ModePerm)
			continue
		}

		// File.
		if isHasEntry {
			if cae.IsEntry(h.Name, entries) {
				if err = fn(h.Name, h.FileInfo()); err != nil {
					continue
				}
				err = extractFile(h, tr, destPath)
			}
		} else {
			if err = fn(h.Name, h.FileInfo()); err != nil {
				continue
			}
			err = extractFile(h, tr, destPath)
		}
		if err != nil {
			return err
		}
	}
	return nil
}
1031320
func TracerFromRequest(req *http.Request) *Tracer {
	tr, ok := req.Context().Value(keyTracer).(*Tracer)
	if !ok {
		return nil
	}
	return tr
}
1291009
func (se *StdExtractor) Extract(e *Entry) error {
	if se.rxFields == nil {
		se.rxFields = regexp.MustCompile(fieldsRegex)
	}
	matches := se.rxFields.FindAllSubmatch(e.Message, -1)
	if matches == nil {
		return nil
	}

	var key, value []byte
	captures := make(map[string]interface{})

	// Look for positions with: fmt.Printf("%#v \n", rxFields.SubexpNames())
	// Will find positions []string{"", "key", "", "", "value", "", "quoted", ""}
	//                                    1               4            6

	for _, match := range matches {
		// First group, simple key-value detected
		if len(match[1]) > 0 && len(match[4]) > 0 {
			key, value = match[1], match[4]
		}

		// Second group, quoted value detected
		if len(match[1]) > 0 && len(match[6]) > 0 {
			key, value = match[1], match[6]
			value = value[1 : len(value)-1] // remove quotes, first and last character
		}

		captures[string(key)] = string(value)
	}

	if captures != nil {
		// Eliminate key=value from text and trim from the right
		e.Message = bytes.TrimRight(se.rxFields.ReplaceAll(e.Message, nil), " \n")
		for k, v := range captures {
			e.Fields[k] = v
		}
	}

	return nil
}
1018290
func ExtractScopes(opts ...interface{}) *opt.ScopesOption {
	for _, o := range opts {
		if v, ok := o.(*opt.ScopesOption); ok {
			return v
		}
	}
	return nil
}
780069
func getTrace(errs ...error) string {
	for _, err := range errs {
		if err != nil {
			terr, ok := err.(stackTracer)
			if ok {
				return fmt.Sprintf("%+v", terr.StackTrace())
			}
		}
	}
	return E_EMPTY_TRACE
}
174867
func (NoopTracer) TraceBatch(ctx context.Context, keys Keys) (context.Context, TraceBatchFinishFunc) {
	return ctx, func(result []*Result) {}
}
1126650
func GetLightStepReporterID(tracer opentracing.Tracer) (uint64, error) {
	switch lsTracer := tracer.(type) {
	case *tracerImpl:
		return lsTracer.reporterID, nil
	case *tracerv0_14:
		return GetLightStepReporterID(lsTracer.Tracer)
	default:
		return 0, newEventUnsupportedTracer(tracer)
	}
}
210564
func ExtractFacetingAfterDistinct(opts ...interface{}) *opt.FacetingAfterDistinctOption {
	for _, o := range opts {
		if v, ok := o.(*opt.FacetingAfterDistinctOption); ok {
			return v
		}
	}
	return nil
}
293207
func (p *TextMapPropagator) Extract(abstractCarrier interface{}) (SpanContext, error) {
	textMapReader, ok := abstractCarrier.(opentracing.TextMapReader)
	if !ok {
		return emptyContext, opentracing.ErrInvalidCarrier
	}
	var ctx SpanContext
	var baggage map[string]string
	err := textMapReader.ForeachKey(func(rawKey, value string) error {
		key := strings.ToLower(rawKey) // TODO not necessary for plain TextMap
		if key == p.headerKeys.TraceContextHeaderName {
			var err error
			safeVal := p.decodeValue(value)
			if ctx, err = ContextFromString(safeVal); err != nil {
				return err
			}
		} else if key == p.headerKeys.JaegerDebugHeader {
			ctx.debugID = p.decodeValue(value)
		} else if key == p.headerKeys.JaegerBaggageHeader {
			if baggage == nil {
				baggage = make(map[string]string)
			}
			for k, v := range p.parseCommaSeparatedMap(value) {
				baggage[k] = v
			}
		} else if strings.HasPrefix(key, p.headerKeys.TraceBaggageHeaderPrefix) {
			if baggage == nil {
				baggage = make(map[string]string)
			}
			safeKey := p.removeBaggageKeyPrefix(key)
			safeVal := p.decodeValue(value)
			baggage[safeKey] = safeVal
		}
		return nil
	})
	if err != nil {
		p.metrics.DecodingErrors.Inc(1)
		return emptyContext, err
	}
	if !ctx.traceID.IsValid() && ctx.debugID == "" && len(baggage) == 0 {
		return emptyContext, opentracing.ErrSpanContextNotFound
	}
	ctx.baggage = baggage
	return ctx, nil
}
530995
func (bj BinaryJSON) Extract(pathExprList []PathExpression) (ret BinaryJSON, found bool) {
	buf := make([]BinaryJSON, 0, 1)
	for _, pathExpr := range pathExprList {
		buf = bj.extractTo(buf, pathExpr)
	}
	if len(buf) == 0 {
		found = false
	} else if len(pathExprList) == 1 && len(buf) == 1 {
		// If pathExpr contains asterisks, len(elemList) won't be 1
		// even if len(pathExprList) equals to 1.
		found = true
		ret = buf[0]
	} else {
		found = true
		ret = buildBinaryArray(buf)
	}
	return
}
783309
func WithTracing(ctx context.Context, tracing *Tracing) context.Context {
	return context.WithValue(ctx, tracingKey, tracing)
}