Get tracer before attempting to inject span to header
@@ -87,6 +87,7 @@ const discovery = require("clever-discovery");
const kayvee = require("kayvee");
const request = require("request");
const opentracing = require("opentracing");
+const globalTracing = require("opentracing/lib/global_tracer");
const {commandFactory} = require("hystrixjs");
const RollingNumberEvent = require("hystrixjs/lib/metrics/RollingNumberEvent");
@@ -406,7 +407,8 @@ var methodTmplStr = `
{{end}}{{end}}
if (span) {
- opentracing.inject(span, opentracing.FORMAT_TEXT_MAP, headers);
+ // Need to get tracer to inject. Use HTTP headers format so we can properly escape special characters
+ globalTracing.globalTracer().inject(span, opentracing.FORMAT_HTTP_HEADERS, headers);
{{- if not .IterMethod}}
span.logEvent("{{.Method}} {{.Path}}");
{{- end}}
