upgrade opentracing. change sendpriority to send for request.from.peers

This commit is contained in:
Anton Evangelatov 2019-03-14 12:23:18 +01:00
parent 5b46c6654d
commit 03d0d2633b
7 changed files with 28 additions and 28 deletions

View file

@ -295,11 +295,13 @@ func (d *Delivery) RequestFromPeers(ctx context.Context, req *network.Request) (
// this span will finish only when delivery is handled (or times out) // this span will finish only when delivery is handled (or times out)
ctx = context.WithValue(ctx, tracing.StoreLabelId, "stream.send.request") ctx = context.WithValue(ctx, tracing.StoreLabelId, "stream.send.request")
ctx = context.WithValue(ctx, tracing.StoreLabelMeta, fmt.Sprintf("%v.%v", sp.ID(), req.Addr)) ctx = context.WithValue(ctx, tracing.StoreLabelMeta, fmt.Sprintf("%v.%v", sp.ID(), req.Addr))
err := sp.SendPriority(ctx, &RetrieveRequestMsg{ ctx = tracing.StartSaveSpan(ctx)
log.Trace("request.from.peers", "peer", sp.ID(), "ref", req.Addr)
err := sp.Send(ctx, &RetrieveRequestMsg{
Addr: req.Addr, Addr: req.Addr,
SkipCheck: req.SkipCheck, SkipCheck: req.SkipCheck,
HopCount: req.HopCount, HopCount: req.HopCount,
}, Top) })
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }

View file

@ -10,5 +10,5 @@ Changes by Version
1.0.0 (2016-09-26) 1.0.0 (2016-09-26)
------------------- -------------------
- This release implements OpenTracing Specification 1.0 (http://opentracing.io/spec) - This release implements OpenTracing Specification 1.0 (https://opentracing.io/spec)

View file

@ -1,26 +1,15 @@
PACKAGES := . ./mocktracer/... ./ext/...
.DEFAULT_GOAL := test-and-lint .DEFAULT_GOAL := test-and-lint
.PHONE: test-and-lint .PHONY: test-and-lint
test-and-lint: test lint test-and-lint: test lint
.PHONY: test .PHONY: test
test: test:
go test -v -cover -race ./... go test -v -cover -race ./...
.PHONY: cover
cover: cover:
@rm -rf cover-all.out go test -v -coverprofile=coverage.txt -covermode=atomic -race ./...
$(foreach pkg, $(PACKAGES), $(MAKE) cover-pkg PKG=$(pkg) || true;)
@grep mode: cover.out > coverage.out
@cat cover-all.out >> coverage.out
go tool cover -html=coverage.out -o cover.html
@rm -rf cover.out cover-all.out coverage.out
cover-pkg:
go test -coverprofile cover.out $(PKG)
@grep -v mode: cover.out >> cover-all.out
.PHONY: lint .PHONY: lint
lint: lint:
@ -29,4 +18,3 @@ lint:
@# Run again with magic to exit non-zero if golint outputs anything. @# Run again with magic to exit non-zero if golint outputs anything.
@! (golint ./... | read dummy) @! (golint ./... | read dummy)
go vet ./... go vet ./...

View file

@ -8,8 +8,8 @@ This package is a Go platform API for OpenTracing.
## Required Reading ## Required Reading
In order to understand the Go platform API, one must first be familiar with the In order to understand the Go platform API, one must first be familiar with the
[OpenTracing project](http://opentracing.io) and [OpenTracing project](https://opentracing.io) and
[terminology](http://opentracing.io/documentation/pages/spec.html) more specifically. [terminology](https://opentracing.io/specification/) more specifically.
## API overview for those adding instrumentation ## API overview for those adding instrumentation

View file

@ -1,7 +1,12 @@
package opentracing package opentracing
type registeredTracer struct {
tracer Tracer
isRegistered bool
}
var ( var (
globalTracer Tracer = NoopTracer{} globalTracer = registeredTracer{NoopTracer{}, false}
) )
// SetGlobalTracer sets the [singleton] opentracing.Tracer returned by // SetGlobalTracer sets the [singleton] opentracing.Tracer returned by
@ -11,22 +16,27 @@ var (
// Prior to calling `SetGlobalTracer`, any Spans started via the `StartSpan` // Prior to calling `SetGlobalTracer`, any Spans started via the `StartSpan`
// (etc) globals are noops. // (etc) globals are noops.
func SetGlobalTracer(tracer Tracer) { func SetGlobalTracer(tracer Tracer) {
globalTracer = tracer globalTracer = registeredTracer{tracer, true}
} }
// GlobalTracer returns the global singleton `Tracer` implementation. // GlobalTracer returns the global singleton `Tracer` implementation.
// Before `SetGlobalTracer()` is called, the `GlobalTracer()` is a noop // Before `SetGlobalTracer()` is called, the `GlobalTracer()` is a noop
// implementation that drops all data handed to it. // implementation that drops all data handed to it.
func GlobalTracer() Tracer { func GlobalTracer() Tracer {
return globalTracer return globalTracer.tracer
} }
// StartSpan defers to `Tracer.StartSpan`. See `GlobalTracer()`. // StartSpan defers to `Tracer.StartSpan`. See `GlobalTracer()`.
func StartSpan(operationName string, opts ...StartSpanOption) Span { func StartSpan(operationName string, opts ...StartSpanOption) Span {
return globalTracer.StartSpan(operationName, opts...) return globalTracer.tracer.StartSpan(operationName, opts...)
} }
// InitGlobalTracer is deprecated. Please use SetGlobalTracer. // InitGlobalTracer is deprecated. Please use SetGlobalTracer.
func InitGlobalTracer(tracer Tracer) { func InitGlobalTracer(tracer Tracer) {
SetGlobalTracer(tracer) SetGlobalTracer(tracer)
} }
// IsGlobalTracerRegistered returns a `bool` to indicate if a tracer has been globally registered
func IsGlobalTracerRegistered() bool {
return globalTracer.isRegistered
}

View file

@ -160,7 +160,7 @@ type HTTPHeadersCarrier http.Header
// Set conforms to the TextMapWriter interface. // Set conforms to the TextMapWriter interface.
func (c HTTPHeadersCarrier) Set(key, val string) { func (c HTTPHeadersCarrier) Set(key, val string) {
h := http.Header(c) h := http.Header(c)
h.Add(key, val) h.Set(key, val)
} }
// ForeachKey conforms to the TextMapReader interface. // ForeachKey conforms to the TextMapReader interface.

6
vendor/vendor.json vendored
View file

@ -352,10 +352,10 @@
"revisionTime": "2017-01-28T05:05:32Z" "revisionTime": "2017-01-28T05:05:32Z"
}, },
{ {
"checksumSHA1": "wIcN7tZiF441h08RHAm4NV8cYO4=", "checksumSHA1": "a/DHmc9bdsYlZZcwp6i3xhvV7Pk=",
"path": "github.com/opentracing/opentracing-go", "path": "github.com/opentracing/opentracing-go",
"revision": "bd9c3193394760d98b2fa6ebb2291f0cd1d06a7d", "revision": "25a84ff92183e2f8ac018ba1db54f8a07b3c0e04",
"revisionTime": "2018-06-06T20:41:48Z" "revisionTime": "2019-02-18T02:30:34Z"
}, },
{ {
"checksumSHA1": "uhDxBvLEqRAMZKgpTZ8MFuLIIM8=", "checksumSHA1": "uhDxBvLEqRAMZKgpTZ8MFuLIIM8=",