Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Commit de37041

Browse files
authored
Revert "Allow replacing trace SDK (#1234)" (#1235)
This reverts commit fc3822b.
1 parent fc3822b commit de37041

13 files changed

Lines changed: 80 additions & 245 deletions

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
4848
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
4949
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
5050
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
51-
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
52-
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
5351
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
5452
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
5553
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

plugin/ochttp/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ type Transport struct {
5656
// name equals the URL Path.
5757
FormatSpanName func(*http.Request) string
5858

59-
// NewClientTrace may be set to a function allowing the current trace.Span
59+
// NewClientTrace may be set to a function allowing the current *trace.Span
6060
// to be annotated with HTTP request event information emitted by the
6161
// httptrace package.
62-
NewClientTrace func(*http.Request, trace.Span) *httptrace.ClientTrace
62+
NewClientTrace func(*http.Request, *trace.Span) *httptrace.ClientTrace
6363

6464
// TODO: Implement tag propagation for HTTP.
6565
}

plugin/ochttp/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func (h *Handler) startTrace(w http.ResponseWriter, r *http.Request) (*http.Requ
109109
startOpts = h.GetStartOptions(r)
110110
}
111111

112-
var span trace.Span
112+
var span *trace.Span
113113
sc, ok := h.extractSpanContext(r)
114114
if ok && !h.IsPublicEndpoint {
115115
ctx, span = trace.StartSpanWithRemoteParent(ctx, name, sc,

plugin/ochttp/server_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ func TestIgnoreHealthEndpoints(t *testing.T) {
584584
ts := httptest.NewServer(&Handler{
585585
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
586586
span := trace.FromContext(r.Context())
587-
if span.IsRecordingEvents() {
587+
if span != nil {
588588
spans++
589589
}
590590
fmt.Fprint(w, "ok")

plugin/ochttp/span_annotating_client_trace.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,21 @@ import (
2424
)
2525

2626
type spanAnnotator struct {
27-
sp trace.Span
27+
sp *trace.Span
2828
}
2929

3030
// TODO: Remove NewSpanAnnotator at the next release.
3131

3232
// NewSpanAnnotator returns a httptrace.ClientTrace which annotates
3333
// all emitted httptrace events on the provided Span.
3434
// Deprecated: Use NewSpanAnnotatingClientTrace instead
35-
func NewSpanAnnotator(r *http.Request, s trace.Span) *httptrace.ClientTrace {
35+
func NewSpanAnnotator(r *http.Request, s *trace.Span) *httptrace.ClientTrace {
3636
return NewSpanAnnotatingClientTrace(r, s)
3737
}
3838

3939
// NewSpanAnnotatingClientTrace returns a httptrace.ClientTrace which annotates
4040
// all emitted httptrace events on the provided Span.
41-
func NewSpanAnnotatingClientTrace(_ *http.Request, s trace.Span) *httptrace.ClientTrace {
41+
func NewSpanAnnotatingClientTrace(_ *http.Request, s *trace.Span) *httptrace.ClientTrace {
4242
sa := spanAnnotator{sp: s}
4343

4444
return &httptrace.ClientTrace{

plugin/ochttp/trace.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ type traceTransport struct {
4444
startOptions trace.StartOptions
4545
format propagation.HTTPFormat
4646
formatSpanName func(*http.Request) string
47-
newClientTrace func(*http.Request, trace.Span) *httptrace.ClientTrace
47+
newClientTrace func(*http.Request, *trace.Span) *httptrace.ClientTrace
4848
}
4949

5050
// TODO(jbd): Add message events for request and response size.
@@ -104,7 +104,7 @@ func (t *traceTransport) RoundTrip(req *http.Request) (*http.Response, error) {
104104
// the body of the original response.
105105
type bodyTracker struct {
106106
rc io.ReadCloser
107-
span trace.Span
107+
span *trace.Span
108108
}
109109

110110
var _ io.ReadCloser = (*bodyTracker)(nil)

plugin/ochttp/trace_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func TestTransport_RoundTrip(t *testing.T) {
106106
_, parent := trace.StartSpan(context.Background(), "parent")
107107
tests := []struct {
108108
name string
109-
parent trace.Span
109+
parent *trace.Span
110110
}{
111111
{
112112
name: "no parent",

trace/basetypes.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,6 @@ type Attribute struct {
4949
value interface{}
5050
}
5151

52-
// Key returns the attribute's key
53-
func (a *Attribute) Key() string {
54-
return a.key
55-
}
56-
57-
// Value returns the attribute's value
58-
func (a *Attribute) Value() interface{} {
59-
return a.value
60-
}
61-
6252
// BoolAttribute returns a bool-valued attribute.
6353
func BoolAttribute(key string, value bool) Attribute {
6454
return Attribute{key: key, value: value}

trace/examples_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"go.opencensus.io/trace"
2222
)
2323

24-
// This example shows how to use StartSpan and (Span).End to capture
24+
// This example shows how to use StartSpan and (*Span).End to capture
2525
// a function execution in a Span. It assumes that the function
2626
// has a context.Context argument.
2727
func ExampleStartSpan() {

trace/spanstore.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,8 @@ func (i internalOnly) ReportActiveSpans(name string) []*SpanData {
4848
var out []*SpanData
4949
s.mu.Lock()
5050
defer s.mu.Unlock()
51-
for activeSpan := range s.active {
52-
if s, ok := activeSpan.(*span); ok {
53-
out = append(out, s.makeSpanData())
54-
}
51+
for span := range s.active {
52+
out = append(out, span.makeSpanData())
5553
}
5654
return out
5755
}
@@ -187,7 +185,7 @@ func (i internalOnly) ReportSpansByLatency(name string, minLatency, maxLatency t
187185
// bucketed by latency.
188186
type spanStore struct {
189187
mu sync.Mutex // protects everything below.
190-
active map[Span]struct{}
188+
active map[*Span]struct{}
191189
errors map[int32]*bucket
192190
latency []bucket
193191
maxSpansPerErrorBucket int
@@ -196,7 +194,7 @@ type spanStore struct {
196194
// newSpanStore creates a span store.
197195
func newSpanStore(name string, latencyBucketSize int, errorBucketSize int) *spanStore {
198196
s := &spanStore{
199-
active: make(map[Span]struct{}),
197+
active: make(map[*Span]struct{}),
200198
latency: make([]bucket, len(defaultLatencies)+1),
201199
maxSpansPerErrorBucket: errorBucketSize,
202200
}
@@ -273,15 +271,15 @@ func (s *spanStore) resize(latencyBucketSize int, errorBucketSize int) {
273271
}
274272

275273
// add adds a span to the active bucket of the spanStore.
276-
func (s *spanStore) add(span Span) {
274+
func (s *spanStore) add(span *Span) {
277275
s.mu.Lock()
278276
s.active[span] = struct{}{}
279277
s.mu.Unlock()
280278
}
281279

282280
// finished removes a span from the active set, and adds a corresponding
283281
// SpanData to a latency or error bucket.
284-
func (s *spanStore) finished(span Span, sd *SpanData) {
282+
func (s *spanStore) finished(span *Span, sd *SpanData) {
285283
latency := sd.EndTime.Sub(sd.StartTime)
286284
if latency < 0 {
287285
latency = 0

0 commit comments

Comments
 (0)