Fission meets OpenTelemetry (#2157)
* add opentracing section and otelCollectorEndpoint * initialize OTLP exporter * pkg/controller: changes for context propagation * pkg/executor: changes for context propagation * pkg/fetcher: changes for context propagation * pkg/router: changes for context propagation * pkg/storagesvc: changes for context propagation * set no default value for otel collector endpoint * update readme and add notes to charts * move common code to pkg/utils/otel * adding fn and env as attributes * don't use otelhttp transport for websocket * URL ignore with common filter UrlsToIgnore Note: The web socket example does not work when using OTEL HTTP. Here is an issue related to that on open-telemetry/opentelemetry-js-contrib. Signed-off-by: Gaurav Gahlot <gauravgahlot0107@gmail.com> Co-authored-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
co-authored by
Sanket Sudake
parent
a24934f1a0
commit
0cc3ecc2e9
@@ -29,6 +29,8 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"go.opencensus.io/plugin/ochttp"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/fission/fission/pkg/utils/otel"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -132,7 +134,6 @@ func (ss *StorageService) uploadHandler(w http.ResponseWriter, r *http.Request)
|
||||
zap.String("filename", handler.Filename),
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (ss *StorageService) getIdFromRequest(r *http.Request) (string, error) {
|
||||
@@ -199,7 +200,7 @@ func MakeStorageService(logger *zap.Logger, storageClient *StowClient, port int)
|
||||
}
|
||||
}
|
||||
|
||||
func (ss *StorageService) Start(port int) {
|
||||
func (ss *StorageService) Start(port int, openTracingEnabled bool) {
|
||||
r := mux.NewRouter()
|
||||
r.HandleFunc("/v1/archive", ss.uploadHandler).Methods("POST")
|
||||
r.HandleFunc("/v1/archive", ss.downloadHandler).Methods("GET")
|
||||
@@ -208,15 +209,19 @@ func (ss *StorageService) Start(port int) {
|
||||
|
||||
address := fmt.Sprintf(":%v", port)
|
||||
|
||||
err := http.ListenAndServe(address, &ochttp.Handler{
|
||||
Handler: r,
|
||||
})
|
||||
|
||||
var err error
|
||||
if openTracingEnabled {
|
||||
err = http.ListenAndServe(address, &ochttp.Handler{
|
||||
Handler: r,
|
||||
})
|
||||
} else {
|
||||
err = http.ListenAndServe(address, otel.GetHandlerWithOTEL(r, "fission-storagesvc", otel.UrlsToIgnore("/healthz")))
|
||||
}
|
||||
ss.logger.Fatal("done listening", zap.Error(err))
|
||||
}
|
||||
|
||||
// Start runs storage service
|
||||
func Start(logger *zap.Logger, storage Storage, port int) error {
|
||||
func Start(logger *zap.Logger, storage Storage, port int, openTracingEnabled bool) error {
|
||||
enablePruner := true
|
||||
// create a storage client
|
||||
storageClient, err := MakeStowClient(logger, storage)
|
||||
@@ -226,7 +231,7 @@ func Start(logger *zap.Logger, storage Storage, port int) error {
|
||||
|
||||
// create http handlers
|
||||
storageService := MakeStorageService(logger, storageClient, port)
|
||||
go storageService.Start(port)
|
||||
go storageService.Start(port, openTracingEnabled)
|
||||
|
||||
// enablePruner prevents storagesvc unit test from needing to talk to kubernetes
|
||||
if enablePruner {
|
||||
|
||||
Reference in New Issue
Block a user