Skip to content

Commit

Permalink
Remove otel handler per function handler in router (#2664)
Browse files Browse the repository at this point in the history
Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
  • Loading branch information
sanketsudake committed Dec 11, 2022
1 parent 3ae1742 commit 31f4f8c
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions pkg/router/httpTriggers.go
Expand Up @@ -39,7 +39,6 @@ import (
"github.com/fission/fission/pkg/throttler"
"github.com/fission/fission/pkg/utils"
"github.com/fission/fission/pkg/utils/metrics"
"github.com/fission/fission/pkg/utils/otel"
)

// HTTPTriggerSet represents an HTTP trigger set
Expand Down Expand Up @@ -200,12 +199,7 @@ func (ts *HTTPTriggerSet) getRouter(fnTimeoutMap map[types.UID]int) *mux.Router
}
}

var handler http.Handler
if trigger.Spec.Prefix != nil && *trigger.Spec.Prefix != "" {
handler = otel.GetHandlerWithOTEL(http.HandlerFunc(fh.handler), *trigger.Spec.Prefix)
} else {
handler = otel.GetHandlerWithOTEL(http.HandlerFunc(fh.handler), trigger.Spec.RelativeURL)
}
handler := http.HandlerFunc(fh.handler)

if trigger.Spec.Prefix != nil && *trigger.Spec.Prefix != "" {
prefix := *trigger.Spec.Prefix
Expand Down Expand Up @@ -269,11 +263,9 @@ func (ts *HTTPTriggerSet) getRouter(fnTimeoutMap map[types.UID]int) *mux.Router
unTapServiceTimeout: ts.unTapServiceTimeout,
}

var handler http.Handler
internalRoute := utils.UrlForFunction(fn.ObjectMeta.Name, fn.ObjectMeta.Namespace)
internalPrefixRoute := internalRoute + "/"
handler = otel.GetHandlerWithOTEL(http.HandlerFunc(fh.handler), internalRoute)

handler := http.HandlerFunc(fh.handler)
muxRouter.Handle(internalRoute, handler)
muxRouter.PathPrefix(internalPrefixRoute).Handler(handler)
ts.logger.Debug("add internal handler and prefix route for function", zap.String("router", internalRoute), zap.Any("function", fn))
Expand Down

0 comments on commit 31f4f8c

Please sign in to comment.