Copilot commented on code in PR #3714: URL: https://github.com/apache/celeborn/pull/3714#discussion_r3340898536
########## master/src/test/scala/org/apache/celeborn/service/deploy/master/MasterSourceSuite.scala: ########## @@ -0,0 +1,42 @@ +/* + * 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.service.deploy.master + +import org.apache.celeborn.CelebornFunSuite +import org.apache.celeborn.common.CelebornConf +import org.apache.celeborn.common.protocol.message.StatusCode + +class MasterSourceSuite extends CelebornFunSuite { + + test("test request slots failed metrics") { + val conf = new CelebornConf() + conf.set(CelebornConf.METRICS_EXTRA_LABELS.key, "status=prod") + val source = new MasterSource(conf) + + source.incRequestSlotsFailed(StatusCode.SLOT_NOT_AVAILABLE) + source.incRequestSlotsFailed(StatusCode.WORKER_EXCLUDED) + + val metrics = source.getMetrics + assert(metrics.contains( + """metrics_RequestSlotsFailed_Count{instance=""")) Review Comment: The test currently asserts `instance=""`, but `AbstractSource` always populates the master `instance` label as `host:port`, so this assertion will fail in normal test environments. Use the actual instance label from the created `MasterSource` (or avoid asserting an empty instance value). ########## master/src/main/scala/org/apache/celeborn/service/deploy/master/MasterSource.scala: ########## @@ -19,19 +19,29 @@ package org.apache.celeborn.service.deploy.master import org.apache.celeborn.common.CelebornConf import org.apache.celeborn.common.metrics.source.{AbstractSource, Role} +import org.apache.celeborn.common.protocol.message.StatusCode class MasterSource(conf: CelebornConf) extends AbstractSource(conf, Role.MASTER) { override val sourceName = "master" import MasterSource._ + RequestSlotsFailureStatuses.foreach { status => + addCounter(REQUEST_SLOTS_FAILED_COUNT, Map(STATUS_LABEL -> status.name())) + } // add timers addTimer(OFFER_SLOTS_TIME) addTimer(UPDATE_RESOURCE_CONSUMPTION_TIME) // start cleaner startCleaner() + + def incRequestSlotsFailed(status: StatusCode): Unit = { + incCounter(REQUEST_SLOTS_FAILED_COUNT, 1, Map(STATUS_LABEL -> status.name())) + } Review Comment: `incRequestSlotsFailed` accepts any `StatusCode`, but only two status values are pre-registered. Calling this method with any other status will repeatedly log "Metric ... not found" warnings and makes it unclear which statuses are intended to be tracked. Consider explicitly ignoring (or rejecting) untracked statuses so the `status` label stays bounded and logs stay clean. -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
