-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add containerPool container histogram metric #5222
Add containerPool container histogram metric #5222
Conversation
val t1 = System.currentTimeMillis() | ||
MetricEmitter.emitHistogramMetric( | ||
LogMarkerToken("kubeapi", "create", "duration", Some("create"), Map("cmd" -> "create"))( | ||
MeasurementUnit.time.milliseconds), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, just add kubeapi for create, maybe we can add kubeapi for delete
in future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The related transaction id already exists. And it is better to use transid than to calculate time directly.
val start = transid.started(
this,
LoggingMarkers.INVOKER_KUBEAPI_CMD("create"),
s"launching pod $name (image:$image, mem: ${memory.toMB}) (timeout: ${config.timeouts.run.toSeconds}s)",
logLevel = akka.event.Logging.InfoLevel)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
transid.finished
method already sends Histogram metric here. What's the difference?
openwhisk/common/scala/src/main/scala/org/apache/openwhisk/common/TransactionId.scala
Line 125 in 99fb2c5
MetricEmitter.emitHistogramMetric(endMarker, deltaToEnd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@upgle ,good found, has no any difference, i already removed the duplicated one, just keep transid.finish
to send the metric.
MetricEmitter.emitHistogramMetric(LoggingMarkers.INVOKER_CONTAINERPOOL_CONTAINER("prewarmed"), prewarmedSize) | ||
MetricEmitter.emitHistogramMetric(LoggingMarkers.INVOKER_CONTAINERPOOL_CONTAINER("busy"), busySize) | ||
MetricEmitter.emitHistogramMetric(LoggingMarkers.INVOKER_CONTAINERPOOL_CONTAINER("warmed"), warmedSize) | ||
MetricEmitter.emitHistogramMetric(LoggingMarkers.INVOKER_CONTAINERPOOL_CONTAINER("all"), allSize) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As admin, he may want to know the prewarmed/busy/warmed container in one invoker in metric show page
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep this a great metric addition and needed. Should we include namespace and action as tags here as well for the warmed containers? If needed in a separate metric. I think it's useful as well to know what invokers a namespace and actions are running on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that would apply for the memory metric as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bdoyle0182 for warmed container size metric, i have added namespace
and action
tags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding I guess that would apply for the memory metric as well
Seems a little complex to apply tag: namespace + action to memory metric.
Currently, i just apply the tag(namespace + action) to container metric.
cd40b2a
to
439d6d0
Compare
Codecov Report
@@ Coverage Diff @@
## master #5222 +/- ##
=======================================
Coverage 44.87% 44.87%
=======================================
Files 238 238
Lines 13996 13996
Branches 561 561
=======================================
Hits 6281 6281
Misses 7715 7715 Continue to review full report at Codecov.
|
439d6d0
to
513fccd
Compare
LGTM other than my one comment |
MetricEmitter.emitHistogramMetric( | ||
LogMarkerToken("docker", "runCmd", "duration", Some(args.head), Map("cmd" -> args.head))( | ||
MeasurementUnit.time.milliseconds), | ||
Instant.now.toEpochMilli - transid.meta.start.toEpochMilli) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the usual way to send metric.
Is there any reason not to use transid start, finish ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already changed to use transid.finish
to send the metric and delete the repeated one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that the transid.finished method is already sending histogram metric. I wonder what the difference is.
val t1 = System.currentTimeMillis() | ||
MetricEmitter.emitHistogramMetric( | ||
LogMarkerToken("kubeapi", "create", "duration", Some("create"), Map("cmd" -> "create"))( | ||
MeasurementUnit.time.milliseconds), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
transid.finished
method already sends Histogram metric here. What's the difference?
openwhisk/common/scala/src/main/scala/org/apache/openwhisk/common/TransactionId.scala
Line 125 in 99fb2c5
MetricEmitter.emitHistogramMetric(endMarker, deltaToEnd) |
18b611d
to
910d7de
Compare
def INVOKER_RUNC_CMD(cmd: String) = | ||
LogMarkerToken(invoker, "runc", start, Some(cmd), Map("cmd" -> cmd))(MeasurementUnit.time.milliseconds) | ||
def INVOKER_KUBEAPI_CMD(cmd: String) = | ||
LogMarkerToken(invoker, "kubeapi", start, Some(cmd), Map("cmd" -> cmd))(MeasurementUnit.none) | ||
LogMarkerToken(invoker, "kubeapi", start, Some(cmd), Map("cmd" -> cmd))(MeasurementUnit.time.milliseconds) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Obviously, the unit should be MeasurementUnit.time.milliseconds
@@ -207,7 +207,6 @@ class DockerClient(dockerHost: Option[String] = None, | |||
case Success(_) => transid.finished(this, start) | |||
case Failure(pte: ProcessTimeoutException) => | |||
transid.failed(this, start, pte.getMessage, ErrorLevel) | |||
MetricEmitter.emitCounterMetric(LoggingMarkers.INVOKER_DOCKER_CMD_TIMEOUT(args.head)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
transid.failed
already send the metric, so delete the repeated one and deleted the INVOKER_DOCKER_CMD_TIMEOUT
method
@ningyougang can we get this merged in? This is a useful metric to have available along with the container pool memory that's already there |
Oh, ok |
4b2b1ba
to
45c1d32
Compare
} | ||
val warmedPoolResultMap: mutable.Map[(String, String), Int] = mutable.Map.empty[(String, String), Int] | ||
warmedPoolGroupMap.foreach { data => | ||
warmedPoolResultMap += (data._1 -> data._2.size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't it just remove the type annotation?
val warmedPoolMap = warmedPool groupBy {
case (_, warmedData) => (warmedData.invocationNamespace, warmedData.action.toString)
} mapValues (_.size)
for((data, size) <- warmedPoolMap) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a good solution.
map += (k -> v) | ||
} | ||
} | ||
LogMarkerToken(invoker, "containerPoolContainer", counter, Some(state), map)(MeasurementUnit.none) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can use tags.map(Map("state" -> state) ++: _).getOrElse(Map("state" -> state))
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorrry, this Map("state" -> state) ++: tags.getOrElse(Map.empty)
should be better
45c1d32
to
71e224e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with some minor suggestions
71e224e
to
53cbe7f
Compare
* Add containerPool container histogram metric * Add pod creation consume time metric * Add docker container creation consume time metric * Use transaction to calculate * Add namespace and action tags for container metric * Avoid send metric repeatedly * Fix scala 2.13 compilation error * Update according to review comment
There has container start relative metric in FunctionFullContainerPool,
It is better to provide container size histogram metric as well
Add pod creation consume time metricalready existed using trans.finishAdd docker container creation consume time metricalready existed using trans.finishDescription
Related issue and scope
My changes affect the following components
Types of changes
Checklist: