You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by rc...@apache.org on 2020/06/08 03:12:35 UTC

[james-project] 14/16: JAMES-3171 Add metrics to MailboxGetMethod process

This is an automated email from the ASF dual-hosted git repository.

rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 613a87b7d4cf17a879c170084375fa507b3cfce1
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Wed May 27 14:21:44 2020 +0700

    JAMES-3171 Add metrics to MailboxGetMethod process
---
 .../scala/org/apache/james/jmap/method/MailboxGetMethod.scala    | 9 ++++++---
 .../src/main/scala/org/apache/james/jmap/method/Method.scala     | 2 ++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxGetMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxGetMethod.scala
index ca9f2e7..1ccb921 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxGetMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxGetMethod.scala
@@ -30,6 +30,7 @@ import org.apache.james.jmap.utils.quotas.QuotaLoaderWithPreloadedDefaultFactory
 import org.apache.james.mailbox.model.MailboxMetaData
 import org.apache.james.mailbox.model.search.MailboxQuery
 import org.apache.james.mailbox.{MailboxManager, MailboxSession}
+import org.apache.james.metrics.api.MetricFactory
 import org.reactivestreams.Publisher
 import play.api.libs.json.{JsError, JsObject, JsSuccess, Json}
 import reactor.core.scala.publisher.{SFlux, SMono}
@@ -38,11 +39,13 @@ import reactor.core.scheduler.Schedulers
 class MailboxGetMethod @Inject() (serializer: Serializer,
                                   mailboxManager: MailboxManager,
                                   quotaFactory : QuotaLoaderWithPreloadedDefaultFactory,
-                                  mailboxFactory: MailboxFactory) extends Method {
+                                  mailboxFactory: MailboxFactory,
+                                  metricFactory: MetricFactory) extends Method {
   override val methodName: MethodName = MethodName("Mailbox/get")
 
   override def process(invocation: Invocation, mailboxSession: MailboxSession): Publisher[Invocation] = {
-    asMailboxGetRequest(invocation.arguments)
+    metricFactory.runPublishingTimerMetricLogP99(JMAP_RFC8621_PREFIX + methodName.value,
+      asMailboxGetRequest(invocation.arguments)
         .flatMap(mailboxGetRequest => getMailboxes(mailboxGetRequest, mailboxSession)
           .collectSeq()
           .map(_.sortBy(_.sortOrder))
@@ -54,7 +57,7 @@ class MailboxGetMethod @Inject() (serializer: Serializer,
           .map(mailboxGetResponse => Invocation(
             methodName = methodName,
             arguments = Arguments(serializer.serialize(mailboxGetResponse).as[JsObject]),
-            methodCallId = invocation.methodCallId)))
+            methodCallId = invocation.methodCallId))))
   }
 
   private def asMailboxGetRequest(arguments: Arguments): SMono[MailboxGetRequest] = {
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/Method.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/Method.scala
index 21b33b5..02751dc 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/Method.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/Method.scala
@@ -25,6 +25,8 @@ import org.apache.james.mailbox.MailboxSession
 import org.reactivestreams.Publisher
 
 trait Method {
+  val JMAP_RFC8621_PREFIX: String = "JMAP-RFC8621-"
+
   val methodName: MethodName
 
   def process(invocation: Invocation, mailboxSession: MailboxSession): Publisher[Invocation]


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org