michaeljmarshall commented on a change in pull request #10208: URL: https://github.com/apache/pulsar/pull/10208#discussion_r612166953
########## File path: pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/stats/FunctionCollectorRegistryImpl.java ########## @@ -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.pulsar.functions.instance.stats; + +import io.prometheus.client.Collector; + +import java.util.HashMap; +import java.util.Map; + +public class FunctionCollectorRegistryImpl extends FunctionCollectorRegistry { + + private final Map<String, Collector> namesToCollectors = new HashMap<String, Collector>(); Review comment: Nit. I think it might be more efficient to use a `ConcurrentHashMap` for this map, given that the map is accessed from several threads. Then, use `computeIfAbsent` in the `registerIfNotExist` method instead of using `synchronized`. ########## File path: pulsar-functions/localrun/src/main/java/org/apache/pulsar/functions/LocalRunner.java ########## @@ -171,7 +172,7 @@ public RuntimeEnv convert(String value) { protected String secretsProviderClassName; @Parameter(names = "--secretsProviderConfig", description = "Whats the config for the secrets provider", hidden = true) protected String secretsProviderConfig; - @Parameter(names = "--metricsPortStart", description = "The starting port range for metrics server", hidden = true) + @Parameter(names = "--metricsPortStart", description = "The starting port range for metrics server. When running instances as threads, one metrics server is used to host the stats for all instances.", hidden = true) Review comment: Does this need to be a range because every instance thread expects a `metricsPort`? I see that in `startProcessMode` we use a range but in `startThreadedMode` we use a single value. Further, I see that we're only using `metricsPortStart` when starting the metrics server. -- 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: [email protected]
