From 57a577dfc972cb7af778e0a28fff911cebc8ff06 Mon Sep 17 00:00:00 2001 From: Denis Makogon Date: Wed, 6 Sep 2017 21:55:52 +0300 Subject: [PATCH] Wiring new context with initial span --- api/agent/agent.go | 3 ++- api/agent/call.go | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/api/agent/agent.go b/api/agent/agent.go index 8187da493..2dd1329e1 100644 --- a/api/agent/agent.go +++ b/api/agent/agent.go @@ -223,7 +223,8 @@ func (a *agent) Submit(callI Call) error { a.stats.Complete() // TODO if the context is timed out here we need to allocate new one - call.End(context.Background(), err) + ctx = opentracing.ContextWithSpan(context.Background(), span) + call.End(ctx, err) return err } diff --git a/api/agent/call.go b/api/agent/call.go index e636e3ef9..3d58dc147 100644 --- a/api/agent/call.go +++ b/api/agent/call.go @@ -103,10 +103,10 @@ func FromRequest(appName, path string, req *http.Request) CallOpt { envVars[toEnvName("PARAM", param.Key)] = param.Value } - headerVars := make(map[string]string,len(req.Header)) + headerVars := make(map[string]string, len(req.Header)) for k, v := range req.Header { - headerVars[toEnvName("HEADER",k)] = strings.Join(v, ", ") + headerVars[toEnvName("HEADER", k)] = strings.Join(v, ", ") } // add all the env vars we build to the request headers @@ -115,7 +115,7 @@ func FromRequest(appName, path string, req *http.Request) CallOpt { req.Header.Add(k, v) } - for k,v := range headerVars { + for k, v := range headerVars { envVars[k] = v }