Add client tracing to external storage requests (#1626)

This commit is contained in:
Marwan Sulaiman
2020-06-14 11:03:48 -04:00
committed by GitHub
parent c08aa890cb
commit 38a6a6fe0b
2 changed files with 15 additions and 8 deletions
+3 -3
View File
@@ -3,6 +3,7 @@ package actions
import (
"context"
"fmt"
"net/http"
"time"
"github.com/gomods/athens/pkg/config"
@@ -20,7 +21,7 @@ import (
)
// GetStorage returns storage backend based on env configuration
func GetStorage(storageType string, storageConfig *config.StorageConfig, timeout time.Duration) (storage.Backend, error) {
func GetStorage(storageType string, storageConfig *config.StorageConfig, timeout time.Duration, client *http.Client) (storage.Backend, error) {
const op errors.Op = "actions.GetStorage"
switch storageType {
case "memory":
@@ -65,8 +66,7 @@ func GetStorage(storageType string, storageConfig *config.StorageConfig, timeout
if storageConfig.External == nil {
return nil, errors.E(op, "Invalid External Storage Configuration")
}
// TODO(marwan-at-work): add client tracing
return external.NewClient(storageConfig.External.URL, nil), nil
return external.NewClient(storageConfig.External.URL, client), nil
default:
return nil, fmt.Errorf("storage type %s is unknown", storageType)
}