[GitHub] [openwhisk] selfxp commented on a change in pull request #4584: OpenWhisk User Events

2019-09-20 Thread GitBox
selfxp commented on a change in pull request #4584: OpenWhisk User Events
URL: https://github.com/apache/openwhisk/pull/4584#discussion_r326800406
 
 

 ##
 File path: 
common/scala/src/main/scala/org/apache/openwhisk/core/connector/Message.scala
 ##
 @@ -256,6 +286,7 @@ case class Metric(metricName: String, metricValue: Long) 
extends EventMessageBod
 }
 
 object Metric extends DefaultJsonProtocol {
+  val typeName = "Metric"
 
 Review comment:
   I think it's still being used here: 
https://github.com/apache/openwhisk/blob/f04275a825346da52d8616cf241f7a6ae78dccbc/core/monitoring/user-events/src/main/scala/org/apache/openwhisk/core/monitoring/metrics/EventConsumer.scala#L99


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [openwhisk] selfxp commented on a change in pull request #4584: OpenWhisk User Events

2019-09-17 Thread GitBox
selfxp commented on a change in pull request #4584: OpenWhisk User Events
URL: https://github.com/apache/openwhisk/pull/4584#discussion_r325345830
 
 

 ##
 File path: core/monitoring/user-events/README.md
 ##
 @@ -0,0 +1,55 @@
+
+
+# ![OpenWhisk User 
Events](https://raw.githubusercontent.com/apache/openwhisk/master/core/monitoring/user-events/images/demo_landing.png)
+
+# OpenWhisk User Events
+
+This service connects to `events` topic and publishes the events to various 
services like Prometheus, Datadog etc via Kamon. Refer to [user specific 
metrics][1] on how to enable them.
 
 Review comment:
    yes good idea, adding a reference


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [openwhisk] selfxp commented on a change in pull request #4584: OpenWhisk User Events

2019-09-17 Thread GitBox
selfxp commented on a change in pull request #4584: OpenWhisk User Events
URL: https://github.com/apache/openwhisk/pull/4584#discussion_r324002293
 
 

 ##
 File path: 
common/scala/src/main/scala/org/apache/openwhisk/core/connector/Message.scala
 ##
 @@ -223,6 +256,15 @@ object Activation extends DefaultJsonProtocol {
   "memory",
   "causedBy")
 
 Review comment:
    I'll create an issue for this


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [openwhisk] selfxp commented on a change in pull request #4584: OpenWhisk User Events

2019-09-12 Thread GitBox
selfxp commented on a change in pull request #4584: OpenWhisk User Events
URL: https://github.com/apache/openwhisk/pull/4584#discussion_r324003457
 
 

 ##
 File path: 
core/monitoring/user-events/src/main/scala/org/apache/openwhisk/core/monitoring/metrics/KamonRecorder.scala
 ##
 @@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.openwhisk.core.monitoring.metrics
+
+import akka.event.slf4j.SLF4JLogging
+import org.apache.openwhisk.core.connector.{Activation, Metric}
+import kamon.Kamon
+import kamon.metric.MeasurementUnit
+
+import scala.collection.concurrent.TrieMap
+
+trait KamonMetricNames extends MetricNames {
+  val activationMetric = "openwhisk.action.activations"
+  val coldStartMetric = "openwhisk.action.coldStarts"
+  val waitTimeMetric = "openwhisk.action.waitTime"
+  val initTimeMetric = "openwhisk.action.initTime"
+  val durationMetric = "openwhisk.action.duration"
+  val statusMetric = "openwhisk.action.status"
+
+  val concurrentLimitMetric = "openwhisk.action.limit.concurrent"
+  val timedLimitMetric = "openwhisk.action.limit.timed"
+}
+
+object KamonRecorder extends MetricRecorder with KamonMetricNames with 
SLF4JLogging {
+  private val activationMetrics = new TrieMap[String, ActivationKamonMetrics]
+  private val limitMetrics = new TrieMap[String, LimitKamonMetrics]
+
+  override def processActivation(activation: Activation, initiatorNamespace: 
String): Unit = {
 
 Review comment:
   yes exactly, initiator would be the namespace that makes the invocation


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [openwhisk] selfxp commented on a change in pull request #4584: OpenWhisk User Events

2019-09-12 Thread GitBox
selfxp commented on a change in pull request #4584: OpenWhisk User Events
URL: https://github.com/apache/openwhisk/pull/4584#discussion_r324002153
 
 

 ##
 File path: 
common/scala/src/main/scala/org/apache/openwhisk/core/connector/Message.scala
 ##
 @@ -194,22 +196,53 @@ object EventMessageBody extends DefaultJsonProtocol {
 
 case class Activation(name: String,
   statusCode: Int,
-  duration: Long,
-  waitTime: Long,
-  initTime: Long,
+  duration: Duration,
+  waitTime: Duration,
+  initTime: Duration,
   kind: String,
   conductor: Boolean,
   memory: Int,
   causedBy: Option[String])
 extends EventMessageBody {
-  val typeName = "Activation"
+  val typeName = Activation.typeName
   override def serialize = toJson.compactPrint
 
   def toJson = Activation.activationFormat.write(this)
+
+  def status: String = statusCode match {
 
 Review comment:
   Yeah makes sense, I'll use that


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [openwhisk] selfxp commented on a change in pull request #4584: OpenWhisk User Events

2019-09-12 Thread GitBox
selfxp commented on a change in pull request #4584: OpenWhisk User Events
URL: https://github.com/apache/openwhisk/pull/4584#discussion_r324005299
 
 

 ##
 File path: 
core/monitoring/user-events/src/main/scala/org/apache/openwhisk/core/monitoring/metrics/PrometheusEventsApi.scala
 ##
 @@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.openwhisk.core.monitoring.metrics
+
+import akka.http.scaladsl.model.StatusCodes.ServiceUnavailable
+import akka.http.scaladsl.model.{ContentType, MessageEntity}
+import akka.http.scaladsl.server.Directives._
+import akka.http.scaladsl.server.Route
+
+trait PrometheusExporter {
+  def getReport(): MessageEntity
+}
+
+object PrometheusExporter {
+  val textV4: ContentType = ContentType.parse("text/plain; version=0.0.4; 
charset=utf-8").right.get
+}
+
+class PrometheusEventsApi(consumer: EventConsumer, prometheus: 
PrometheusExporter) {
 
 Review comment:
   it's not, I guess it depends on the environment on where it's being 
deployed. In `openwhisk-deploy-kube` I have a PR where the service would be 
exposed through the gateway 
([#520](https://github.com/apache/openwhisk-deploy-kube/pull/520/files)), and 
so the authentication strategy could be defined there


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services