sourcegraph / go-vcs

manipulate and inspect VCS repositories in Go
https://sourcegraph.com/sourcegraph/go-vcs
Other
79 stars 20 forks source link

vcs/util/tracer: add a utility package for recording VCS operations to Appdash #85

Closed slimsag closed 8 years ago

slimsag commented 8 years ago

This change adds a utility package which records VCS operations to an *appdash.Recorder by wrapping a vcs.Repository value. It implements the optional interface types that a vcs.Repository implementation may opt-in to, so no functionality is lost. Because it works at the interface level we can trace all different backends (gitcmd, git, hg, etc) without writing new tracing code.

In Appdash, all events are prefixed with vcs.Type for easier filtering:

screenshot

slimsag commented 8 years ago

Dang, sorry for wasting your time here @beyang. This approach won't work for implementing the optional interfaces.

It appears that only the last wrapped one is actually implemented, it doesn't carry through in the embedded e.g. fileSystem vcs.Repository field like I naively thought it did.

Confirmed with http://play.golang.org/p/PbFdH6v_Ph -- I'm going to have to think up a different approach to wrapping all these optional interfaces.

EDIT: I see others have run into this problem too

slimsag commented 8 years ago

@beyang I'm not very happy about how it looks, but this implementation will work.

Our only other options would be to pass a context.Context around in all of the backends and duplicate the tracing code across every backend. Either way we're looking at a lot of code dup (here or there), and I think this is the best of two evils.

Let me know what you think.

slimsag commented 8 years ago

kind bump

beyang commented 8 years ago

LGTM, sorry about the delay