github.com/vseinstrumentiru/lego@v1.0.2/internal/lego/monitor/propagation/jaegerwrap/http.go (about)

     1  package jaegerwrap
     2  
     3  import (
     4  	jaegerPropagation "contrib.go.opencensus.io/exporter/jaeger/propagation"
     5  	"fmt"
     6  	"go.opencensus.io/trace"
     7  	"net/http"
     8  	"strings"
     9  )
    10  
    11  const (
    12  	httpHeader = `uber-trace-id`
    13  )
    14  
    15  var parent = &jaegerPropagation.HTTPFormat{}
    16  
    17  type HTTPFormat struct{}
    18  
    19  func (f *HTTPFormat) SpanContextFromRequest(req *http.Request) (sc trace.SpanContext, ok bool) {
    20  	return parent.SpanContextFromRequest(req)
    21  }
    22  
    23  func (f *HTTPFormat) SpanContextToRequest(sc trace.SpanContext, req *http.Request) {
    24  	header := fmt.Sprintf("%s:%s:%s:%d",
    25  		strings.Replace(sc.TraceID.String(), "0000000000000000", "", 1), // Replacing 0 if string is 8bit
    26  		sc.SpanID.String(),
    27  		"0", // Parent span deprecated and will therefore be ignored.
    28  		int64(sc.TraceOptions))
    29  	req.Header.Set(httpHeader, header)
    30  }