-
Notifications
You must be signed in to change notification settings - Fork 450
[CELEBORN-194] Introduce client side metrics for celeborn #3740
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
base: main
Are you sure you want to change the base?
Changes from all commits
905411f
a31fe31
57e588a
438f541
2070627
fe1aa14
28ea5fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| /* | ||
| * 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.celeborn.client | ||
|
|
||
| import java.util.concurrent.ConcurrentHashMap | ||
|
|
||
| import org.apache.celeborn.common.CelebornConf | ||
| import org.apache.celeborn.common.metrics.{ClientMetric, MetricType} | ||
| import org.apache.celeborn.common.metrics.source.{AbstractSource, Role} | ||
|
|
||
| /** | ||
| * Metrics source for the Celeborn client | ||
| */ | ||
| class CelebornClientSource(conf: CelebornConf) extends AbstractSource(conf, Role.CLIENT) { | ||
| override val sourceName = "client" | ||
|
|
||
| import CelebornClientSource._ | ||
|
|
||
| // Tracks previous counter values so we can send deltas to the master. | ||
| private val counterPrev = new ConcurrentHashMap[String, java.lang.Long]() | ||
|
|
||
| addCounter(REGISTER_SHUFFLE_COUNT) | ||
| addCounter(REGISTER_SHUFFLE_FAIL_COUNT) | ||
| addCounter(UNREGISTER_SHUFFLE_COUNT) | ||
| addCounter(REVIVE_REQUEST_COUNT) | ||
| addCounter(REVIVE_FAIL_COUNT) | ||
| addCounter(SLOT_RESERVATION_FAIL_COUNT) | ||
| addCounter(SHUFFLE_FETCH_FAILURE_COUNT) | ||
| addCounter(SHUFFLE_DATA_LOST_COUNT) | ||
|
|
||
| def getMetricsSnapshot(): Map[String, ClientMetric] = { | ||
| // Counters: compute delta since last snapshot | ||
| val counterMetrics = counters().flatMap { c => | ||
| val current = c.counter.getCount | ||
| val prev = Option(counterPrev.put(c.name, current)).map(_.longValue()).getOrElse(0L) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Counter deltas are lost when a heartbeat fails to send. (The symmetric hazard — advancing only on success — would double-count the timeout-but-actually-applied case, so a fully correct fix needs an ack/idempotency key. At least worth a comment acknowledging the at-most-once semantics, or carrying-forward the un-acked delta into the next snapshot.) |
||
| val delta = current - prev | ||
| if (delta > 0) Some(c.name -> ClientMetric(delta, MetricType.Counter)) | ||
| else None | ||
| } | ||
| // Gauges: send the latest value as-is. | ||
| val gaugeMetrics = gauges().map(g => | ||
| g.name -> ClientMetric(g.gauge.getValue.asInstanceOf[Number].longValue(), MetricType.Gauge)) | ||
| (counterMetrics ++ gaugeMetrics).toMap | ||
| } | ||
|
|
||
| def start(): Unit = startCleaner() | ||
|
|
||
| def stop(): Unit = metricsCleaner.shutdown() | ||
| } | ||
|
|
||
| object CelebornClientSource { | ||
| val EXCLUDED_WORKER_COUNT = "ClientExcludedWorkerCount" | ||
| val SHUTTING_WORKER_COUNT = "ClientShuttingWorkerCount" | ||
| val ACTIVE_SHUFFLE_COUNT = "ClientActiveShuffleCount" | ||
| val REGISTER_SHUFFLE_COUNT = "ClientRegisterShuffleCount" | ||
| val REGISTER_SHUFFLE_FAIL_COUNT = "ClientRegisterShuffleFailCount" | ||
| val UNREGISTER_SHUFFLE_COUNT = "ClientUnregisterShuffleCount" | ||
| val REVIVE_REQUEST_COUNT = "ClientReviveRequestCount" | ||
| val REVIVE_FAIL_COUNT = "ClientReviveFailCount" | ||
| val SLOT_RESERVATION_FAIL_COUNT = "ClientSlotReservationFailCount" | ||
| val SHUFFLE_FETCH_FAILURE_COUNT = "ClientShuffleFetchFailureCount" | ||
| val SHUFFLE_DATA_LOST_COUNT = "ClientShuffleDataLostCount" | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| /* | ||
| * 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.celeborn.client | ||
|
|
||
| import java.util.concurrent.atomic.AtomicInteger | ||
|
|
||
| import org.apache.celeborn.CelebornFunSuite | ||
| import org.apache.celeborn.common.CelebornConf | ||
| import org.apache.celeborn.common.metrics.MetricType | ||
|
|
||
| class CelebornClientSourceSuite extends CelebornFunSuite { | ||
|
|
||
| test("counters are declared, increment, and emit with role=Client") { | ||
| val source = new CelebornClientSource(new CelebornConf()) | ||
|
|
||
| source.incCounter(CelebornClientSource.REGISTER_SHUFFLE_COUNT) | ||
| source.incCounter(CelebornClientSource.REGISTER_SHUFFLE_COUNT) | ||
| source.incCounter(CelebornClientSource.REGISTER_SHUFFLE_FAIL_COUNT) | ||
| source.incCounter(CelebornClientSource.UNREGISTER_SHUFFLE_COUNT, 3) | ||
| source.incCounter(CelebornClientSource.REVIVE_REQUEST_COUNT, 5) | ||
| source.incCounter(CelebornClientSource.REVIVE_FAIL_COUNT, 2) | ||
| source.incCounter(CelebornClientSource.SLOT_RESERVATION_FAIL_COUNT) | ||
| source.incCounter(CelebornClientSource.SHUFFLE_FETCH_FAILURE_COUNT) | ||
| source.incCounter(CelebornClientSource.SHUFFLE_DATA_LOST_COUNT) | ||
|
|
||
| val metrics = source.getMetrics | ||
| assert(metrics.contains("""metrics_ClientRegisterShuffleCount_Count""")) | ||
| assert(metrics.contains("""role="Client"""")) | ||
|
|
||
| val snapshot = source.getMetricsSnapshot() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The delta semantics — the whole point of |
||
| assert(snapshot(CelebornClientSource.REGISTER_SHUFFLE_COUNT).value == 2) | ||
| assert(snapshot(CelebornClientSource.REGISTER_SHUFFLE_COUNT).metricType == MetricType.Counter) | ||
| assert(snapshot(CelebornClientSource.REGISTER_SHUFFLE_FAIL_COUNT).value == 1) | ||
| assert(snapshot(CelebornClientSource.UNREGISTER_SHUFFLE_COUNT).value == 3) | ||
| assert(snapshot(CelebornClientSource.REVIVE_REQUEST_COUNT).value == 5) | ||
| assert(snapshot(CelebornClientSource.REVIVE_FAIL_COUNT).value == 2) | ||
| assert(snapshot(CelebornClientSource.SLOT_RESERVATION_FAIL_COUNT).value == 1) | ||
| assert(snapshot(CelebornClientSource.SHUFFLE_FETCH_FAILURE_COUNT).value == 1) | ||
| assert(snapshot(CelebornClientSource.SHUFFLE_DATA_LOST_COUNT).value == 1) | ||
| } | ||
|
|
||
| test("gauges registered on the source are reflected in metrics and snapshot") { | ||
| val source = new CelebornClientSource(new CelebornConf()) | ||
| val excluded = new AtomicInteger(0) | ||
|
|
||
| source.addGauge(CelebornClientSource.EXCLUDED_WORKER_COUNT) { () => excluded.get() } | ||
|
|
||
| assert(source.getMetricsSnapshot()(CelebornClientSource.EXCLUDED_WORKER_COUNT).value == 0) | ||
|
|
||
| excluded.set(5) | ||
| val metrics = source.getMetrics | ||
| assert(metrics.contains("metrics_ClientExcludedWorkerCount_Value")) | ||
| val snapshot = source.getMetricsSnapshot() | ||
| assert(snapshot(CelebornClientSource.EXCLUDED_WORKER_COUNT).value == 5) | ||
| assert(snapshot(CelebornClientSource.EXCLUDED_WORKER_COUNT).metricType == MetricType.Gauge) | ||
| } | ||
|
|
||
| test("getMetricsSnapshot includes both counters and gauges with correct types") { | ||
| val source = new CelebornClientSource(new CelebornConf()) | ||
| source.addGauge(CelebornClientSource.ACTIVE_SHUFFLE_COUNT) { () => 7 } | ||
| source.incCounter(CelebornClientSource.REGISTER_SHUFFLE_COUNT) | ||
|
|
||
| val snapshot = source.getMetricsSnapshot() | ||
| assert(snapshot.contains(CelebornClientSource.REGISTER_SHUFFLE_COUNT)) | ||
| assert(snapshot(CelebornClientSource.REGISTER_SHUFFLE_COUNT).value == 1) | ||
| assert(snapshot(CelebornClientSource.REGISTER_SHUFFLE_COUNT).metricType == MetricType.Counter) | ||
| assert(snapshot(CelebornClientSource.ACTIVE_SHUFFLE_COUNT).value == 7) | ||
| assert(snapshot(CelebornClientSource.ACTIVE_SHUFFLE_COUNT).metricType == MetricType.Gauge) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ import scala.collection.mutable.ArrayBuffer | |
| import org.junit.Assert | ||
|
|
||
| import org.apache.celeborn.CelebornFunSuite | ||
| import org.apache.celeborn.client.LifecycleManager.ShuffleFailedWorkers | ||
| import org.apache.celeborn.common.CelebornConf | ||
| import org.apache.celeborn.common.CelebornConf.{CLIENT_EXCLUDED_WORKER_EXPIRE_TIMEOUT, CLIENT_SHUFFLE_DYNAMIC_RESOURCE_ENABLED} | ||
| import org.apache.celeborn.common.meta.WorkerInfo | ||
|
|
@@ -159,6 +160,31 @@ class WorkerStatusTrackerSuite extends CelebornFunSuite { | |
| errors.get()) | ||
| } | ||
|
|
||
| test("recordWorkerFailure updates client worker-excluded gauge") { | ||
| val celebornConf = new CelebornConf() | ||
| celebornConf.set(CelebornConf.METRICS_ENABLED.key, "true") | ||
| celebornConf.set(CelebornConf.CLIENT_METRICS_ENABLED.key, "true") | ||
| val lifecycleManager = new LifecycleManager("app-metrics-test", celebornConf) | ||
| try { | ||
| val statusTracker = lifecycleManager.workerStatusTracker | ||
| val source = lifecycleManager.clientSource.get | ||
|
|
||
| val failed = new ShuffleFailedWorkers() | ||
| val now = System.currentTimeMillis() | ||
| failed.put(mock("host1"), (StatusCode.WORKER_UNRESPONSIVE, now)) | ||
| failed.put(mock("host2"), (StatusCode.WORKER_UNRESPONSIVE, now)) | ||
| statusTracker.recordWorkerFailure(failed) | ||
|
|
||
| val snapshot = source.getMetricsSnapshot() | ||
| Assert.assertEquals(2L, snapshot(CelebornClientSource.EXCLUDED_WORKER_COUNT).value) | ||
|
|
||
| // re-recording already-excluded workers does not change the gauge | ||
| statusTracker.recordWorkerFailure(failed) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dead comment / missing assertion, and this is an integration test in a unit suite. The Separately, |
||
| } finally { | ||
| lifecycleManager.stop() | ||
| } | ||
| } | ||
|
|
||
| private def buildResponse( | ||
| excludedWorkerHosts: Array[String], | ||
| unknownWorkerHosts: Array[String], | ||
|
|
||
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.
Silent no-op unless
celeborn.client.metrics.appLabelsis set. The client only sends metrics whenappMetricLabelsis non-empty, and the master'supdateApplicationMetricsearly-returns whenmetricLabels.isEmpty. So an operator who turns on the two obvious switches —celeborn.client.metrics.enabled=trueandceleborn.metrics.master.clientMetrics.enabled=true— but leavesappLabelsat its default (empty) gets zero metrics and zero log output. Neither enable-flag's doc mentions thatappLabelsis mandatory.At minimum, log a one-time
warnon the client when metrics are enabled butappLabelsis empty. Better: don't gate emission on labels at all — emit with justrole/instanceso the default enablement path produces something.