adriancole commented on a change in pull request #2282: Distributed tracing 
support #2192
URL: 
https://github.com/apache/incubator-openwhisk/pull/2282#discussion_r120270748
 
 

 ##########
 File path: common/scala/src/main/scala/whisk/common/Logging.scala
 ##########
 @@ -122,6 +138,45 @@ class PrintStreamLogging(outputStream: PrintStream = 
Console.out) extends Loggin
 }
 
 /**
+  * Implementation of logging which also supports tracing using Zipkin.
+  * @param logger <code>Logging<code> instance which can do basic logging
+  */
+class ZipkinLogging (logger: Logging) extends Logging {
+
+    def emit(loglevel: LogLevel, id: TransactionId, from: AnyRef, message: 
String) = {
+        logger.emit(loglevel, id, from, message)
+    }
+
+    override def emit(loglevel: LogLevel, id: TransactionId, from: AnyRef, 
message: String, logMarker: LogMarker) = {
+
+        //log message as usual
+        emit(loglevel, id, from, 
TransactionId.createMessageWithMarker(message, logMarker))
+
+        //tracing support
+        logMarker.token.state match {
+
+            case LoggingMarkers.start => {
+                TraceUtil.startTrace(logMarker.token.getServiceName(), id)
+            }
+
+            case LoggingMarkers.finish => {
+                var req = TraceUtil.getTracedRequestForTrasactionId(id)
+                if (req != null)
+                    TraceUtil.finish(id)
+            }
+
+            case LoggingMarkers.error => {
+                var req = TraceUtil.getTracedRequestForTrasactionId(id)
+                if (req != null)
 
 Review comment:
   usually an "error" tag (binary annotation) is added to the span on error. 
This color-codes it red in the UI
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to