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

Remove deprecated trace.StartSpanWithXXX convenience methods #540

Conversation

semistrict
Copy link
Contributor

No description provided.


te := &traceExporter{}
trace.RegisterExporter(te)
var (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you revert these changes?

In Go, this style is discouraged. var grouping is mostly discouraged unless the variables need to be strictly grouped together for readability. var is entirely discouraged unless it is for the zero value.

md, _ := metadata.FromIncomingContext(ctx)
name := "Recv" + strings.Replace(rti.FullMethodName, "/", ".", -1)
func (sh *serverTraceHandler) TagRPC(ctx context.Context, rti *stats.RPCTagInfo) context.Context {
var (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@@ -59,7 +59,7 @@ func main() {

// Set up a new server with the OpenCensus
// stats handler to enable stats and tracing.
s := grpc.NewServer(grpc.StatsHandler(ocgrpc.NewServerStatsHandler()))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in the other PR

@semistrict
Copy link
Contributor Author

@rakyll PTAL

Copy link
Contributor

@rakyll rakyll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit.

if s := md[traceContextKey]; len(s) > 0 {
if parent, ok := propagation.FromBinary([]byte(s[0])); ok {
ctx, _ = trace.StartSpanWithRemoteParent(ctx, name, parent, trace.StartOptions{})
return ctx
span = trace.NewSpanWithRemoteParent(name, parent, trace.StartOptions{})
Copy link
Contributor

@rakyll rakyll Mar 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd move ctx = trace.WithSpan(ctx, span) after this line and return.

if s := md[traceContextKey]; len(s) > 0 {
	if parent, ok := propagation.FromBinary([]byte(s[0])); ok {
		span := trace.NewSpanWithRemoteParent(name, parent, trace.StartOptions{})
		return trace.WithSpan(ctx, span)
	}
}

ctx, _ = trace.StartSpan(ctx, name) 
return

@semistrict semistrict merged commit 0ccdb21 into census-instrumentation:master Mar 9, 2018
semistrict pushed a commit to semistrict/opencensus-go that referenced this pull request Mar 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants