enhancement: Add different samplers and propagators support with OpenTelemetry (#2201)
* Samplers: Check PR/helm values for supported types * Propagators: Check PR/helm values for supported types * Added tracing support via fission CLI * Use parentbased_traceidratio as default sampler with 0.1 ratio Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
@@ -26,6 +26,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
|
||||
"go.opentelemetry.io/otel"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
@@ -35,6 +37,7 @@ import (
|
||||
"github.com/fission/fission/pkg/fission-cli/console"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
otelUtils "github.com/fission/fission/pkg/utils/otel"
|
||||
)
|
||||
|
||||
type TestSubCommand struct {
|
||||
@@ -153,7 +156,19 @@ func (opts *TestSubCommand) do(input cli.Input) error {
|
||||
}
|
||||
|
||||
func doHTTPRequest(ctx context.Context, url string, headers []string, method, body string) (*http.Response, error) {
|
||||
method, err := httptrigger.GetMethod(method)
|
||||
shutdown, err := otelUtils.InitProvider(ctx, nil, "fission-cli")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if shutdown != nil {
|
||||
defer shutdown(ctx)
|
||||
}
|
||||
|
||||
tracer := otel.Tracer("fission-cli")
|
||||
ctx, span := tracer.Start(ctx, "httpRequest")
|
||||
defer span.End()
|
||||
|
||||
method, err = httptrigger.GetMethod(method)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -170,7 +185,8 @@ func doHTTPRequest(ctx context.Context, url string, headers []string, method, bo
|
||||
}
|
||||
req.Header.Set(headerKeyValue[0], headerKeyValue[1])
|
||||
}
|
||||
resp, err := http.DefaultClient.Do(req.WithContext(ctx))
|
||||
hc := &http.Client{Transport: otelhttp.NewTransport(http.DefaultTransport)}
|
||||
resp, err := hc.Do(req.WithContext(ctx))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error executing HTTP request")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user