You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/02/06 11:59:41 UTC

[GitHub] cbickel closed pull request #3255: Only log outgoing requests.

cbickel closed pull request #3255: Only log outgoing requests.
URL: https://github.com/apache/incubator-openwhisk/pull/3255
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/common/scala/src/main/scala/whisk/http/BasicHttpService.scala b/common/scala/src/main/scala/whisk/http/BasicHttpService.scala
index 914c199133..c64afd8326 100644
--- a/common/scala/src/main/scala/whisk/http/BasicHttpService.scala
+++ b/common/scala/src/main/scala/whisk/http/BasicHttpService.scala
@@ -76,14 +76,12 @@ trait BasicHttpService extends Directives with TransactionCounter {
    */
   def route: Route = {
     assignId { implicit transid =>
-      DebuggingDirectives.logRequest(logRequestInfo _) {
-        DebuggingDirectives.logRequestResult(logResponseInfo _) {
-          BasicDirectives.mapRequest(_.removeHeader(OW_EXTRA_LOGGING_HEADER)) {
-            handleRejections(BasicHttpService.customRejectionHandler) {
-              prioritizeRejections {
-                toStrictEntity(30.seconds) {
-                  routes
-                }
+      DebuggingDirectives.logRequestResult(logResponseInfo _) {
+        BasicDirectives.mapRequest(_.removeHeader(OW_EXTRA_LOGGING_HEADER)) {
+          handleRejections(BasicHttpService.customRejectionHandler) {
+            prioritizeRejections {
+              toStrictEntity(30.seconds) {
+                routes
               }
             }
           }
@@ -105,33 +103,25 @@ trait BasicHttpService extends Directives with TransactionCounter {
   }
 
   /** Generates log entry for every request. */
-  protected def logRequestInfo(req: HttpRequest)(implicit tid: TransactionId): LogEntry = {
-    val m = req.method.name
-    val p = req.uri.path.toString
-    val q = req.uri.query().toString
-    val l = loglevelForRoute(p)
-    LogEntry(s"[$tid] $m $p $q", l)
-  }
-
   protected def logResponseInfo(req: HttpRequest)(implicit tid: TransactionId): RouteResult => Option[LogEntry] = {
     case RouteResult.Complete(res: HttpResponse) =>
       val m = req.method.name
       val p = req.uri.path.toString
+      val q = req.uri.query().toString
       val l = loglevelForRoute(p)
+      val responseCode = res.status.intValue
 
-      val name = "BasicHttpService"
-
-      val token = LogMarkerToken("http", s"${m.toLowerCase}.${res.status.intValue}", LoggingMarkers.count)
-      val marker = LogMarker(token, tid.deltaToStart, Some(tid.deltaToStart))
+      val token = LogMarkerToken("http", s"${m.toLowerCase}.${responseCode}", LoggingMarkers.count)
 
       if (TransactionId.metricsKamon) {
         MetricEmitter.emitHistogramMetric(token, tid.deltaToStart)
         MetricEmitter.emitCounterMetric(token)
       }
       if (TransactionId.metricsLog) {
-        Some(LogEntry(s"[$tid] [$name] $marker", l))
+        val marker = LogMarker(token, tid.deltaToStart, Some(tid.deltaToStart))
+        Some(LogEntry(s"[$tid] $m $p $q $responseCode $marker", l))
       } else {
-        None
+        Some(LogEntry(s"[$tid] $m $p $q $responseCode", l))
       }
 
     case _ => None // other kind of responses


 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services