|
|
@ -18,8 +18,10 @@ import ( |
|
|
|
"context" |
|
|
|
"context" |
|
|
|
"errors" |
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
|
"fmt" |
|
|
|
|
|
|
|
"go.opentelemetry.io/otel/attribute" |
|
|
|
"io" |
|
|
|
"io" |
|
|
|
"net/http" |
|
|
|
"net/http" |
|
|
|
|
|
|
|
"net/http/httptrace" |
|
|
|
"strconv" |
|
|
|
"strconv" |
|
|
|
"strings" |
|
|
|
"strings" |
|
|
|
"time" |
|
|
|
"time" |
|
|
@ -279,7 +281,36 @@ func (c *Client) Store(ctx context.Context, req []byte, attempt int) (WriteRespo |
|
|
|
ctx, span := otel.Tracer("").Start(ctx, "Remote Store", trace.WithSpanKind(trace.SpanKindClient)) |
|
|
|
ctx, span := otel.Tracer("").Start(ctx, "Remote Store", trace.WithSpanKind(trace.SpanKindClient)) |
|
|
|
defer span.End() |
|
|
|
defer span.End() |
|
|
|
|
|
|
|
|
|
|
|
httpResp, err := c.Client.Do(httpReq.WithContext(ctx)) |
|
|
|
httpReqTrace := &httptrace.ClientTrace{ |
|
|
|
|
|
|
|
GetConn: func(hostPort string) { |
|
|
|
|
|
|
|
span.AddEvent("GetConn", trace.WithAttributes(attribute.String("host", hostPort))) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
GotConn: func(info httptrace.GotConnInfo) { |
|
|
|
|
|
|
|
span.AddEvent("GotConn", trace.WithAttributes( |
|
|
|
|
|
|
|
attribute.Bool("reused", info.Reused), |
|
|
|
|
|
|
|
attribute.Bool("wasIdle", info.WasIdle), |
|
|
|
|
|
|
|
//attribute.Duration("idleTime", info.IdleTime),
|
|
|
|
|
|
|
|
)) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
DNSStart: func(info httptrace.DNSStartInfo) { |
|
|
|
|
|
|
|
span.AddEvent("DNSStart", trace.WithAttributes(attribute.String("host", info.Host))) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
DNSDone: func(info httptrace.DNSDoneInfo) { |
|
|
|
|
|
|
|
span.AddEvent("DNSDone", trace.WithAttributes(attribute.Bool("coalesced", info.Coalesced))) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
ConnectStart: func(network, addr string) { |
|
|
|
|
|
|
|
span.AddEvent("ConnectStart", trace.WithAttributes(attribute.String("network", network), attribute.String("addr", addr))) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
ConnectDone: func(network, addr string, err error) { |
|
|
|
|
|
|
|
attrs := []attribute.KeyValue{attribute.String("network", network), attribute.String("addr", addr)} |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
attrs = append(attrs, attribute.String("error", err.Error())) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
span.AddEvent("ConnectDone", trace.WithAttributes(attrs...)) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
httpResp, err := c.Client.Do(httpReq.WithContext(httptrace.WithClientTrace(ctx, httpReqTrace))) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
// Errors from Client.Do are from (for example) network errors, so are
|
|
|
|
// Errors from Client.Do are from (for example) network errors, so are
|
|
|
|
// recoverable.
|
|
|
|
// recoverable.
|
|
|
|