core: Implement vtrace (part 1 of many)
In this CL I add a basic implementation of vtrace spans and the vtrace
store. Also add enough functionality to collect trace data when
javascript is acting as a client.
There are many shortcomings which will be addressed by future CLs.
- The store always collects, there is no pattern based collection as in go.
- JS servers never return trace information
- There is no interface to dump traces from the console / etc.
MultiPart: 2/4
Change-Id: Ia476f4f8929889f890e43a09fb29958d0dd3daa8
diff --git a/runtimes/google/ipc/server.go b/runtimes/google/ipc/server.go
index 3665d59..fc974f8 100644
--- a/runtimes/google/ipc/server.go
+++ b/runtimes/google/ipc/server.go
@@ -1037,7 +1037,7 @@
// on the server even if they will not be allowed to collect the
// results later. This might be considered a DOS vector.
spanName := fmt.Sprintf("\"%s\".%s", fs.Name(), fs.Method())
- fs.T, _ = ivtrace.SetContinuedSpan(fs.T, spanName, req.TraceRequest)
+ fs.T, _ = vtrace.SetContinuedTrace(fs.T, spanName, req.TraceRequest)
var cancel context.CancelFunc
if req.Timeout != ipc.NoTimeout {
diff --git a/runtimes/google/vtrace/vtrace.go b/runtimes/google/vtrace/vtrace.go
index 528d717..7ca647c 100644
--- a/runtimes/google/vtrace/vtrace.go
+++ b/runtimes/google/vtrace/vtrace.go
@@ -82,18 +82,6 @@
return vtrace.Response{}
}
-// ContinuedSpan creates a span that represents a continuation of a trace from
-// a remote server. name is a user readable string that describes the context
-// and req contains the parameters needed to connect this span with it's trace.
-func SetContinuedSpan(ctx *context.T, name string, req vtrace.Request) (*context.T, vtrace.Span) {
- st := getStore(ctx)
- if req.Method == vtrace.InMemory {
- st.ForceCollect(req.TraceID)
- }
- newSpan := newSpan(req.SpanID, name, req.TraceID, st)
- return context.WithValue(ctx, spanKey, newSpan), newSpan
-}
-
type contextKey int
const (
@@ -119,6 +107,19 @@
return context.WithValue(ctx, spanKey, s), s
}
+// SetContinuedTrace creates a span that represents a continuation of
+// a trace from a remote server. name is the name of the new span and
+// req contains the parameters needed to connect this span with it's
+// trace.
+func (m manager) SetContinuedTrace(ctx *context.T, name string, req vtrace.Request) (*context.T, vtrace.Span) {
+ st := getStore(ctx)
+ if req.Method == vtrace.InMemory {
+ st.ForceCollect(req.TraceID)
+ }
+ newSpan := newSpan(req.SpanID, name, req.TraceID, st)
+ return context.WithValue(ctx, spanKey, newSpan), newSpan
+}
+
// SetNewSpan derives a context with a new Span that can be used to
// trace and annotate operations across process boundaries.
func (m manager) SetNewSpan(ctx *context.T, name string) (*context.T, vtrace.Span) {