joerghoh commented on code in PR #38:
URL: 
https://github.com/apache/sling-org-apache-sling-jcr-resource/pull/38#discussion_r1016626606


##########
src/main/java/org/apache/sling/jcr/resource/internal/helper/AccessLogger.java:
##########
@@ -0,0 +1,129 @@
+/*
+ * 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.sling.jcr.resource.internal.helper;
+
+import java.io.Closeable;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.stream.Collectors;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *  Helper class to report on repository access.
+ *  
+ *  The focus is to have a less overhead as possible if it is not used; in 
case it is enabled and access
+ *  is logged, the performance overhead does not matter.
+ *  
+ *  In the current implementation it has 2 features:
+ *  * Write a stacktrace on every recorded operation; this comes with a 
massive overhead and it is definitely
+ *    not recommended to turn this on on production, since it can easily 
create 100s of megabytes of log and will slow
+ *    down processing massively. To use this turn on TRACE logging on 
'org.apache.sling.jcr.resource.AccessLogger.operation'
+ *  * When a resource resolver is closed, dump a single log statement about 
the number of recorded operations. The overhead is
+ *    very small and it can be turned on for a longer period of time also in 
production. To use it enable DEBUG logging on
+ *    'org.apache.sling.jcr.resource.AccessLogger.statistics'.
+ *  
+ *
+ */
+public class AccessLogger implements Closeable {
+    
+    
+    Map<String,AtomicLong> metrics = new HashMap<>();

Review Comment:
   Agree. 
   A ResourceResolver also has some limitations regarding thread-safety, so we 
avoid any shared resourceresolver. But I agree, a deadlock should not happen.
   
   As this code is not run by default, I will not cancel the already running 
release. But I will prepare a patch for the inclusion in the next release.
   



-- 
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: dev-unsubscr...@sling.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to