ipc/stream: Correctly associate VIF-dialing and VC handshaking with
the attempt to create a flow.

Prior to this change, the span used by InternalNewDialedVIF
and HandshakeDialedVC was the parent span of the flow creation,
leading to traces like:

Span - <client>tryCreateFlow [id: 2655000b parent 2655000a] (14.671588ms, 2.467000711s)
    @14.684954ms address:/ns.dev.v.io:8101/applicationd
Span - InternalNewDialedVIF [id: 2655000c parent 2655000a] (619.687107ms, 2.173953565s)
    @619.710552ms (tcp, 23.236.61.112:8101)
...
Span - vc.HandshakeDialedVC [id: 26550063 parent 2655000a] (2.174009677s, 2.466984928s)

With this, the VIF/VC creation that is initiated because of a flow
becomes a child span leading to traces like (notice the change in
indentation):

Span - <client>tryCreateFlow [id: 2b01000b parent 2b01000a] (13.130956ms, 2.224585885s)
    @13.141539ms address:/ns.dev.v.io:8101/applicationd
    Span - InternalNewDialedVIF [id: 2b01000c parent 2b01000b] (559.015204ms, 1.867401128s)
        @559.04892ms (tcp, 23.236.61.112:8101)
    ...
    Span - vc.HandshakeDialedVC [id: 2b010063 parent 2b01000b] (1.867443798s, 2.224575586s)
        @1.867450636s @3@@ns.dev.v.io:8101@00000000000000000000000000000000@@@m@@

Change-Id: I4d18b5456a078180145b00490a52de3a0ee54042
diff --git a/runtimes/google/ipc/client.go b/runtimes/google/ipc/client.go
index 9afb81d..cfc6bdc 100644
--- a/runtimes/google/ipc/client.go
+++ b/runtimes/google/ipc/client.go
@@ -172,6 +172,14 @@
 	}
 	sm := c.streamMgr
 	c.vcMapMu.Unlock()
+	// Include the context when Dial-ing. This is currently done via an
+	// option, and for thread-safety reasons - cannot append directly to
+	// vcOpts.
+	// TODO(ashankar,mattr): Revisit the API in ipc/stream and explicitly
+	// provide a context to Dial and other relevant operations.
+	cpy := make([]stream.VCOpt, len(vcOpts)+1)
+	cpy[copy(cpy, vcOpts)] = vc.DialContext{ctx}
+	vcOpts = cpy
 	vc, err := sm.Dial(ep, vcOpts...)
 	c.vcMapMu.Lock()
 	if err != nil {
@@ -431,7 +439,6 @@
 	responses := make([]*serverStatus, attempts)
 	ch := make(chan *serverStatus, attempts)
 	vcOpts := append(getVCOpts(opts), c.vcOpts...)
-	vcOpts = append(vcOpts, vc.DialContext{ctx})
 	for i, server := range resolved.Names() {
 		go c.tryCreateFlow(ctx, i, server, ch, vcOpts)
 	}