Repository: fission/fission
Pull request #2201 (2021-09-21 12:47:41)

enhancement: Add different samplers and propagators support with OpenTelemetry
* Samplers
  - always_on - Sampler that always samples spans, regardless of the parent span's sampling decision.
  - always_off - Sampler that never samples spans, regardless of the parent span's sampling decision.
  - traceidratio - Sampler that samples probabalistically based on rate.
  - parentbased_always_on - (default) Sampler that respects its parent span's sampling decision, but otherwise always samples.
  - parentbased_always_off - Sampler that respects its parent span's sampling decision, but otherwise never samples.
  - parentbased_traceidratio - Sampler that respects its parent span's sampling decision, but otherwise samples probabalistically based on rate.

* Propogators
  - tracecontext - W3C Trace Context
  - baggage - W3C Baggage
  - b3 - B3 Single
  - b3multi - B3 Multi
  - jaeger - Jaeger uber-trace-id header
  - xray - AWS X-Ray (third party)
  - ottrace - OpenTracing Trace (third party)

* Added tracing support via fission CLI

With support for jaeger propagator, ie, support for uber-trace-id header we can remove opentracing. 
https://github.com/fission/fission/pull/2196


sanketsudake: Once https://github.com/open-telemetry/opentelemetry-go/issues/1698 is resolved we can get rid of code from Fission and use features sdk itself.

Patch:
diff --git a/charts/fission-all/templates/_helpers.tpl b/charts/fission-all/templates/_helpers.tpl
index fbb8c13a..ffb3c892 100644
--- a/charts/fission-all/templates/_helpers.tpl
+++ b/charts/fission-all/templates/_helpers.tpl
@@ -61,6 +61,12 @@ This template generates the image name for the deployment depending on the value
 - name: OTEL_EXPORTER_OTLP_HEADERS
   value: "{{ .Values.openTelemetry.otlpHeaders }}"
 {{- end }}
+- name: OTEL_TRACES_SAMPLER
+  value: "{{ .Values.openTelemetry.tracesSampler }}"
+- name: OTEL_TRACES_SAMPLER_ARG
+  value: "{{ .Values.openTelemetry.tracesSamplingRate }}"
+- name: OTEL_PROPAGATORS
+  value: "{{ .Values.openTelemetry.propagators }}"
 {{- end }}
 
 {{- define "opentracing.envs" }}
diff --git a/charts/fission-all/values.yaml b/charts/fission-all/values.yaml
index 6ebbed9a..02ba87e1 100644
--- a/charts/fission-all/values.yaml
+++ b/charts/fission-all/values.yaml
@@ -340,7 +340,7 @@ canaryDeployment:
   enabled: true
 
 # Use the following flags to enable OpenTracing.
-# Note: OpenTracing support will be deprecated in an upcoming release.
+# Note: OpenTracing support will be removed in an upcoming release.
 # Please prefer using OpenTelemetry instead.
 openTracing:
   ## set this flag to true if you wish to enable OpenTracing
@@ -364,6 +364,29 @@ openTelemetry:
   # to the collector.
   # Eg. otlpHeaders: "key1=value1,key2=value2"
   otlpHeaders: ""
+  # Supported samplers:
+  # always_on - Sampler that always samples spans, regardless of the parent span's sampling decision.
+  # always_off - Sampler that never samples spans, regardless of the parent span's sampling decision.
+  # traceidratio - Sampler that samples probabalistically based on rate.
+  # parentbased_always_on - (default if empty) Sampler that respects its parent span's sampling decision, but otherwise always samples.
+  # parentbased_always_off - Sampler that respects its parent span's sampling decision, but otherwise never samples.
+  # parentbased_traceidratio - Sampler that respects its parent span's sampling decision, but otherwise samples probabalistically based on rate.
+  tracesSampler: "parentbased_traceidratio"
+  # Each Sampler type defines its own expected input, if any.
+  # Currently we get trace ratio for the case of,
+  # 1. traceidratio
+  # 2. parentbased_traceidratio
+  # Sampling probability, a number in the [0..1] range, e.g. "0.1". Default is 0.1.
+  tracesSamplingRate: "0.1"
+  # Supported providers:
+  # tracecontext - W3C Trace Context
+  # baggage - W3C Baggage
+  # b3 - B3 Single
+  # b3multi - B3 Multi
+  # jaeger - Jaeger uber-trace-id header
+  # xray - AWS X-Ray (third party)
+  # ottrace - OpenTracing Trace (third party)
+  propagators: "tracecontext,baggage"
 
 ## Message Queue Trigger Kind, KEDA: enable and configuration
 mqt_keda:
diff --git a/charts/fission-core/templates/_helpers.tpl b/charts/fission-core/templates/_helpers.tpl
index b4674d06..025bcbc2 100644
--- a/charts/fission-core/templates/_helpers.tpl
+++ b/charts/fission-core/templates/_helpers.tpl
@@ -52,6 +52,12 @@ This template generates the image name for the deployment depending on the value
 - name: OTEL_EXPORTER_OTLP_HEADERS
   value: "{{ .Values.openTelemetry.otlpHeaders }}"
 {{- end }}
+- name: OTEL_TRACES_SAMPLER
+  value: "{{ .Values.openTelemetry.tracesSampler }}"
+- name: OTEL_TRACES_SAMPLER_ARG
+  value: "{{ .Values.openTelemetry.tracesSamplingRate }}"
+- name: OTEL_PROPAGATORS
+  value: "{{ .Values.openTelemetry.propagators }}"
 {{- end }}
 
 {{- define "opentracing.envs" }}
