Skip to content

Commit

Permalink
Merge pull request kserve#1 from kserve/main
Browse files Browse the repository at this point in the history
Upstream Sync November 8th 2022
  • Loading branch information
anishasthana authored Nov 8, 2022
2 parents 820fa86 + 1c2de08 commit e4cf146
Show file tree
Hide file tree
Showing 20 changed files with 1,284 additions and 118 deletions.
10 changes: 4 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4 as build_base
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.6 as build_base

ARG ETCD_VERSION=v3.5.4

Expand All @@ -28,9 +28,7 @@ RUN true \
&& sed -i 's:#security.provider.1=SunPKCS11 ${java.home}/lib/security/nss.cfg:security.provider.12=SunPKCS11 ${java.home}/lib/security/nss.cfg:g' /usr/lib/jvm/java-17-openjdk-*/conf/security/java.security \
&& true

RUN microdnf install wget tar \
gzip vim-common python39 maven && \
pip3 install -U pip setuptools
RUN microdnf install wget tar gzip maven

ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk

Expand Down Expand Up @@ -59,7 +57,7 @@ ENV MAVEN_OPTS="-Dfile.encoding=UTF8"
RUN mvn -B package -DskipTests=true --file pom.xml

###############################################################################
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.6

ARG imageVersion
ARG buildId
Expand Down Expand Up @@ -91,7 +89,7 @@ COPY --from=build /build/target/dockerhome/ /opt/kserve/mmesh/
# Make this the current directory when starting the container
WORKDIR /opt/kserve/mmesh

RUN microdnf install shadow-utils hostname python39 && \
RUN microdnf install shadow-utils hostname && \
# Create app user
useradd -c "Application User" -U -u ${USER} -m app && \
chown -R app:0 /home/app && \
Expand Down
31 changes: 16 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,25 @@
<!--suppress UnresolvedMavenProperty -->
<jenkins-build-tag>${env.BUILD_TAG}</jenkins-build-tag> <!-- set by jenkins -->

<grpc-version>1.49.0</grpc-version>
<netty-version>4.1.80.Final</netty-version>
<grpc-version>1.50.2</grpc-version>
<netty-version>4.1.84.Final</netty-version>
<litelinks-version>1.7.2</litelinks-version>
<kv-utils-version>0.5.1</kv-utils-version>
<etcd-java-version>0.0.21</etcd-java-version>
<protobuf-version>3.21.5</protobuf-version>
<annotation-version>9.0.65</annotation-version>
<etcd-java-version>0.0.22</etcd-java-version>
<protobuf-version>3.21.9</protobuf-version>
<annotation-version>9.0.68</annotation-version>
<guava-version>31.1-jre</guava-version>
<jackson-databind-version>2.13.3</jackson-databind-version>
<gson-version>2.9.1</gson-version>
<jackson-databind-version>2.13.4.2</jackson-databind-version>
<gson-version>2.10</gson-version>
<thrift-version>0.16.0</thrift-version>
<eclipse-collections-version>11.1.0</eclipse-collections-version>
<log4j2-version>2.18.0</log4j2-version>
<log4j2-version>2.19.0</log4j2-version>
<slf4j-version>1.7.36</slf4j-version>
<!-- Care must be taken when updating the prometheus client lib version
since we have some custom optimized extensions to this -->
<prometheus-version>0.9.0</prometheus-version>
<bouncycastle-version>1.70</bouncycastle-version>
<junit-version>5.9.0</junit-version>
<junit-version>5.9.1</junit-version>

<dockerhome>${project.build.directory}/dockerhome</dockerhome>
<skipTests>false</skipTests>
Expand Down Expand Up @@ -328,12 +329,6 @@
<artifactId>simpleclient_common</artifactId>
<version>${prometheus-version}</version>
</dependency>
<!-- Prometheus metrics Hotspot JVM metrics-->
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_hotspot</artifactId>
<version>${prometheus-version}</version>
</dependency>

<dependency>
<!-- used only for int list, dep can easily be removed if necessary -->
Expand Down Expand Up @@ -516,6 +511,12 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<!-- override litelinks' version with latest -->
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
<version>${thrift-version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
56 changes: 55 additions & 1 deletion src/main/java/com/ibm/watson/modelmesh/Metrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@
import com.ibm.watson.prometheus.Counter;
import com.ibm.watson.prometheus.Gauge;
import com.ibm.watson.prometheus.Histogram;
import com.ibm.watson.prometheus.NettyMemoryExports;
import com.ibm.watson.prometheus.NettyServer;
import com.ibm.watson.prometheus.SimpleCollector;
import com.ibm.watson.prometheus.hotspot.BufferPoolsExports;
import com.ibm.watson.prometheus.hotspot.GarbageCollectorExports;
import com.ibm.watson.prometheus.hotspot.MemoryAllocationExports;
import com.ibm.watson.prometheus.hotspot.MemoryPoolsExports;
import com.ibm.watson.statsd.NonBlockingStatsDClient;
import com.ibm.watson.statsd.StatsDSender;
import com.timgroup.statsd.StatsDClient;
Expand All @@ -36,8 +41,10 @@
import java.util.Collections;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -152,6 +159,7 @@ public PrometheusMetrics(Map<String, String> params) throws Exception {
int port = 2112;
boolean shortNames = true;
boolean https = true;
String memMetrics = "all"; // default to all
for (Entry<String, String> ent : params.entrySet()) {
switch (ent.getKey()) {
case "port":
Expand All @@ -172,6 +180,9 @@ public PrometheusMetrics(Map<String, String> params) throws Exception {
+ " (must be either http or https)");
}
break;
case "mem_detail":
memMetrics = ent.getValue();
break;
default:
throw new Exception("Unrecognized metrics config parameter: " + ent.getKey());
}
Expand Down Expand Up @@ -222,8 +233,51 @@ public PrometheusMetrics(Map<String, String> params) throws Exception {
this.metricServer = new NettyServer(registry, port, https);
this.shortNames = shortNames;

logger.info("Will expose " + (https ? "https" : "http") + " Sysdig Prometheus metrics on port " + port
logger.info("Will expose " + (https ? "https" : "http") + " Prometheus metrics on port " + port
+ " using " + (shortNames ? "short" : "fully-qualified") + " method names");

if (memMetrics != null) {
registerMemoryExporters(registry, memMetrics);
}
}

private static void registerMemoryExporters(CollectorRegistry registry, String value) {
if ("none".equals(value)) {
return;
}
if ("all".equals(value)) {
value = "netty,gc,bp,mp,ma";
}
Set<String> allTypes = new HashSet<>(), validTypes = new HashSet<>();
for (String type : value.split(",")) {
allTypes.add(type.trim());
}
if (allTypes.remove("netty")) {
new NettyMemoryExports().register(registry);
validTypes.add("netty");
}
if (allTypes.remove("gc")) {
new GarbageCollectorExports().register(registry);
validTypes.add("gc");
}
if (allTypes.remove("bp")) {
new BufferPoolsExports().register(registry);
validTypes.add("bp");
}
if (allTypes.remove("ma")) {
new MemoryAllocationExports().register(registry);
validTypes.add("ma");
}
if (allTypes.remove("mp")) {
new MemoryPoolsExports().register(registry);
validTypes.add("mp");
}
if (!allTypes.isEmpty()) {
logger.warn("Unrecognized memory detail metric type(s) specified: " + allTypes);
}
if (!validTypes.isEmpty()) {
logger.info("Detailed memory usage metrics will be exposed: " + validTypes);
}
}

@Override
Expand Down
Loading

0 comments on commit e4cf146

Please sign in to comment.