Skip to content

Commit

Permalink
fixes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
hexdigest committed Apr 9, 2019
1 parent f3b7072 commit ecf1f59
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,24 @@ const template = `
type {{$structName}} struct {
next {{$interfaceName}}
prefix string
tracer opentracing.Tracer
}
// New{{$structName}} creates a {{$structName}}
func New{{$structName}}(next {{$interfaceName}}, prefix string) *{{$structName}} {
return &{{$structName}} {
next: next,
prefix: prefix,
tracer: opentracing.GlobalTracer(),
}
}
// New{{$structName}} creates a {{$structName}}
func New{{$structName}}WithTracer(next {{$interfaceName}}, prefix string, tracer opentracing.Tracer) *{{$structName}} {
return &{{$structName}} {
next: next,
prefix: prefix,
tracer: tracer,
}
}
Expand Down Expand Up @@ -83,7 +94,7 @@ func startSpan(gen *generator.Generator) interface{} {
return "", errors.Wrap(err, "failed to parse func params")
}
ctxName := params[0].Name
return "span, " + ctxName + " := opentracing.StartSpanFromContext(" + ctxName + ", t.prefix + \"" + anchor + "\")", nil
return "span, " + ctxName + " := opentracing.StartSpanFromContextWithTracer(" + ctxName + ", t.tracer, t.prefix + \"" + anchor + "\")", nil
}
}

Expand Down

0 comments on commit ecf1f59

Please sign in to comment.