diff --git a/charts/fission-core/values.yaml b/charts/fission-core/values.yaml
index e9263221..031c6674 100644
--- a/charts/fission-core/values.yaml
+++ b/charts/fission-core/values.yaml
@@ -230,7 +230,7 @@ canaryDeployment:
   enabled: false
 
 # Use the following flags to enable OpenTracing.
-# Note: OpenTracing support will be deprecated in an upcoming release.
+# Note: OpenTracing support will be removed in an upcoming release.
 # Please prefer using OpenTelemetry instead.
 openTracing:
   ## set this flag to true if you wish to enable OpenTracing
@@ -254,6 +254,29 @@ openTelemetry:
   # to the collector.
   # Eg. otlpHeaders: "key1=value1,key2=value2"
   otlpHeaders: ""
+  # Supported samplers:
+  # always_on - Sampler that always samples spans, regardless of the parent span's sampling decision.
+  # always_off - Sampler that never samples spans, regardless of the parent span's sampling decision.
+  # traceidratio - Sampler that samples probabalistically based on rate.
+  # parentbased_always_on - (default if empty) Sampler that respects its parent span's sampling decision, but otherwise always samples.
+  # parentbased_always_off - Sampler that respects its parent span's sampling decision, but otherwise never samples.
+  # parentbased_traceidratio - Sampler that respects its parent span's sampling decision, but otherwise samples probabalistically based on rate.
+  tracesSampler: "parentbased_traceidratio"
+  # Each Sampler type defines its own expected input, if any.
+  # Currently we get trace ratio for the case of,
+  # 1. traceidratio
+  # 2. parentbased_traceidratio
+  # Sampling probability, a number in the [0..1] range, e.g. "0.1". Default is 0.1.
+  tracesSamplingRate: "0.1"
+  # Supported providers:
+  # tracecontext - W3C Trace Context
+  # baggage - W3C Baggage
+  # b3 - B3 Single
+  # b3multi - B3 Multi
+  # jaeger - Jaeger uber-trace-id header
+  # xray - AWS X-Ray (third party)
+  # ottrace - OpenTracing Trace (third party)
+  propagators: "tracecontext,baggage"
 
 ## Message Queue Trigger Kind, KEDA: enable and configuration
 mqt_keda:
diff --git a/go.mod b/go.mod
index 8ac9d2b9..a2d018e5 100644
--- a/go.mod
+++ b/go.mod
@@ -54,15 +54,19 @@ require (
 	github.com/ulikunitz/xz v0.5.9 // indirect
 	github.com/wcharczuk/go-chart v2.0.1+incompatible
 	go.opencensus.io v0.23.0
-	go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.22.0
-	go.opentelemetry.io/otel v1.0.0-RC2
-	go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.0.0-RC2
-	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.0-RC2
-	go.opentelemetry.io/otel/sdk v1.0.0-RC2
-	go.opentelemetry.io/otel/trace v1.0.0-RC2
-	go.uber.org/zap v1.18.1
+	go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.23.0
+	go.opentelemetry.io/contrib/propagators/aws v0.23.0
+	go.opentelemetry.io/contrib/propagators/b3 v0.23.0
+	go.opentelemetry.io/contrib/propagators/jaeger v0.23.0
+	go.opentelemetry.io/contrib/propagators/ot v0.23.0
+	go.opentelemetry.io/otel v1.0.0
+	go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.0.0
+	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.0
+	go.opentelemetry.io/otel/sdk v1.0.0
+	go.opentelemetry.io/otel/trace v1.0.0
+	go.uber.org/zap v1.19.1
 	golang.org/x/net v0.0.0-20210614182718-04defd469f4e
-	google.golang.org/grpc v1.39.0
+	google.golang.org/grpc v1.40.0
 	gotest.tools v2.2.0+incompatible // indirect
 	k8s.io/api v0.21.4
 	k8s.io/apiextensions-apiserver v0.21.4
@@ -70,5 +74,5 @@ require (
 	k8s.io/client-go v0.21.4
 	k8s.io/klog v1.0.0
 	k8s.io/metrics v0.21.4
-	sigs.k8s.io/controller-runtime v0.9.6
+	sigs.k8s.io/controller-runtime v0.9.7
 )
diff --git a/go.sum b/go.sum
index 07008dc9..a86674d2 100644
--- a/go.sum
+++ b/go.sum
@@ -645,8 +645,8 @@ github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGV
 github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
 github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
 github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
-github.com/onsi/gomega v1.14.0 h1:ep6kpPVwmr/nTbklSx2nrLNSIO62DoYAhnPNIMhK8gI=
-github.com/onsi/gomega v1.14.0/go.mod h1:cIuvLEne0aoVhAgh/O6ac0Op8WWw9H6eYCriF+tEHG0=
+github.com/onsi/gomega v1.15.0 h1:WjP/FQ/sk43MRmnEcT+MlDw2TFvkrXlprrPST/IudjU=
+github.com/onsi/gomega v1.15.0/go.mod h1:cIuvLEne0aoVhAgh/O6ac0Op8WWw9H6eYCriF+tEHG0=
 github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
 github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
 github.com/opencontainers/image-spec v1.0.1 h1:JMemWkRwHx4Zj+fVxWoMCFm/8sYGGrUVojFA6h/TRcI=
@@ -816,29 +816,35 @@ go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
 go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
 go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M=
 go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
-go.opentelemetry.io/contrib v0.22.0 h1:0F7gDEjgb1WGn4ODIjaCAg75hmqF+UN0LiVgwxsCodc=
-go.opentelemetry.io/contrib v0.22.0/go.mod h1:EH4yDYeNoaTqn/8yCWQmfNB78VHfGX2Jt2bvnvzBlGM=
-go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.22.0 h1:WHjZguqT+3UjTgFum33hWZYybDVnx8u9q5/kQDfaGTs=
-go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.22.0/go.mod h1:o3MuU25bYroYnc2TOKe8mTk8f9X1oPFO6C5RCoPKtSU=
-go.opentelemetry.io/otel v1.0.0-RC1/go.mod h1:x9tRa9HK4hSSq7jf2TKbqFbtt58/TGk0f9XiEYISI1I=
-go.opentelemetry.io/otel v1.0.0-RC2 h1:SHhxSjB+omnGZPgGlKe+QMp3MyazcOHdQ8qwo89oKbg=
-go.opentelemetry.io/otel v1.0.0-RC2/go.mod h1:w1thVQ7qbAy8MHb0IFj8a5Q2QU0l2ksf8u/CN8m3NOM=
-go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.0.0-RC2 h1:Z/91DSYkOqnVuECrd+hxCU9lzeo5Fihjp28uq0Izfpw=
-go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.0.0-RC2/go.mod h1:T+s8GKi1OqMwPuZ+ouDtZW4vWYpJuzIzh2Matq4Jo9k=
-go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.0-RC2 h1:PaSlrCE+hRbamroLGGgFDmzDamCxp7ID+hBvPmOhcSc=
-go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.0-RC2/go.mod h1:3shayJIFcDqHi9/GT2fAHyMI/bRgc6FO0CAkhaDkhi0=
-go.opentelemetry.io/otel/internal/metric v0.22.0 h1:Q9bS02XRykSRIbggaU4hVF9oWOP9PyILu26zJWoKmk0=
-go.opentelemetry.io/otel/internal/metric v0.22.0/go.mod h1:7qVuMihW/ktMonEfOvBXuh6tfMvvEyoIDgeJNRloYbQ=
-go.opentelemetry.io/otel/metric v0.22.0 h1:/qv10BzznqEifrXBwsTT370OCN1PRgt+mnjzMwxJKrQ=
-go.opentelemetry.io/otel/metric v0.22.0/go.mod h1:KcsUkBiYGW003DJ+ugd2aqIRIfjabD9jeOUXqsAtrq0=
-go.opentelemetry.io/otel/oteltest v1.0.0-RC1/go.mod h1:+eoIG0gdEOaPNftuy1YScLr1Gb4mL/9lpDkZ0JjMRq4=
-go.opentelemetry.io/otel/oteltest v1.0.0-RC2 h1:xNKqMhlZYkASSyvF4JwObZFMq0jhFN3c3SP+2rCzVPk=
-go.opentelemetry.io/otel/oteltest v1.0.0-RC2/go.mod h1:kiQ4tw5tAL4JLTbcOYwK1CWI1HkT5aiLzHovgOVnz/A=
-go.opentelemetry.io/otel/sdk v1.0.0-RC2 h1:ROuteeSCBaZNjiT9JcFzZepmInDvLktR28Y6qKo8bCs=
-go.opentelemetry.io/otel/sdk v1.0.0-RC2/go.mod h1:fgwHyiDn4e5k40TD9VX243rOxXR+jzsWBZYA2P5jpEw=
-go.opentelemetry.io/otel/trace v1.0.0-RC1/go.mod h1:86UHmyHWFEtWjfWPSbu0+d0Pf9Q6e1U+3ViBOc+NXAg=
-go.opentelemetry.io/otel/trace v1.0.0-RC2 h1:dunAP0qDULMIT82atj34m5RgvsIK6LcsXf1c/MsYg1w=
-go.opentelemetry.io/otel/trace v1.0.0-RC2/go.mod h1:JPQ+z6nNw9mqEGT8o3eoPTdnNI+Aj5JcxEsVGREIAy4=
+go.opentelemetry.io/contrib v0.23.0 h1:MgRuo0JZZX8J9WLRjyd7OpTSbaLOdQXXJa6SnZvlWLM=
+go.opentelemetry.io/contrib v0.23.0/go.mod h1:EH4yDYeNoaTqn/8yCWQmfNB78VHfGX2Jt2bvnvzBlGM=
+go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.23.0 h1:hNSH6f4WUMDnRAvUCLItD0WKzQqAPoECvORj+ZChbnA=
+go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.23.0/go.mod h1:wLrbAf2Qb+kFsEjowrxOcuy2SE0dcY0VwFiiYCmUeFQ=
+go.opentelemetry.io/contrib/propagators/aws v0.23.0 h1:BTveX+0ASfhMsCb1ro1lQGuL/56hmxjptZ1rzVxu6OM=
+go.opentelemetry.io/contrib/propagators/aws v0.23.0/go.mod h1:FNKmH5WbGb5qmUSUrzQjaXoc+gdXiVK8ZlGM7Qpx3Ys=
+go.opentelemetry.io/contrib/propagators/b3 v0.23.0 h1:sxitmDBHZS3Z2lw81kDntCRFt4dQglu9EOhBPNHN9CY=
+go.opentelemetry.io/contrib/propagators/b3 v0.23.0/go.mod h1:tAJUf0uW1xrgQ1QgOZqLXFbn3DNFO4tTmh0Nqe3kSzw=
+go.opentelemetry.io/contrib/propagators/jaeger v0.23.0 h1:sVMsCeDMgJiz8NW0NilH2NhydiU+r+pYUMHkWf0zi/k=
+go.opentelemetry.io/contrib/propagators/jaeger v0.23.0/go.mod h1:wssWZnQoNdAtCwObUENjAnsJg873IS67mdVdmj0tYbs=
+go.opentelemetry.io/contrib/propagators/ot v0.23.0 h1:QD69MmaJwLOaLj8uNmxpJa52v/jSsX4ZU/BV8acpb68=
+go.opentelemetry.io/contrib/propagators/ot v0.23.0/go.mod h1:uhAU1z0UtdOTHWPfmpAOlikY/vK79cGwrteYDkcxvGU=
+go.opentelemetry.io/otel v1.0.0-RC3/go.mod h1:Ka5j3ua8tZs4Rkq4Ex3hwgBgOchyPVq5S6P2lz//nKQ=
+go.opentelemetry.io/otel v1.0.0 h1:qTTn6x71GVBvoafHK/yaRUmFzI4LcONZD0/kXxl5PHI=
+go.opentelemetry.io/otel v1.0.0/go.mod h1:AjRVh9A5/5DE7S+mZtTR6t8vpKKryam+0lREnfmS4cg=
+go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.0.0 h1:Vv4wbLEjheCTPV07jEav7fyUpJkyftQK7Ss2G7qgdSo=
+go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.0.0/go.mod h1:3VqVbIbjAycfL1C7sIu/Uh/kACIUPWHztt8ODYwR3oM=
+go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.0 h1:B9VtEB1u41Ohnl8U6rMCh1jjedu8HwFh4D0QeB+1N+0=
+go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.0/go.mod h1:zhEt6O5GGJ3NCAICr4hlCPoDb2GQuh4Obb4gZBgkoQQ=
+go.opentelemetry.io/otel/internal/metric v0.23.0 h1:mPfzm9Iqhw7G2nDBmUAjFTfPqLZPbOW2k7QI57ITbaI=
+go.opentelemetry.io/otel/internal/metric v0.23.0/go.mod h1:z+RPiDJe30YnCrOhFGivwBS+DU1JU/PiLKkk4re2DNY=
+go.opentelemetry.io/otel/metric v0.23.0 h1:mYCcDxi60P4T27/0jchIDFa1WHEfQeU3zH9UEMpnj2c=
+go.opentelemetry.io/otel/metric v0.23.0/go.mod h1:G/Nn9InyNnIv7J6YVkQfpc0JCfKBNJaERBGw08nqmVQ=
+go.opentelemetry.io/otel/sdk v1.0.0-RC3/go.mod h1:78H6hyg2fka0NYT9fqGuFLvly2yCxiBXDJAgLKo/2Us=
+go.opentelemetry.io/otel/sdk v1.0.0 h1:BNPMYUONPNbLneMttKSjQhOTlFLOD9U22HNG1KrIN2Y=
+go.opentelemetry.io/otel/sdk v1.0.0/go.mod h1:PCrDHlSy5x1kjezSdL37PhbFUMjrsLRshJ2zCzeXwbM=
+go.opentelemetry.io/otel/trace v1.0.0-RC3/go.mod h1:VUt2TUYd8S2/ZRX09ZDFZQwn2RqfMB5MzO17jBojGxo=
+go.opentelemetry.io/otel/trace v1.0.0 h1:TSBr8GTEtKevYMG/2d21M989r5WJYVimhTHBKVEZuh4=
+go.opentelemetry.io/otel/trace v1.0.0/go.mod h1:PXTWqayeFUlJV1YDNhsJYB184+IvAH814St6o6ajzIs=
 go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
 go.opentelemetry.io/proto/otlp v0.9.0 h1:C0g6TWmQYvjKRnljRULLWUVJGy8Uvu0NEL/5frY2/t4=
 go.opentelemetry.io/proto/otlp v0.9.0/go.mod h1:1vKfU9rv61e9EVGthD1zNvUbiwPcimSsOPU9brfSHJg=
@@ -847,8 +853,9 @@ go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
 go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
 go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
 go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
-go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0=
 go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
+go.uber.org/goleak v1.1.11-0.20210813005559-691160354723 h1:sHOAIxRGBp443oHZIPB+HsUGaksVCXVQENPxwTfQdH4=
+go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
 go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
 go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
 go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4=
@@ -857,8 +864,9 @@ go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9E
 go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
 go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
 go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo=
-go.uber.org/zap v1.18.1 h1:CSUJ2mjFszzEWt4CdKISEuChVIXGBn3lAPwkRGyVrc4=
-go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
+go.uber.org/zap v1.19.0/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
+go.uber.org/zap v1.19.1 h1:ue41HOKd1vGURxrmeKIgELGb3jPW9DMUDGtsinblHwI=
+go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI=
 golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
 golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
 golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
@@ -906,7 +914,6 @@ golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRu
 golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
 golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
 golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
-golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug=
 golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
 golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
 golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
@@ -1070,8 +1077,8 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc
 golang.org/x/sys v0.0.0-20210525143221-35b2ab0089ea/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
-golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20210817190340-bfb29a6856f2 h1:c8PlLMqBbOHoqtjteWm5/kbe6rNY2pbRfbIMVnepueo=
+golang.org/x/sys v0.0.0-20210817190340-bfb29a6856f2/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
 golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
 golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d h1:SZxvLBoTP5yHO3Frd4z4vrF+DBX9vMVanchswa69toE=
@@ -1155,8 +1162,8 @@ golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4f
 golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
 golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
 golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
-golang.org/x/tools v0.1.2 h1:kRBLX7v7Af8W7Gdbbc908OJcdgtK8bOz9Uaj8/F1ACA=
 golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
+golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
 golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@@ -1261,8 +1268,8 @@ google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAG
 google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
 google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
 google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
-google.golang.org/grpc v1.39.0 h1:Klz8I9kdtkIN6EpHHUOMLCYhTn/2WAe5a0s1hcBkdTI=
-google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE=
+google.golang.org/grpc v1.40.0 h1:AGJ0Ih4mHjSeibYkFGh1dD9KJ/eOtZ93I6hoHhukQ5Q=
+google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
 google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
 google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
 google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
@@ -1327,23 +1334,16 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
 honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
 honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
 honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
-k8s.io/api v0.21.3/go.mod h1:hUgeYHUbBp23Ue4qdX9tR8/ANi/g3ehylAqDn9NWVOg=
 k8s.io/api v0.21.4 h1:WtDkzTAuI31WZKDPeIYpEUA+WeUfXAmA7gwj6nzFfbc=
 k8s.io/api v0.21.4/go.mod h1:fTVGP+M4D8+00FN2cMnJqk/eb/GH53bvmNs2SVTmpFk=
-k8s.io/apiextensions-apiserver v0.21.3/go.mod h1:kl6dap3Gd45+21Jnh6utCx8Z2xxLm8LGDkprcd+KbsE=
 k8s.io/apiextensions-apiserver v0.21.4 h1:HkajN/vmT/9HnFmUxvpXfSGkTCvH/ax4e3+j6mqWUDU=
 k8s.io/apiextensions-apiserver v0.21.4/go.mod h1:OoC8LhI9LnV+wKjZkXIBbLUwtnOGJiTRE33qctH5CIk=
-k8s.io/apimachinery v0.21.3/go.mod h1:H/IM+5vH9kZRNJ4l3x/fXP/5bOPJaVP/guptnZPeCFI=
 k8s.io/apimachinery v0.21.4 h1:KDq0lWZVslHkuE5I7iGAQHwpK0aDTlar1E7IWEc4CNw=
 k8s.io/apimachinery v0.21.4/go.mod h1:H/IM+5vH9kZRNJ4l3x/fXP/5bOPJaVP/guptnZPeCFI=
-k8s.io/apiserver v0.21.3/go.mod h1:eDPWlZG6/cCCMj/JBcEpDoK+I+6i3r9GsChYBHSbAzU=
 k8s.io/apiserver v0.21.4/go.mod h1:SErUuFBBPZUcD2nsUU8hItxoYheqyYr2o/pCINEPW8g=
-k8s.io/client-go v0.21.3/go.mod h1:+VPhCgTsaFmGILxR/7E1N0S+ryO010QBeNCv5JwRGYU=
 k8s.io/client-go v0.21.4 h1:tcwj167If+v+pIGrCjaPG7hFo6SqFPFCCgMJy+Vm8Jc=
 k8s.io/client-go v0.21.4/go.mod h1:t0/eMKyUAq/DoQ7vW8NVVA00/nomlwC+eInsS8PxSew=
-k8s.io/code-generator v0.21.3/go.mod h1:K3y0Bv9Cz2cOW2vXUrNZlFbflhuPvuadW6JdnN6gGKo=
 k8s.io/code-generator v0.21.4/go.mod h1:K3y0Bv9Cz2cOW2vXUrNZlFbflhuPvuadW6JdnN6gGKo=
-k8s.io/component-base v0.21.3/go.mod h1:kkuhtfEHeZM6LkX0saqSK8PbdO7A0HigUngmhhrwfGQ=
 k8s.io/component-base v0.21.4/go.mod h1:ZKG0eHVX+tUDcaoIGpU3Vtk4TIjMddN9uhEWDmW6Nyg=
 k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
 k8s.io/gengo v0.0.0-20201214224949-b6c5ce23f027/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
@@ -1358,15 +1358,14 @@ k8s.io/kube-openapi v0.0.0-20210305001622-591a79e4bda7/go.mod h1:wXW5VT87nVfh/iL
 k8s.io/metrics v0.21.4 h1:4QzwCM7O87PHHnPF+NF7A9I4M+UPstUwkQ66EArhrjU=
 k8s.io/metrics v0.21.4/go.mod h1:uhWoVuVumUMSeCa1B1p2tm4Y4XuZIg0n24QEtB54wuA=
 k8s.io/utils v0.0.0-20201110183641-67b214c5f920/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
-k8s.io/utils v0.0.0-20210722164352-7f3ee0f31471 h1:DnzUXII7sVg1FJ/4JX6YDRJfLNAC7idRatPwe07suiI=
-k8s.io/utils v0.0.0-20210722164352-7f3ee0f31471/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
+k8s.io/utils v0.0.0-20210802155522-efc7438f0176 h1:Mx0aa+SUAcNRQbs5jUzV8lkDlGFU8laZsY9jrcVX5SY=
+k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
 rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
 rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
 rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
-sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.19/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg=
 sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.22/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg=
-sigs.k8s.io/controller-runtime v0.9.6 h1:EevVMlgUj4fC1NVM4+DB3iPkWkmGRNarA66neqv9Qew=
-sigs.k8s.io/controller-runtime v0.9.6/go.mod h1:q6PpkM5vqQubEKUKOM6qr06oXGzOBcCby1DA9FbyZeA=
+sigs.k8s.io/controller-runtime v0.9.7 h1:DlHMlAyLpgEITVvNsuZqMbf8/sJl9HirmCZIeR5H9mQ=
+sigs.k8s.io/controller-runtime v0.9.7/go.mod h1:nExcHcQ2zvLMeoO9K7rOesGCmgu32srN5SENvpAEbGA=
 sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw=
 sigs.k8s.io/structured-merge-diff/v4 v4.1.2 h1:Hr/htKFmJEbtMgS/UD0N+gtgctAqz81t3nu+sPzynno=
 sigs.k8s.io/structured-merge-diff/v4 v4.1.2/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4=
diff --git a/pkg/utils/otel/provider.go b/pkg/utils/otel/provider.go
index 5867366f..9b7adcf7 100644
--- a/pkg/utils/otel/provider.go
+++ b/pkg/utils/otel/provider.go
@@ -2,10 +2,15 @@ package otel
 
 import (
 	"context"
+	"fmt"
 	"os"
 	"strconv"
 	"strings"
 
+	"go.opentelemetry.io/contrib/propagators/aws/xray"
+	"go.opentelemetry.io/contrib/propagators/b3"
+	"go.opentelemetry.io/contrib/propagators/jaeger"
+	"go.opentelemetry.io/contrib/propagators/ot"
 	"go.opentelemetry.io/otel"
 	"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
 	"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
@@ -20,9 +25,12 @@ import (
 )
 
 const (
-	OtelEnvPrefix      = "OTEL_"
-	OtelEndpointEnvVar = "OTEL_EXPORTER_OTLP_ENDPOINT"
-	OtelInsecureEnvVar = "OTEL_EXPORTER_OTLP_INSECURE"
+	OtelEnvPrefix        = "OTEL_"
+	OtelEndpointEnvVar   = "OTEL_EXPORTER_OTLP_ENDPOINT"
+	OtelInsecureEnvVar   = "OTEL_EXPORTER_OTLP_INSECURE"
+	OtelTracesSampler    = "OTEL_TRACES_SAMPLER"
+	OtelTracesSamplerArg = "OTEL_TRACES_SAMPLER_ARG"
+	OtelPropogaters      = "OTEL_PROPOGATORS"
 )
 
 type OtelConfig struct {
@@ -30,12 +38,118 @@ type OtelConfig struct {
 	insecure bool
 }
 
+/*
+Each Sampler type defines its own expected input, if any.
+Currently we get trace ratio for the case of,
+1. traceidratio
+2. parentbased_traceidratio
+*/
+func getSamplerArg() (float64, error) {
+	arg := os.Getenv(OtelTracesSamplerArg)
+	return strconv.ParseFloat(arg, 64)
+}
+
+/* GetPropogater returns a slice of propagators to be used by the OpenTelemetry
+provider.
+
+Supported providers:
+tracecontext - W3C Trace Context
+baggage - W3C Baggage
+b3 - B3 Single
+b3multi - B3 Multi
+jaeger - Jaeger uber-trace-id header
+xray - AWS X-Ray (third party)
+ottrace - OpenTracing Trace (third party)
+*/
+func GetPropogater(logger *zap.Logger) []propagation.TextMapPropagator {
+	propogatersEnv := os.Getenv(OtelPropogaters)
+	if propogatersEnv == "" {
+		return []propagation.TextMapPropagator{
+			propagation.TraceContext{}, propagation.Baggage{},
+		}
+	}
+	propogators := []propagation.TextMapPropagator{}
+	for _, prop := range strings.Split(propogatersEnv, ",") {
+		switch prop {
+		case "tracecontext":
+			propogators = append(propogators, propagation.TraceContext{})
+		case "baggage":
+			propogators = append(propogators, propagation.Baggage{})
+		case "b3multi":
+			propogators = append(propogators, b3.New(b3.WithInjectEncoding(b3.B3MultipleHeader)))
+		case "b3":
+			propogators = append(propogators, b3.New(b3.WithInjectEncoding(b3.B3SingleHeader)))
+		case "jaeger":
+			propogators = append(propogators, jaeger.Jaeger{})
+		case "xray":
+			propogators = append(propogators, xray.Propagator{})
+		case "ottrace":
+			propogators = append(propogators, ot.OT{})
+		default:
+			logger.Error("Unsupported propagation type", zap.String("propagation", prop))
+		}
+	}
+	if len(propogators) == 0 {
+		return []propagation.TextMapPropagator{
+			propagation.TraceContext{}, propagation.Baggage{},
+		}
+	}
+	return propogators
+}
+
+/*
+GetSampler returns a sampler that can be used to sample traces.
+This is based on https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/sdk-environment-variables.md#general-sdk-configuration
+We have to implement as open-telemetry Go sdk doesn't support configuration of different samplers.
+Once its added we may remove this code.
+
+Supported samplers:
+always_on - Sampler that always samples spans, regardless of the parent span's sampling decision.
+always_off - Sampler that never samples spans, regardless of the parent span's sampling decision.
+traceidratio - Sampler that samples probabalistically based on rate.
+parentbased_always_on - (default) Sampler that respects its parent span's sampling decision, but otherwise always samples.
+parentbased_always_off - Sampler that respects its parent span's sampling decision, but otherwise never samples.
+parentbased_traceidratio - Sampler that respects its parent span's sampling decision, but otherwise samples probabalistically based on rate.
+
+Environment variables:
+OTEL_TRACES_SAMPLER - Sampler to use(one of the above samplers)
+OTEL_TRACES_SAMPLER_ARG - Argument to pass to the sampler(float value)
+*/
+func GetSampler() (sdktrace.Sampler, error) {
+	samplerType := os.Getenv(OtelTracesSampler)
+	switch samplerType {
+	case "always_on":
+		return sdktrace.AlwaysSample(), nil
+	case "always_off":
+		return sdktrace.NeverSample(), nil
+	case "parentbased_always_on":
+		return sdktrace.ParentBased(sdktrace.AlwaysSample()), nil
+	case "parentbased_always_off":
+		return sdktrace.ParentBased(sdktrace.NeverSample()), nil
+	case "traceidratio":
+		arg, err := getSamplerArg()
+		if err != nil {
+			return nil, fmt.Errorf("invalid sampler arg: %w", err)
+		}
+		return sdktrace.TraceIDRatioBased(arg), nil
+	case "parentbased_traceidratio":
+		arg, err := getSamplerArg()
+		if err != nil {
+			return nil, fmt.Errorf("invalid sampler arg: %w", err)
+		}
+		return sdktrace.ParentBased(sdktrace.TraceIDRatioBased(arg)), nil
+	default:
+		return sdktrace.ParentBased(sdktrace.AlwaysSample()), nil
+	}
+}
+
+// parseOtelConfig parses the environment variables OTEL_EXPORTER_OTLP_ENDPOINT and
 func parseOtelConfig() OtelConfig {
 	config := OtelConfig{}
 	config.endpoint = os.Getenv(OtelEndpointEnvVar)
 	insecure, err := strconv.ParseBool(os.Getenv(OtelInsecureEnvVar))
 	if err != nil {
-		insecure = false
+		insecure = true
 	}
 	config.insecure = insecure
 	return config
@@ -44,7 +158,9 @@ func parseOtelConfig() OtelConfig {
 func getTraceExporter(ctx context.Context, logger *zap.Logger) (*otlptrace.Exporter, error) {
 	otelConfig := parseOtelConfig()
 	if otelConfig.endpoint == "" {
-		logger.Info("OTEL_EXPORTER_OTLP_ENDPOINT not set, skipping Opentelemtry tracing")
+		if logger != nil {
+			logger.Info("OTEL_EXPORTER_OTLP_ENDPOINT not set, skipping Opentelemtry tracing")
+		}
 		return nil, nil
 	}
 
@@ -75,10 +191,14 @@ func InitProvider(ctx context.Context, logger *zap.Logger, serviceName string) (
 	if err != nil {
 		return nil, err
 	}
+	sampler, err := GetSampler()
+	if err != nil {
+		return nil, err
+	}
 	tracerProvider := sdktrace.NewTracerProvider(
 		sdktrace.WithResource(res),
+		sdktrace.WithSampler(sampler),
 	)
-
 	traceExporter, err := getTraceExporter(ctx, logger)
 	if err != nil {
 		return nil, err
@@ -90,17 +210,16 @@ func InitProvider(ctx context.Context, logger *zap.Logger, serviceName string) (
 	}
 
 	otel.SetTracerProvider(tracerProvider)
-	otel.SetTextMapPropagator(propagation.NewCompositeTextMapPropagator(
-		propagation.TraceContext{}, propagation.Baggage{}))
-
+	propogaters := GetPropogater(logger)
+	otel.SetTextMapPropagator(propagation.NewCompositeTextMapPropagator(propogaters...))
 	// Shutdown will flush any remaining spans and shut down the exporter.
 	return func(ctx context.Context) {
 		err := tracerProvider.Shutdown(ctx)
-		if err != nil {
+		if err != nil && logger != nil {
 			logger.Fatal("error shutting down trace provider", zap.Error(err))
 		}
 		if traceExporter != nil {
-			if err = traceExporter.Shutdown(ctx); err != nil {
+			if err = traceExporter.Shutdown(ctx); err != nil && logger != nil {
 				logger.Fatal("error shutting down trace exporter", zap.Error(err))
 			}
 		}


Test patch:
diff --git a/pkg/fission-cli/cmd/function/test.go b/pkg/fission-cli/cmd/function/test.go
index 0122140d..735364a7 100644
--- a/pkg/fission-cli/cmd/function/test.go
+++ b/pkg/fission-cli/cmd/function/test.go
@@ -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")
 	}
diff --git a/pkg/utils/otel/provider_test.go b/pkg/utils/otel/provider_test.go
new file mode 100644
index 00000000..00fb5906
--- /dev/null
+++ b/pkg/utils/otel/provider_test.go
@@ -0,0 +1,181 @@
+package otel
+
+import (
+	"context"
+	"errors"
+	"fmt"
+	"os"
+	"reflect"
+	"testing"
+
+	"go.opentelemetry.io/contrib/propagators/jaeger"
+	"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
+	"go.opentelemetry.io/otel/propagation"
+	sdktrace "go.opentelemetry.io/otel/sdk/trace"
+
+	"github.com/fission/fission/pkg/utils/loggerfactory"
+)
+
+func TestGetPropogater(t *testing.T) {
+	if OtelPropogaters != "OTEL_PROPOGATORS" {
+		t.Errorf("Expected OTEL_PROPOGATORS to be set, got %s", OtelPropogaters)
+	}
+	tests := []struct {
+		propogaterEnv string
+		propogaters   []propagation.TextMapPropagator
+	}{
+		{
+			"",
+			[]propagation.TextMapPropagator{propagation.TraceContext{}, propagation.Baggage{}},
+		},
+		{
+			"tracecontext,baggage",
+			[]propagation.TextMapPropagator{propagation.TraceContext{}, propagation.Baggage{}},
+		},
+		{
+			"jaeger",
+			[]propagation.TextMapPropagator{jaeger.Jaeger{}},
+		},
+		{
+			"baggage,tracecontext",
+			[]propagation.TextMapPropagator{propagation.Baggage{}, propagation.TraceContext{}},
+		},
+		{
+			"jaeger,baggage",
+			[]propagation.TextMapPropagator{jaeger.Jaeger{}, propagation.Baggage{}},
+		},
+	}
+	logger := loggerfactory.GetLogger()
+	for _, tt := range tests {
+		os.Setenv(OtelPropogaters, tt.propogaterEnv)
+		prop := GetPropogater(logger)
+		if prop == nil {
+			t.Errorf("GetPropogater() = %#v, want %#v", prop, tt.propogaters)
+		}
+		if len(prop) != len(tt.propogaters) {
+			t.Errorf("GetPropogater() = %#v, want %#v", prop, tt.propogaters)
+		}
+		if !reflect.DeepEqual(prop, tt.propogaters) {
+			t.Errorf("GetPropogater() = %#v, want %#v", prop, tt.propogaters)
+		}
+	}
+}
+
+func TestGetSampler(t *testing.T) {
+	if OtelTracesSampler != "OTEL_TRACES_SAMPLER" {
+		t.Errorf("Expected OTEL_TRACES_SAMPLER to be set, got %s", OtelTracesSampler)
+	}
+	if OtelTracesSamplerArg != "OTEL_TRACES_SAMPLER_ARG" {
+		t.Errorf("Expected OTEL_TRACES_SAMPLER_ARG to be set, got %s", OtelTracesSamplerArg)
+	}
+	if OtelPropogaters != "OTEL_PROPOGATORS" {
+		t.Errorf("Expected OTEL_PROPOGATORS to be set, got %s", OtelPropogaters)
+	}
+	tests := []struct {
+		sampler     string
+		samplerArg  string
+		wantSampler sdktrace.Sampler
+		wantError   error
+	}{
+		{
+			"",
+			"",
+			sdktrace.ParentBased(sdktrace.AlwaysSample()),
+			nil,
+		},
+		{
+			"always_on",
+			"",
+			sdktrace.AlwaysSample(),
+			nil,
+		},
+		{
+			"always_off",
+			"",
+			sdktrace.NeverSample(),
+			nil,
+		},
+		{
+			"parentbased_always_on",
+			"",
+			sdktrace.ParentBased(sdktrace.AlwaysSample()),
+			nil,
+		},
+		{
+			"parentbased_always_off",
+			"",
+			sdktrace.ParentBased(sdktrace.NeverSample()),
+			nil,
+		},
+		{
+			"traceidratio",
+			"0.5",
+			sdktrace.TraceIDRatioBased(0.5),
+			nil,
+		},
+		{
+			"traceidratio",
+			"",
+			nil,
+			errors.New("invalid sampler arg: strconv.ParseFloat: parsing \"\": invalid syntax"),
+		},
+		{
+			"parentbased_traceidratio",
+			"",
+			nil,
+			errors.New("invalid sampler arg: strconv.ParseFloat: parsing \"\": invalid syntax"),
+		},
+		{
+			"parentbased_traceidratio",
+			"0.01",
+			sdktrace.ParentBased(sdktrace.TraceIDRatioBased(0.01)),
+			nil,
+		},
+	}
+	for _, tt := range tests {
+		os.Setenv(OtelTracesSampler, tt.sampler)
+		os.Setenv(OtelTracesSamplerArg, tt.samplerArg)
+		gotSampler, gotError := GetSampler()
+		if !reflect.DeepEqual(gotSampler, tt.wantSampler) {
+			t.Errorf("GetSampler() gotSampler = %#v, want %#v", gotSampler, tt.wantSampler)
+		}
+		if fmt.Sprintf("%s", gotError) != fmt.Sprintf("%s", tt.wantError) {
+			t.Errorf("GetSampler() gotError = %#v, want %#v", gotError, tt.wantError)
+		}
+	}
+}
+
+func TestGetTraceExporter(t *testing.T) {
+	if OtelEndpointEnvVar != "OTEL_EXPORTER_OTLP_ENDPOINT" {
+		t.Errorf("Expected OTEL_EXPORTER_OTLP_ENDPOINT to be set, got %s", OtelEndpointEnvVar)
+	}
+	if OtelInsecureEnvVar != "OTEL_EXPORTER_OTLP_INSECURE" {
+		t.Errorf("Expected OTEL_EXPORTER_OTLP_INSECURE to be set, got %s", OtelInsecureEnvVar)
+	}
+	logger := loggerfactory.GetLogger()
+	ctx := context.Background()
+	tests := []struct {
+		oltpEndpoint string
+		oltpInsecure string
+		wantExporter *otlptrace.Exporter
+		wantError    error
+	}{
+		{
+			"",
+			"",
+			nil,
+			nil,
+		},
+	}
+	for _, tt := range tests {
+		os.Setenv(OtelEndpointEnvVar, tt.oltpEndpoint)
+		os.Setenv(OtelInsecureEnvVar, tt.oltpInsecure)
+		exporter, err := getTraceExporter(ctx, logger)
+		if !reflect.DeepEqual(exporter, tt.wantExporter) {
+			t.Errorf("getTraceExporter() exporter = %#v, want %#v", exporter, tt.wantExporter)
+		}
+		if fmt.Sprintf("%s", err) != fmt.Sprintf("%s", tt.wantError) {
+			t.Errorf("getTraceExporter() err = %#v, want %#v", err, tt.wantError)
+		}
+	}
+}