[VOL-3855] Skip span generation if both tracing and log_correlation are disabled

Without skipping we are generating an Empty span than will fail
extraction when it hits the second component

Change-Id: Ib47f369bd0bff3a76e9a761ac63367f8018e6ee0
diff --git a/VERSION b/VERSION
index a1ef0ca..50e2274 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-5.0.2
+5.0.3
diff --git a/pkg/kafka/kafka_inter_container_library.go b/pkg/kafka/kafka_inter_container_library.go
index b149e7d..d874fb6 100644
--- a/pkg/kafka/kafka_inter_container_library.go
+++ b/pkg/kafka/kafka_inter_container_library.go
@@ -197,14 +197,15 @@
 func (kp *interContainerProxy) InvokeAsyncRPC(ctx context.Context, rpc string, toTopic *Topic, replyToTopic *Topic,
 	waitForResponse bool, key string, kvArgs ...*KVArg) chan *RpcResponse {
 
-	logger.Debugw(ctx, "InvokeAsyncRPC", log.Fields{"rpc": rpc, "key": key})
-
 	spanArg, span, ctx := kp.embedSpanAsArg(ctx, rpc, !waitForResponse)
 	if spanArg != nil {
 		kvArgs = append(kvArgs, &spanArg[0])
 	}
+
 	defer span.Finish()
 
+	logger.Debugw(ctx, "InvokeAsyncRPC", log.Fields{"rpc": rpc, "key": key, "kvArgs": kvArgs})
+
 	//	If a replyToTopic is provided then we use it, otherwise just use the  default toTopic.  The replyToTopic is
 	// typically the device ID.
 	responseTopic := replyToTopic
@@ -315,6 +316,13 @@
 	var newCtx context.Context
 	var spanToInject opentracing.Span
 
+	if !log.GetGlobalLFM().GetLogCorrelationStatus() && !log.GetGlobalLFM().GetTracePublishingStatus() {
+		// if both log correlation and trace publishing is disable do not generate the span
+		logger.Debugw(ctx, "not-embedding-span-in-KVArg-", log.Fields{"rpc": rpc,
+			"log-correlation-status": log.GetGlobalLFM().GetLogCorrelationStatus(), "trace-publishing-status": log.GetGlobalLFM().GetTracePublishingStatus()})
+		return nil, opentracing.SpanFromContext(ctx), ctx
+	}
+
 	var spanName strings.Builder
 	spanName.WriteString("kafka-")
 
@@ -366,8 +374,11 @@
 	if spanArg != nil {
 		kvArgs = append(kvArgs, &spanArg[0])
 	}
+
 	defer span.Finish()
 
+	logger.Debugw(ctx, "InvokeRPC", log.Fields{"rpc": rpc, "key": key, "kvArgs": kvArgs})
+
 	//	If a replyToTopic is provided then we use it, otherwise just use the  default toTopic.  The replyToTopic is
 	// typically the device ID.
 	responseTopic := replyToTopic
@@ -876,10 +887,10 @@
 		if err = ptypes.UnmarshalAny(msg.Body, requestBody); err != nil {
 			logger.Warnw(ctx, "cannot-unmarshal-request", log.Fields{"error": err})
 		} else {
+			logger.Debugw(ctx, "received-request", log.Fields{"rpc": requestBody.Rpc, "header": msg.Header, "args": requestBody.Args})
 			span, ctx := kp.enrichContextWithSpan(ctx, requestBody.Rpc, requestBody.Args)
 			defer span.Finish()
 
-			logger.Debugw(ctx, "received-request", log.Fields{"rpc": requestBody.Rpc, "header": msg.Header})
 			// let the callee unpack the arguments as its the only one that knows the real proto type
 			// Augment the requestBody with the message Id as it will be used in scenarios where cores
 			// are set in pairs and competing