Skip to content

Commit 1e9720d

Browse files
fix init httptreemux
1 parent 424d492 commit 1e9720d

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

contrib/dimfeld/httptreemux.v5/httptreemux.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func New(opts ...RouterOption) *Router {
4343
cfg.spanOpts = append(cfg.spanOpts, tracer.Measured())
4444
cfg.spanOpts = append(cfg.spanOpts, tracer.Tag(ext.SpanKind, ext.SpanKindServer))
4545
cfg.spanOpts = append(cfg.spanOpts, tracer.Tag(ext.Component, componentName))
46+
cfg.spanOpts = append(cfg.spanOpts, instrumentation.ServiceNameWithSource(cfg.serviceName, cfg.serviceSource))
4647
instr.Logger().Debug("contrib/dimfeld/httptreemux.v5: Configuring Router: %#v", cfg)
4748
return &Router{httptreemux.New(), cfg}
4849
}
@@ -51,13 +52,12 @@ func New(opts ...RouterOption) *Router {
5152
func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
5253
resource := r.config.resourceNamer(r.TreeMux, w, req)
5354
route, _ := getRoute(r.TreeMux, w, req)
54-
spanOpts := append(r.config.spanOpts, instrumentation.ServiceNameWithSource(r.config.serviceName, r.config.serviceSource))
5555
// pass r.TreeMux to avoid a circular reference panic on calling r.ServeHTTP
5656
httptrace.TraceAndServe(r.TreeMux, w, req, &httptrace.ServeConfig{
5757
Framework: "github.com/dimfeld/httptreemux/v5",
5858
Service: r.config.serviceName,
5959
Resource: resource,
60-
SpanOpts: spanOpts,
60+
SpanOpts: r.config.spanOpts,
6161
Route: route,
6262
})
6363
}
@@ -80,6 +80,7 @@ func NewWithContext(opts ...RouterOption) *ContextRouter {
8080
cfg.spanOpts = append(cfg.spanOpts, tracer.Measured())
8181
cfg.spanOpts = append(cfg.spanOpts, tracer.Tag(ext.SpanKind, ext.SpanKindServer))
8282
cfg.spanOpts = append(cfg.spanOpts, tracer.Tag(ext.Component, componentName))
83+
cfg.spanOpts = append(cfg.spanOpts, instrumentation.ServiceNameWithSource(cfg.serviceName, cfg.serviceSource))
8384
instr.Logger().Debug("contrib/dimfeld/httptreemux.v5: Configuring ContextRouter: %#v", cfg)
8485
return &ContextRouter{httptreemux.NewContextMux(), cfg}
8586
}
@@ -88,13 +89,12 @@ func NewWithContext(opts ...RouterOption) *ContextRouter {
8889
func (r *ContextRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
8990
resource := r.config.resourceNamer(r.TreeMux, w, req)
9091
route, _ := getRoute(r.TreeMux, w, req)
91-
spanOpts := append(r.config.spanOpts, instrumentation.ServiceNameWithSource(r.config.serviceName, r.config.serviceSource))
9292
// pass r.TreeMux to avoid a circular reference panic on calling r.ServeHTTP
9393
httptrace.TraceAndServe(r.TreeMux, w, req, &httptrace.ServeConfig{
9494
Framework: "github.com/dimfeld/httptreemux/v5",
9595
Service: r.config.serviceName,
9696
Resource: resource,
97-
SpanOpts: spanOpts,
97+
SpanOpts: r.config.spanOpts,
9898
Route: route,
9999
})
100100
}

0 commit comments

Comments
 (0)