Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How is one supposed to initialize spanFactory? #248

Closed
fatih opened this issue Dec 16, 2014 · 4 comments · Fixed by #251
Closed

How is one supposed to initialize spanFactory? #248

fatih opened this issue Dec 16, 2014 · 4 comments · Fixed by #251

Comments

@fatih
Copy link
Member

fatih commented Dec 16, 2014

Sorry if I miss something but I couldn't find anything so I need to ask it here :) The comment for spanFactory says (https://github.com/youtube/vitess/blob/master/go/trace/trace.go#L60):

// spanFactory should be changed by a plugin during init() to a factory that
// creates an actual Span implementation for that plugin's tracing framework.

As I playing with the rpcplus package, the methods of rpcplus.Client is calling the following lines (Go method):

span := trace.NewSpanFromContext(ctx)
span.StartClient(serviceMethod)
defer span.Finish()

I dig into it and saw that it uses a no-op implementation (fakeSpan). I can't change the Span interface. The spanFactory variable is not exported I don't have any access to it. I've searched for the whole git repo and couldn't find any other implementation too.

Is that used? If yes how should we use it? If not can we export it so I have access to it, otherwise it's seems pretty useless for third-party package users.

@fatih fatih changed the title How is one supposed to initialize spanFactory How is one supposed to initialize spanFactory? Dec 16, 2014
@enisoc
Copy link
Member

enisoc commented Dec 16, 2014

The trace library we use ourselves is an internal tool, so that's why the default implementation is a no-op. I agree that it would be more useful if you could register plugins from outside the package. I'll work on that. Thanks for the suggestion!

@fatih
Copy link
Member Author

fatih commented Dec 17, 2014

@enisoc Thanks a lot! :) Is there any public implementation of this trace factory? I'll try to implement one but having a look at other implementations would make it better, at least I would know what I should take care of.

@enisoc
Copy link
Member

enisoc commented Dec 17, 2014

I don't think there's a public version of the particular trace library we use, but it should be possible to find one that can be plugged in. The main things you'd need are:

  1. A plugin for this trace package, to wrap the trace creation/annotation methods provided by the trace library you use into the expected interface.
  2. A plugin for golang.org/x/net/context to put/get trace spans in contexts, so spans can be passed around by only passing context (which we already do).
  3. If you want to associate traces across RPCs instead of just within a given process, you'd also need a patch to bsonrpc to serialize the trace ID into the request.

@yaoshengzhe
Copy link
Contributor

I would suggest Twitter's zipkin (http://twitter.github.io/zipkin/). I've seen folks outside Twitter use it and the project itself seems mature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants