vyalamar commented on code in PR #9771:
URL: https://github.com/apache/ozone/pull/9771#discussion_r2903441299
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/metrics/S3GatewayMetrics.java:
##########
@@ -307,20 +309,33 @@ public static synchronized S3GatewayMetrics
create(OzoneConfiguration conf) {
if (instance != null) {
return instance;
}
- MetricsSystem ms = DefaultMetricsSystem.instance();
- instance = ms.register(SOURCE_NAME, "S3 Gateway Metrics",
- new S3GatewayMetrics(conf));
+ if (metricsEnabled == null) {
+ metricsEnabled = conf.getBoolean(
+ S3GatewayConfigKeys.OZONE_S3G_METRICS_ENABLED,
+ S3GatewayConfigKeys.OZONE_S3G_METRICS_ENABLED_DEFAULT);
+ }
+ instance = new S3GatewayMetrics(conf);
+ if (metricsEnabled) {
+ MetricsSystem ms = DefaultMetricsSystem.instance();
+ instance = ms.register(SOURCE_NAME, "S3 Gateway Metrics", instance);
+ } else {
+ // Initialize annotated metrics fields without publishing the source.
+ MetricsAnnotations.makeSource(instance);
+ }
return instance;
}
/**
* Unregister the metrics instance.
*/
- public static void unRegister() {
+ public static synchronized void unRegister() {
IOUtils.closeQuietly(instance);
instance = null;
+ metricsEnabled = null;
Review Comment:
yes, let me simplify it.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]