@@ -47,6 +47,9 @@ func init() {
4747 tracers .RegisterLookup (false , lookup )
4848}
4949
50+ // ctorFn is the constructor signature of a native tracer.
51+ type ctorFn = func (* tracers.Context ) tracers.Tracer
52+
5053/*
5154ctors is a map of package-local tracer constructors.
5255
@@ -59,23 +62,23 @@ The go spec (https://golang.org/ref/spec#Package_initialization) says
5962
6063Hence, we cannot make the map in init, but must make it upon first use.
6164*/
62- var ctors map [string ]func () tracers. Tracer
65+ var ctors map [string ]ctorFn
6366
6467// register is used by native tracers to register their presence.
65- func register (name string , ctor func () tracers. Tracer ) {
68+ func register (name string , ctor ctorFn ) {
6669 if ctors == nil {
67- ctors = make (map [string ]func () tracers. Tracer )
70+ ctors = make (map [string ]ctorFn )
6871 }
6972 ctors [name ] = ctor
7073}
7174
7275// lookup returns a tracer, if one can be matched to the given name.
7376func lookup (name string , ctx * tracers.Context ) (tracers.Tracer , error ) {
7477 if ctors == nil {
75- ctors = make (map [string ]func () tracers. Tracer )
78+ ctors = make (map [string ]ctorFn )
7679 }
7780 if ctor , ok := ctors [name ]; ok {
78- return ctor (), nil
81+ return ctor (ctx ), nil
7982 }
8083 return nil , errors .New ("no tracer found" )
8184}
0 commit comments