You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2022/12/18 13:19:49 UTC
[shardingsphere] branch master updated: Refactor PrometheusPluginBootService (#22953)
This is an automated email from the ASF dual-hosted git repository.
panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 7a5123ca7b7 Refactor PrometheusPluginBootService (#22953)
7a5123ca7b7 is described below
commit 7a5123ca7b7d66f9e15faf14bacf77e246508748
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sun Dec 18 21:19:42 2022 +0800
Refactor PrometheusPluginBootService (#22953)
---
.../RemotePluginConfigurationValidator.java | 23 +++++++++++-
.../agent/core/transformer/AgentTransformer.java | 4 +-
.../RemotePluginConfigurationValidatorTest.java | 16 ++++----
.../agent/metrics/core/util/MetricsUtil.java | 43 ----------------------
.../prometheus/PrometheusPluginBootService.java | 17 +++++----
.../prometheus/collector/BuildInfoCollector.java | 10 ++---
.../collector/MetaDataInfoCollector.java | 9 ++---
.../prometheus/collector/ProxyInfoCollector.java | 13 +++----
.../jaeger/JaegerTracingPluginBootService.java | 2 +-
.../zipkin/ZipkinTracingPluginBootService.java | 2 +-
10 files changed, 53 insertions(+), 86 deletions(-)
diff --git a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/config/validator/RemotePluginConfigurationValidator.java b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/config/validator/RemotePluginConfigurationValidator.java
index d4575f76a41..61e86c328f8 100644
--- a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/config/validator/RemotePluginConfigurationValidator.java
+++ b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/config/validator/RemotePluginConfigurationValidator.java
@@ -30,13 +30,32 @@ import org.apache.shardingsphere.agent.config.plugin.PluginConfiguration;
public final class RemotePluginConfigurationValidator {
/**
- * Validate remote plugin configuration.
+ * Validate host and port.
*
* @param type plugin type
* @param pluginConfig to be validated plugin configuration
*/
- public static void validate(final String type, final PluginConfiguration pluginConfig) {
+ public static void validateHostAndPort(final String type, final PluginConfiguration pluginConfig) {
+ validateHost(type, pluginConfig);
+ validatePort(type, pluginConfig);
+ }
+
+ /**
+ * Validate host.
+ *
+ * @param type plugin type
+ * @param pluginConfig to be validated plugin configuration
+ */
+ public static void validateHost(final String type, final PluginConfiguration pluginConfig) {
Preconditions.checkArgument(!Strings.isNullOrEmpty(pluginConfig.getHost()), "Hostname of %s is required.", type);
+ }
+
+ /**
+ * Validate port.
+ * @param type plugin type
+ * @param pluginConfig to be validated plugin configuration
+ */
+ public static void validatePort(final String type, final PluginConfiguration pluginConfig) {
Preconditions.checkArgument(pluginConfig.getPort() > 0, "Port `%s` of %s must be a positive number.", pluginConfig.getPort(), type);
}
}
diff --git a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/transformer/AgentTransformer.java b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/transformer/AgentTransformer.java
index 6f5bd5efe7e..988e56119ff 100644
--- a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/transformer/AgentTransformer.java
+++ b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/transformer/AgentTransformer.java
@@ -51,7 +51,7 @@ public final class AgentTransformer implements Transformer {
private final Map<String, AdvisorConfiguration> advisorConfigs;
- private final boolean enhanceProxy;
+ private final boolean isEnhancedForProxy;
@SuppressWarnings("NullableProblems")
@Override
@@ -61,7 +61,7 @@ public final class AgentTransformer implements Transformer {
}
Builder<?> result = builder.defineField(EXTRA_DATA, Object.class, Opcodes.ACC_PRIVATE | Opcodes.ACC_VOLATILE).implement(TargetAdviceObject.class).intercept(FieldAccessor.ofField(EXTRA_DATA));
AdvisorConfiguration advisorConfig = advisorConfigs.get(typeDescription.getTypeName());
- AdviceFactory adviceFactory = new AdviceFactory(classLoader, pluginConfigs, pluginJars, enhanceProxy);
+ AdviceFactory adviceFactory = new AdviceFactory(classLoader, pluginConfigs, pluginJars, isEnhancedForProxy);
result = new MethodAdvisorBuildEngine(advisorConfig.getConstructorAdvisors(), typeDescription).create(result, new ConstructorAdvisorBuilder(adviceFactory));
result = new MethodAdvisorBuildEngine(advisorConfig.getInstanceMethodAdvisors(), typeDescription).create(result, new InstanceMethodAdvisorBuilder(adviceFactory));
result = new MethodAdvisorBuildEngine(advisorConfig.getStaticMethodAdvisors(), typeDescription).create(result, new StaticMethodAdvisorBuilder(adviceFactory));
diff --git a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/config/validator/RemotePluginConfigurationValidatorTest.java b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/config/validator/RemotePluginConfigurationValidatorTest.java
index f417fdbe8f5..d1eb97b5981 100644
--- a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/config/validator/RemotePluginConfigurationValidatorTest.java
+++ b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/config/validator/RemotePluginConfigurationValidatorTest.java
@@ -25,25 +25,25 @@ import static org.junit.Assert.assertThrows;
public final class RemotePluginConfigurationValidatorTest {
@Test
- public void assertValidateSuccess() {
- RemotePluginConfigurationValidator.validate("foo_type", new PluginConfiguration("localhost", 8080, "pwd", null));
+ public void assertValidateHostAndPortSuccess() {
+ RemotePluginConfigurationValidator.validateHostAndPort("foo_type", new PluginConfiguration("localhost", 8080, "pwd", null));
}
@Test
- public void assertValidateWhenHostIsEmpty() {
+ public void assertValidateHostAndPortWhenHostIsEmpty() {
assertThrows("Hostname of foo_type is required", IllegalArgumentException.class,
- () -> RemotePluginConfigurationValidator.validate("foo_type", new PluginConfiguration("", 8080, "pwd", null)));
+ () -> RemotePluginConfigurationValidator.validateHostAndPort("foo_type", new PluginConfiguration("", 8080, "pwd", null)));
}
@Test
- public void assertValidateWhenHostIsNull() {
+ public void assertValidateHostAndPortWhenHostIsNull() {
assertThrows("Hostname of foo_type is required", IllegalArgumentException.class,
- () -> RemotePluginConfigurationValidator.validate("foo_type", new PluginConfiguration(null, 8080, "pwd", null)));
+ () -> RemotePluginConfigurationValidator.validateHostAndPort("foo_type", new PluginConfiguration(null, 8080, "pwd", null)));
}
@Test
- public void assertValidateWhenPortLessThanOne() {
+ public void assertValidateHostAndPortWhenPortLessThanOne() {
assertThrows("Port `0` of foo_host must be a positive number", IllegalArgumentException.class,
- () -> RemotePluginConfigurationValidator.validate("foo_type", new PluginConfiguration("localhost", 0, "pwd", null)));
+ () -> RemotePluginConfigurationValidator.validateHostAndPort("foo_type", new PluginConfiguration("localhost", 0, "pwd", null)));
}
}
diff --git a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/metrics/core/util/MetricsUtil.java b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/metrics/core/util/MetricsUtil.java
deleted file mode 100644
index a4a60375936..00000000000
--- a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/metrics/core/util/MetricsUtil.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.shardingsphere.agent.metrics.core.util;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-
-/**
- * Metrics Utility.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class MetricsUtil {
-
- /**
- * Check whether class existed.
- *
- * @param className class name
- * @return class existed or not
- */
- public static boolean isClassExisted(final String className) {
- try {
- Class.forName(className);
- } catch (final ClassNotFoundException ex) {
- return false;
- }
- return true;
- }
-}
diff --git a/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/metrics/prometheus/PrometheusPluginBootService.java b/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/metrics/prometheus/PrometheusPluginBootService.java
index 0d7ed761f04..a3d37d52433 100644
--- a/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/metrics/prometheus/PrometheusPluginBootService.java
+++ b/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/metrics/prometheus/PrometheusPluginBootService.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.agent.metrics.prometheus;
+import com.google.common.base.Strings;
import io.prometheus.client.CollectorRegistry;
import io.prometheus.client.exporter.HTTPServer;
import io.prometheus.client.hotspot.DefaultExports;
@@ -45,35 +46,35 @@ public final class PrometheusPluginBootService implements PluginBootService {
@Override
public void start(final PluginConfiguration pluginConfig, final boolean isEnhancedForProxy) {
- RemotePluginConfigurationValidator.validate(getType(), pluginConfig);
+ RemotePluginConfigurationValidator.validatePort(getType(), pluginConfig);
startServer(pluginConfig, isEnhancedForProxy);
MetricsPool.setMetricsFactory(new PrometheusWrapperFactory());
}
private void startServer(final PluginConfiguration pluginConfig, final boolean isEnhancedForProxy) {
registerCollector(Boolean.parseBoolean(pluginConfig.getProps().getProperty(KEY_JVM_INFORMATION_COLLECTOR_ENABLED)), isEnhancedForProxy);
- InetSocketAddress socketAddress = getSocketAddress(pluginConfig.getHost(), pluginConfig.getPort());
+ InetSocketAddress socketAddress = getSocketAddress(pluginConfig);
try {
httpServer = new HTTPServer(socketAddress, CollectorRegistry.defaultRegistry, true);
- log.info("Prometheus metrics HTTP server `{}:{}` start success", socketAddress.getHostString(), socketAddress.getPort());
+ log.info("Prometheus metrics HTTP server `{}:{}` start success.", socketAddress.getHostString(), socketAddress.getPort());
} catch (final IOException ex) {
- log.error("Prometheus metrics HTTP server start fail", ex);
+ log.error("Prometheus metrics HTTP server start fail.", ex);
}
}
- private void registerCollector(final boolean isCollectJVMInformation, final boolean isEnhancedForProxy) {
+ private void registerCollector(final boolean isJVMInformationCollection, final boolean isEnhancedForProxy) {
new BuildInfoCollector(isEnhancedForProxy).register();
if (isEnhancedForProxy) {
new ProxyInfoCollector().register();
new MetaDataInfoCollector().register();
}
- if (isCollectJVMInformation) {
+ if (isJVMInformationCollection) {
DefaultExports.initialize();
}
}
- private InetSocketAddress getSocketAddress(final String host, final int port) {
- return null == host || "".equals(host) ? new InetSocketAddress(port) : new InetSocketAddress(host, port);
+ private InetSocketAddress getSocketAddress(final PluginConfiguration pluginConfig) {
+ return Strings.isNullOrEmpty(pluginConfig.getHost()) ? new InetSocketAddress(pluginConfig.getPort()) : new InetSocketAddress(pluginConfig.getHost(), pluginConfig.getPort());
}
@Override
diff --git a/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/metrics/prometheus/collector/BuildInfoCollector.java b/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/metrics/prometheus/collector/BuildInfoCollector.java
index 4bf18bce74d..f1015b5c8d8 100644
--- a/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/metrics/prometheus/collector/BuildInfoCollector.java
+++ b/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/metrics/prometheus/collector/BuildInfoCollector.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.agent.metrics.prometheus.collector;
import io.prometheus.client.Collector;
import io.prometheus.client.GaugeMetricFamily;
import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
+import lombok.SneakyThrows;
import org.apache.shardingsphere.agent.metrics.core.constant.MetricIds;
import org.apache.shardingsphere.agent.metrics.prometheus.wrapper.PrometheusWrapperFactory;
@@ -33,7 +33,6 @@ import java.util.Optional;
* Build information collector.
*/
@RequiredArgsConstructor
-@Slf4j
public final class BuildInfoCollector extends Collector {
private static final String PROXY_BOOTSTRAP_CLASS = "org.apache.shardingsphere.proxy.Bootstrap";
@@ -42,6 +41,7 @@ public final class BuildInfoCollector extends Collector {
private final boolean isEnhancedForProxy;
+ @SneakyThrows(ClassNotFoundException.class)
@Override
public List<MetricFamilySamples> collect() {
Optional<GaugeMetricFamily> artifactInfo = FACTORY.createGaugeMetricFamily(MetricIds.BUILD_INFO);
@@ -50,11 +50,7 @@ public final class BuildInfoCollector extends Collector {
}
addMetric(artifactInfo.get(), getClass().getPackage());
if (isEnhancedForProxy) {
- try {
- addMetric(artifactInfo.get(), Class.forName(PROXY_BOOTSTRAP_CLASS).getPackage());
- } catch (final ClassNotFoundException ignored) {
- log.warn("No proxy class found");
- }
+ addMetric(artifactInfo.get(), Class.forName(PROXY_BOOTSTRAP_CLASS).getPackage());
}
return Collections.singletonList(artifactInfo.get());
}
diff --git a/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/metrics/prometheus/collector/MetaDataInfoCollector.java b/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/metrics/prometheus/collector/MetaDataInfoCollector.java
index 3a47738e21f..c55105a0631 100644
--- a/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/metrics/prometheus/collector/MetaDataInfoCollector.java
+++ b/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/metrics/prometheus/collector/MetaDataInfoCollector.java
@@ -21,7 +21,6 @@ import io.prometheus.client.Collector;
import io.prometheus.client.GaugeMetricFamily;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.agent.metrics.core.constant.MetricIds;
-import org.apache.shardingsphere.agent.metrics.core.util.MetricsUtil;
import org.apache.shardingsphere.agent.metrics.prometheus.wrapper.PrometheusWrapperFactory;
import org.apache.shardingsphere.infra.datasource.props.DataSourcePropertiesCreator;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -48,15 +47,13 @@ public final class MetaDataInfoCollector extends Collector {
private static final String ACTUAL_DB_COUNT = "database_count";
- private static final String PROXY_CONTEXT_CLASS = "org.apache.shardingsphere.proxy.backend.context.ProxyContext";
-
private static final PrometheusWrapperFactory FACTORY = new PrometheusWrapperFactory();
@Override
public List<MetricFamilySamples> collect() {
List<MetricFamilySamples> result = new LinkedList<>();
Optional<GaugeMetricFamily> metaDataInfo = FACTORY.createGaugeMetricFamily(MetricIds.METADATA_INFO);
- if (null != ProxyContext.getInstance().getContextManager() && metaDataInfo.isPresent() && MetricsUtil.isClassExisted(PROXY_CONTEXT_CLASS)) {
+ if (null != ProxyContext.getInstance().getContextManager() && metaDataInfo.isPresent()) {
collectProxy(metaDataInfo.get());
result.add(metaDataInfo.get());
}
@@ -88,7 +85,7 @@ public final class MetaDataInfoCollector extends Collector {
private Optional<String> getDatabaseName(final DataSource dataSource) {
Object jdbcUrl = DataSourcePropertiesCreator.create(dataSource).getAllStandardProperties().get("url");
if (null == jdbcUrl) {
- log.info("Can not get JDBC URL");
+ log.info("Can not get JDBC URL.");
return Optional.empty();
}
try {
@@ -97,7 +94,7 @@ public final class MetaDataInfoCollector extends Collector {
return Optional.of(uri.getPath());
}
} catch (final URISyntaxException | NullPointerException ignored) {
- log.info("Unsupported JDBC URL by URI: {}", jdbcUrl);
+ log.info("Unsupported JDBC URL by URI: {}.", jdbcUrl);
}
return Optional.empty();
}
diff --git a/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/metrics/prometheus/collector/ProxyInfoCollector.java b/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/metrics/prometheus/collector/ProxyInfoCollector.java
index d73218f8423..e8e781a0192 100644
--- a/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/metrics/prometheus/collector/ProxyInfoCollector.java
+++ b/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/metrics/prometheus/collector/ProxyInfoCollector.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.agent.metrics.prometheus.collector;
import io.prometheus.client.Collector;
import io.prometheus.client.GaugeMetricFamily;
import org.apache.shardingsphere.agent.metrics.core.constant.MetricIds;
-import org.apache.shardingsphere.agent.metrics.core.util.MetricsUtil;
import org.apache.shardingsphere.agent.metrics.prometheus.wrapper.PrometheusWrapperFactory;
import org.apache.shardingsphere.infra.state.StateContext;
import org.apache.shardingsphere.infra.state.StateType;
@@ -39,20 +38,18 @@ public final class ProxyInfoCollector extends Collector {
private static final String PROXY_STATE = "state";
- private static final String PROXY_CLASS = "org.apache.shardingsphere.proxy.backend.context.ProxyContext";
-
private static final PrometheusWrapperFactory FACTORY = new PrometheusWrapperFactory();
- private static final ConcurrentHashMap<StateType, Integer> PROXY_STATE_MAP = new ConcurrentHashMap<>();
+ private static final ConcurrentHashMap<StateType, Integer> PROXY_STATES = new ConcurrentHashMap<>();
static {
- PROXY_STATE_MAP.put(StateType.OK, 1);
- PROXY_STATE_MAP.put(StateType.CIRCUIT_BREAK, 2);
+ PROXY_STATES.put(StateType.OK, 1);
+ PROXY_STATES.put(StateType.CIRCUIT_BREAK, 2);
}
@Override
public List<MetricFamilySamples> collect() {
- if (!MetricsUtil.isClassExisted(PROXY_CLASS) || null == ProxyContext.getInstance().getContextManager()) {
+ if (null == ProxyContext.getInstance().getContextManager()) {
return Collections.emptyList();
}
Optional<GaugeMetricFamily> proxyInfo = FACTORY.createGaugeMetricFamily(MetricIds.PROXY_INFO);
@@ -61,7 +58,7 @@ public final class ProxyInfoCollector extends Collector {
return Collections.emptyList();
}
List<MetricFamilySamples> result = new LinkedList<>();
- proxyInfo.get().addMetric(Collections.singletonList(PROXY_STATE), PROXY_STATE_MAP.get(stateContext.get().getCurrentState()));
+ proxyInfo.get().addMetric(Collections.singletonList(PROXY_STATE), PROXY_STATES.get(stateContext.get().getCurrentState()));
result.add(proxyInfo.get());
return result;
}
diff --git a/agent/plugins/tracing/type/jaeger/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/JaegerTracingPluginBootService.java b/agent/plugins/tracing/type/jaeger/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/JaegerTracingPluginBootService.java
index 91b7f5edeab..6776997219f 100644
--- a/agent/plugins/tracing/type/jaeger/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/JaegerTracingPluginBootService.java
+++ b/agent/plugins/tracing/type/jaeger/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/JaegerTracingPluginBootService.java
@@ -39,7 +39,7 @@ public final class JaegerTracingPluginBootService implements PluginBootService {
@SuppressWarnings("AccessOfSystemProperties")
@Override
public void start(final PluginConfiguration pluginConfig, final boolean isEnhancedForProxy) {
- RemotePluginConfigurationValidator.validate(getType(), pluginConfig);
+ RemotePluginConfigurationValidator.validateHostAndPort(getType(), pluginConfig);
pluginConfig.getProps().forEach((key, value) -> setSystemProperty(String.valueOf(key), String.valueOf(value)));
Configuration.SamplerConfiguration samplerConfig = Configuration.SamplerConfiguration.fromEnv();
Configuration.ReporterConfiguration reporterConfig = Configuration.ReporterConfiguration.fromEnv()
diff --git a/agent/plugins/tracing/type/zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/ZipkinTracingPluginBootService.java b/agent/plugins/tracing/type/zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/ZipkinTracingPluginBootService.java
index ca6d661abcd..46eaff43211 100644
--- a/agent/plugins/tracing/type/zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/ZipkinTracingPluginBootService.java
+++ b/agent/plugins/tracing/type/zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/ZipkinTracingPluginBootService.java
@@ -59,7 +59,7 @@ public final class ZipkinTracingPluginBootService implements PluginBootService {
@Override
public void start(final PluginConfiguration pluginConfig, final boolean isEnhancedForProxy) {
- RemotePluginConfigurationValidator.validate(getType(), pluginConfig);
+ RemotePluginConfigurationValidator.validateHostAndPort(getType(), pluginConfig);
Properties props = pluginConfig.getProps();
String urlVersion = Optional.ofNullable(props.getProperty(KEY_URL_VERSION)).orElse(DEFAULT_URL_VERSION);
String serviceName = Optional.ofNullable(props.getProperty(KEY_SERVICE_NAME)).orElse(DEFAULT_SERVICE_NAME);