You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2022/01/19 13:51:41 UTC

[GitHub] [skywalking] sunOnly opened a new issue #8450: [Feature]

sunOnly opened a new issue #8450:
URL: https://github.com/apache/skywalking/issues/8450


   ### Search before asking
   
   - [X] I had searched in the [issues](https://github.com/apache/skywalking/issues?q=is%3Aissue) and found no similar feature requirement.
   
   
   ### Description
   
   Support the collection of Druid, hikaricp and other database connection pool measurement data, and support multiple instances
   
   ### Use case
   
   Used to monitor the usage of database connection pool
   
   
   ### Related issues
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
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: notifications-unsubscribe@skywalking.apache.org

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



[GitHub] [skywalking] sunOnly commented on issue #8450: [Feature] Support collecting database connection pool metric

Posted by GitBox <gi...@apache.org>.
sunOnly commented on issue #8450:
URL: https://github.com/apache/skywalking/issues/8450#issuecomment-1017515451


   > The final label should be `datasource name` + `status`(idle/max) in the instance page.
   Is that the effect?
   ![企业微信截图_16426859566790](https://user-images.githubusercontent.com/22111568/150349647-ba4fa268-86ee-44fa-88f9-d1006fb1b55b.png)
   


-- 
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: notifications-unsubscribe@skywalking.apache.org

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



[GitHub] [skywalking] sunOnly edited a comment on issue #8450: [Feature] Support collecting database connection pool metric

Posted by GitBox <gi...@apache.org>.
sunOnly edited a comment on issue #8450:
URL: https://github.com/apache/skywalking/issues/8450#issuecomment-1017431365


   > Why do you set labels as `0,1,2,3,4,5`? Have no clue what do you mean to do so. Counts of idle, using, max are as same as undertow discussion. I could recommend you to take a look at the issue I pointed to you, it has shown a good demo to you.
   
   It is modified as follows:
    instance add global  Datasource metric
   ![image](https://user-images.githubusercontent.com/22111568/150333855-cd4aa158-c20e-4b32-a684-38bd868dc9fa.png)
   ![image](https://user-images.githubusercontent.com/22111568/150336633-4b81403d-fca3-4b50-807d-97b94687d3c5.png)
   
    View specific detail of Datasource metric
   ![企业微信截图_16426806742109](https://user-images.githubusercontent.com/22111568/150336479-23385030-ad7e-4458-9d86-2210e533cb2f.png)
   
   
   


-- 
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: notifications-unsubscribe@skywalking.apache.org

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



[GitHub] [skywalking] sunOnly commented on issue #8450: [Feature] Support collecting database connection pool metric

Posted by GitBox <gi...@apache.org>.
sunOnly commented on issue #8450:
URL: https://github.com/apache/skywalking/issues/8450#issuecomment-1019901537


   > @sunOnly Any update?
   
   Bad network timeout submission failed
   
   


-- 
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: notifications-unsubscribe@skywalking.apache.org

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



[GitHub] [skywalking] wu-sheng commented on issue #8450: [Feature] Support collecting database connection pool metric

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #8450:
URL: https://github.com/apache/skywalking/issues/8450#issuecomment-1017436016


   For the database, I m not sure whether it is a good idea to provide a whole dashboard.
   I think we should include datasource name in the label, then one item component should be enough.


-- 
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: notifications-unsubscribe@skywalking.apache.org

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



[GitHub] [skywalking] sunOnly commented on issue #8450: [Feature] Support collecting database connection pool metric

Posted by GitBox <gi...@apache.org>.
sunOnly commented on issue #8450:
URL: https://github.com/apache/skywalking/issues/8450#issuecomment-1019890205


   > @sunOnly Any update?
   
   There are added code in the skywalking-java . Submit it now
   
    


-- 
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: notifications-unsubscribe@skywalking.apache.org

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



[GitHub] [skywalking] sunOnly commented on issue #8450: [Feature] Support collecting database connection pool metric

Posted by GitBox <gi...@apache.org>.
sunOnly commented on issue #8450:
URL: https://github.com/apache/skywalking/issues/8450#issuecomment-1016498542


   ![image](https://user-images.githubusercontent.com/22111568/150145389-31a76a4f-b5f5-427d-8052-0e66ffec52b9.png)
   ![image](https://user-images.githubusercontent.com/22111568/150145739-c46b8d48-0a2c-43e3-bca2-e151e68b5109.png)
   ![Uploading image.png…]()
   
   
   
   
   package org.apache.skywalking.apm.agent.core.pool.druid;
   
   
   import org.apache.skywalking.apm.agent.core.logging.api.ILog;
   import org.apache.skywalking.apm.agent.core.logging.api.LogManager;
   import org.apache.skywalking.apm.agent.core.meter.MeterFactory;
   import org.apache.skywalking.apm.agent.core.pool.DatabaseParserHelper;
   
   import javax.management.MBeanServer;
   import javax.management.ObjectName;
   import java.lang.management.ManagementFactory;
   import java.util.Hashtable;
   import java.util.LinkedHashMap;
   import java.util.Map;
   import java.util.Set;
   
   public class DruidRegister {
       private static final ILog LOGGER = LogManager.getLogger(DruidRegister.class);
   
       protected MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
       protected DatabaseParserHelper databaseParser = new DatabaseParserHelper();
       private static final String ERROR_ATTRIBUTE = "unknown";
   
   
       public boolean register() {
           try {
               LOGGER.info("DruidRegister register start");
               Hashtable<String, String> table = new Hashtable<String, String>();
               table.put("type", "DruidDataSource");
               table.put("id", "*");
               ObjectName pooledDataSourceObjectName = new ObjectName("com.alibaba.druid", table);
               Set<ObjectName> objectNameSet = mbeanServer.queryNames(pooledDataSourceObjectName, null);
   
               if (objectNameSet == null || objectNameSet.isEmpty()) {
                   return false;
               }
   
               Map<String, Integer> datasources = new LinkedHashMap<String, Integer>();
   
               int index = 0;
               for (ObjectName objectName : objectNameSet) {
                   String jdbcUrl = getStringAttribute(objectName, "Url");
                   DatabaseParserHelper.Database datasource = databaseParser.parseDatabase(jdbcUrl);
                   String key = getConnection(datasources, datasource.toString());
                   LOGGER.debug("key {}", key);
   
                   MeterFactory.gauge("active_count", () -> getIntegerAttribute(objectName, "ActiveCount").doubleValue()).tag("index", String.valueOf(index)).tag("datasource", key).build();
                   MeterFactory.gauge("pooling_count", () -> getIntegerAttribute(objectName, "PoolingCount").doubleValue()).tag("index", String.valueOf(index)).tag("datasource", key).build();
                   MeterFactory.gauge("idle_connection", () -> getIntegerAttribute(objectName, "ActiveCount").doubleValue()).tag("index", String.valueOf(index)).tag("datasource", key).build();
                   MeterFactory.gauge("lock_queue_length", () -> getIntegerAttribute(objectName, "LockQueueLength").doubleValue()).tag("index", String.valueOf(index)).tag("datasource", key).build();
                   MeterFactory.gauge("max_wait_thread_count", () -> getIntegerAttribute(objectName, "MaxWaitThreadCount").doubleValue()).tag("index", String.valueOf(index)).tag("datasource", key).build();
                   MeterFactory.gauge("commit_count", () -> getLongAttribute(objectName, "CommitCount").doubleValue()).tag("index", String.valueOf(index)).tag("datasource", key).build();
                   MeterFactory.gauge("connect_count", () -> getLongAttribute(objectName, "ConnectCount").doubleValue()).tag("index", String.valueOf(index)).tag("datasource", key).build();
                   MeterFactory.gauge("connect_error_count", () -> getLongAttribute(objectName, "ConnectErrorCount").doubleValue()).tag("index", String.valueOf(index)).tag("datasource", key).build();
                   MeterFactory.gauge("create_error_count", () -> getLongAttribute(objectName, "CreateErrorCount").doubleValue()).tag("index", String.valueOf(index)).tag("datasource", key).build();
                   index++;
               }
               LOGGER.info("DruidRegister register end");
           } catch (Exception e) {
               LOGGER.error("Druid Register fail", e);
           }
           return true;
       }
   
       protected String getConnection(Map<String, Integer> datasources, String key) {
           Integer index = datasources.get(key);
   
           if (index == null) {
               datasources.put(key, 0);
   
               return key;
           } else {
               index++;
   
               datasources.put(key, index);
               return key + '[' + index + ']';
           }
       }
   
       protected Integer getIntegerAttribute(ObjectName objectName, String attribute) {
           try {
               Integer value = (Integer) mbeanServer.getAttribute(objectName, attribute);
               return value;
           } catch (Exception e) {
               return 0;
           }
       }
   
       protected Long getLongAttribute(ObjectName objectName, String attribute) {
           try {
               Long value = (Long) mbeanServer.getAttribute(objectName, attribute);
               return value;
           } catch (Exception e) {
               return 0L;
           }
       }
   
       protected String getStringAttribute(ObjectName objectName, String attribute) {
           try {
               return (String) mbeanServer.getAttribute(objectName, attribute);
           } catch (Exception e) {
               return ERROR_ATTRIBUTE;
           }
       }
   
   }
   
   
   package org.apache.skywalking.apm.agent.core.pool;
   
   import org.apache.skywalking.apm.agent.core.boot.BootService;
   import org.apache.skywalking.apm.agent.core.boot.DefaultImplementor;
   import org.apache.skywalking.apm.agent.core.boot.DefaultNamedThreadFactory;
   import org.apache.skywalking.apm.agent.core.logging.api.ILog;
   import org.apache.skywalking.apm.agent.core.logging.api.LogManager;
   import org.apache.skywalking.apm.agent.core.pool.druid.DruidRegister;
   import org.apache.skywalking.apm.util.RunnableWithExceptionProtection;
   
   import java.util.concurrent.Executors;
   import java.util.concurrent.ScheduledFuture;
   import java.util.concurrent.TimeUnit;
   
   /**
    * The <code>PoolService</code> represents a timer, which register Druid monitor metrics
    * {@link DruidRegister}
    */
   @DefaultImplementor
   public class PoolService implements BootService, Runnable {
       private static final ILog LOGGER = LogManager.getLogger(PoolService.class);
       private volatile ScheduledFuture<?> registerMetricFuture;
       private DruidRegister druidRegister;
   
       @Override
       public void prepare() throws Throwable {
           druidRegister = new DruidRegister();
       }
   
       @Override
       public void boot() throws Throwable {
           registerMetricFuture = Executors.newSingleThreadScheduledExecutor(
                   new DefaultNamedThreadFactory("PoolService-Register"))
                   .scheduleAtFixedRate(new RunnableWithExceptionProtection(
                           this,
                           new RunnableWithExceptionProtection.CallbackWhenException() {
                               @Override
                               public void handle(Throwable t) {
                                   LOGGER.error("PoolService Register metrics failure.", t);
                               }
                           }
                   ), 0, 30, TimeUnit.SECONDS);
       }
   
       @Override
       public void onComplete() throws Throwable {
   
       }
   
       @Override
       public void shutdown() throws Throwable {
           registerMetricFuture.cancel(true);
       }
   
       @Override
       public void run() {
           druidRegister.register();
       }
   }


-- 
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: notifications-unsubscribe@skywalking.apache.org

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



[GitHub] [skywalking] wu-sheng commented on issue #8450: [Feature] Support collecting database connection pool metric

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #8450:
URL: https://github.com/apache/skywalking/issues/8450#issuecomment-1019882614


   @sunOnly Any update?


-- 
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: notifications-unsubscribe@skywalking.apache.org

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



[GitHub] [skywalking] wu-sheng commented on issue #8450: [Feature] Support collecting database connection pool metric

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #8450:
URL: https://github.com/apache/skywalking/issues/8450#issuecomment-1016568447


   You need to follow that discussion. We prefer the final metrics as labeled values. Then you could list all metrics on the dashboard by using one metric name, which means we only need one row in the database per timebucket + entity.
   
   Right now, if you have 10 metrics, then one service causes 10 rows in the database per timebucket.


-- 
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: notifications-unsubscribe@skywalking.apache.org

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



[GitHub] [skywalking] sunOnly commented on issue #8450: [Feature] Support collecting database connection pool metric

Posted by GitBox <gi...@apache.org>.
sunOnly commented on issue #8450:
URL: https://github.com/apache/skywalking/issues/8450#issuecomment-1019427700


   > This seems good. Do you have any suggestion or concern?
   
   Is it better to add the function to the apm-agent-core module or create a new module?
   Is it reasonable to put mal analysis statements in the meter analyzer config directory?


-- 
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: notifications-unsubscribe@skywalking.apache.org

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



[GitHub] [skywalking] wu-sheng commented on issue #8450: [Feature] Support collecting database connection pool metric

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #8450:
URL: https://github.com/apache/skywalking/issues/8450#issuecomment-1017603702


   This seems good. Do you have any suggestion or concern?


-- 
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: notifications-unsubscribe@skywalking.apache.org

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



[GitHub] [skywalking] sunOnly commented on issue #8450: [Feature] Support collecting database connection pool metric

Posted by GitBox <gi...@apache.org>.
sunOnly commented on issue #8450:
URL: https://github.com/apache/skywalking/issues/8450#issuecomment-1017431365


   > Why do you set labels as `0,1,2,3,4,5`? Have no clue what do you mean to do so. Counts of idle, using, max are as same as undertow discussion. I could recommend you to take a look at the issue I pointed to you, it has shown a good demo to you.
   
   It is modified as follows:
    instance add global  Datasource metric
   ![image](https://user-images.githubusercontent.com/22111568/150333855-cd4aa158-c20e-4b32-a684-38bd868dc9fa.png)
   
    View specific detail of Datasource metric
   ![image](https://user-images.githubusercontent.com/22111568/150333711-0d1ef451-5437-47c0-8fc9-b283e74a03dc.png)
   


-- 
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: notifications-unsubscribe@skywalking.apache.org

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



[GitHub] [skywalking] wu-sheng commented on issue #8450: [Feature] Support collecting database connection pool metric

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #8450:
URL: https://github.com/apache/skywalking/issues/8450#issuecomment-1019902880


   Usually, you need a VPN to submit codes to GitHub, I am afraid. It is unstable from time to time.


-- 
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: notifications-unsubscribe@skywalking.apache.org

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



[GitHub] [skywalking] wu-sheng commented on issue #8450: [Feature] Support collecting database connection pool metric

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #8450:
URL: https://github.com/apache/skywalking/issues/8450#issuecomment-1017143510


   Why do you set labels as `0,1,2,3,4,5`? Have no clue what do you mean to do so. Counts of idle, using, max are as same as undertow discussion. I could recommend you to take a look at the issue I pointed to you, it has shown a good demo to you.
   


-- 
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: notifications-unsubscribe@skywalking.apache.org

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



[GitHub] [skywalking] wu-sheng commented on issue #8450: [Feature] Support collecting database connection pool metric

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #8450:
URL: https://github.com/apache/skywalking/issues/8450#issuecomment-1017446694


   The final label should be `datasource name` + `status`(idle/max) in the instance page.


-- 
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: notifications-unsubscribe@skywalking.apache.org

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



[GitHub] [skywalking] sunOnly edited a comment on issue #8450: [Feature] Support collecting database connection pool metric

Posted by GitBox <gi...@apache.org>.
sunOnly edited a comment on issue #8450:
URL: https://github.com/apache/skywalking/issues/8450#issuecomment-1016498542


   ![image](https://user-images.githubusercontent.com/22111568/150145389-31a76a4f-b5f5-427d-8052-0e66ffec52b9.png)
   ![image](https://user-images.githubusercontent.com/22111568/150145739-c46b8d48-0a2c-43e3-bca2-e151e68b5109.png)
   ![Uploading image.png…]()
   
   
   
   ```java
   package org.apache.skywalking.apm.agent.core.pool.druid;
   
   
   import org.apache.skywalking.apm.agent.core.logging.api.ILog;
   import org.apache.skywalking.apm.agent.core.logging.api.LogManager;
   import org.apache.skywalking.apm.agent.core.meter.MeterFactory;
   import org.apache.skywalking.apm.agent.core.pool.DatabaseParserHelper;
   
   import javax.management.MBeanServer;
   import javax.management.ObjectName;
   import java.lang.management.ManagementFactory;
   import java.util.Hashtable;
   import java.util.LinkedHashMap;
   import java.util.Map;
   import java.util.Set;
   
   public class DruidRegister {
       private static final ILog LOGGER = LogManager.getLogger(DruidRegister.class);
   
       protected MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
       protected DatabaseParserHelper databaseParser = new DatabaseParserHelper();
       private static final String ERROR_ATTRIBUTE = "unknown";
   
   
       public boolean register() {
           try {
               LOGGER.info("DruidRegister register start");
               Hashtable<String, String> table = new Hashtable<String, String>();
               table.put("type", "DruidDataSource");
               table.put("id", "*");
               ObjectName pooledDataSourceObjectName = new ObjectName("com.alibaba.druid", table);
               Set<ObjectName> objectNameSet = mbeanServer.queryNames(pooledDataSourceObjectName, null);
   
               if (objectNameSet == null || objectNameSet.isEmpty()) {
                   return false;
               }
   
               Map<String, Integer> datasources = new LinkedHashMap<String, Integer>();
   
               int index = 0;
               for (ObjectName objectName : objectNameSet) {
                   String jdbcUrl = getStringAttribute(objectName, "Url");
                   DatabaseParserHelper.Database datasource = databaseParser.parseDatabase(jdbcUrl);
                   String key = getConnection(datasources, datasource.toString());
                   LOGGER.debug("key {}", key);
   
                   MeterFactory.gauge("active_count", () -> getIntegerAttribute(objectName, "ActiveCount").doubleValue()).tag("index", String.valueOf(index)).tag("datasource", key).build();
                   MeterFactory.gauge("pooling_count", () -> getIntegerAttribute(objectName, "PoolingCount").doubleValue()).tag("index", String.valueOf(index)).tag("datasource", key).build();
                   MeterFactory.gauge("idle_connection", () -> getIntegerAttribute(objectName, "ActiveCount").doubleValue()).tag("index", String.valueOf(index)).tag("datasource", key).build();
                   MeterFactory.gauge("lock_queue_length", () -> getIntegerAttribute(objectName, "LockQueueLength").doubleValue()).tag("index", String.valueOf(index)).tag("datasource", key).build();
                   MeterFactory.gauge("max_wait_thread_count", () -> getIntegerAttribute(objectName, "MaxWaitThreadCount").doubleValue()).tag("index", String.valueOf(index)).tag("datasource", key).build();
                   MeterFactory.gauge("commit_count", () -> getLongAttribute(objectName, "CommitCount").doubleValue()).tag("index", String.valueOf(index)).tag("datasource", key).build();
                   MeterFactory.gauge("connect_count", () -> getLongAttribute(objectName, "ConnectCount").doubleValue()).tag("index", String.valueOf(index)).tag("datasource", key).build();
                   MeterFactory.gauge("connect_error_count", () -> getLongAttribute(objectName, "ConnectErrorCount").doubleValue()).tag("index", String.valueOf(index)).tag("datasource", key).build();
                   MeterFactory.gauge("create_error_count", () -> getLongAttribute(objectName, "CreateErrorCount").doubleValue()).tag("index", String.valueOf(index)).tag("datasource", key).build();
                   index++;
               }
               LOGGER.info("DruidRegister register end");
           } catch (Exception e) {
               LOGGER.error("Druid Register fail", e);
           }
           return true;
       }
   
       protected String getConnection(Map<String, Integer> datasources, String key) {
           Integer index = datasources.get(key);
   
           if (index == null) {
               datasources.put(key, 0);
   
               return key;
           } else {
               index++;
   
               datasources.put(key, index);
               return key + '[' + index + ']';
           }
       }
   
       protected Integer getIntegerAttribute(ObjectName objectName, String attribute) {
           try {
               Integer value = (Integer) mbeanServer.getAttribute(objectName, attribute);
               return value;
           } catch (Exception e) {
               return 0;
           }
       }
   
       protected Long getLongAttribute(ObjectName objectName, String attribute) {
           try {
               Long value = (Long) mbeanServer.getAttribute(objectName, attribute);
               return value;
           } catch (Exception e) {
               return 0L;
           }
       }
   
       protected String getStringAttribute(ObjectName objectName, String attribute) {
           try {
               return (String) mbeanServer.getAttribute(objectName, attribute);
           } catch (Exception e) {
               return ERROR_ATTRIBUTE;
           }
       }
   
   }
   ```
   
   ```java
   package org.apache.skywalking.apm.agent.core.pool;
   
   import org.apache.skywalking.apm.agent.core.boot.BootService;
   import org.apache.skywalking.apm.agent.core.boot.DefaultImplementor;
   import org.apache.skywalking.apm.agent.core.boot.DefaultNamedThreadFactory;
   import org.apache.skywalking.apm.agent.core.logging.api.ILog;
   import org.apache.skywalking.apm.agent.core.logging.api.LogManager;
   import org.apache.skywalking.apm.agent.core.pool.druid.DruidRegister;
   import org.apache.skywalking.apm.util.RunnableWithExceptionProtection;
   
   import java.util.concurrent.Executors;
   import java.util.concurrent.ScheduledFuture;
   import java.util.concurrent.TimeUnit;
   
   /**
    * The <code>PoolService</code> represents a timer, which register Druid monitor metrics
    * {@link DruidRegister}
    */
   @DefaultImplementor
   public class PoolService implements BootService, Runnable {
       private static final ILog LOGGER = LogManager.getLogger(PoolService.class);
       private volatile ScheduledFuture<?> registerMetricFuture;
       private DruidRegister druidRegister;
   
       @Override
       public void prepare() throws Throwable {
           druidRegister = new DruidRegister();
       }
   
       @Override
       public void boot() throws Throwable {
           registerMetricFuture = Executors.newSingleThreadScheduledExecutor(
                   new DefaultNamedThreadFactory("PoolService-Register"))
                   .scheduleAtFixedRate(new RunnableWithExceptionProtection(
                           this,
                           new RunnableWithExceptionProtection.CallbackWhenException() {
                               @Override
                               public void handle(Throwable t) {
                                   LOGGER.error("PoolService Register metrics failure.", t);
                               }
                           }
                   ), 0, 30, TimeUnit.SECONDS);
       }
   
       @Override
       public void onComplete() throws Throwable {
   
       }
   
       @Override
       public void shutdown() throws Throwable {
           registerMetricFuture.cancel(true);
       }
   
       @Override
       public void run() {
           druidRegister.register();
       }
   }
   ```


-- 
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: notifications-unsubscribe@skywalking.apache.org

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



[GitHub] [skywalking] wu-sheng commented on issue #8450: [Feature] Support collecting database connection pool metric

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #8450:
URL: https://github.com/apache/skywalking/issues/8450#issuecomment-1016487719


   Please follow https://github.com/apache/skywalking/issues/8433 and finish local POC.
   We prefer labeled value metrics rather than multiple metrics.
   
   Once you did, please provide MAL script, UI configuration and UI preview here before submitting any pull request.


-- 
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: notifications-unsubscribe@skywalking.apache.org

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



[GitHub] [skywalking] wu-sheng closed issue #8450: [Feature] Support collecting database connection pool metric

Posted by GitBox <gi...@apache.org>.
wu-sheng closed issue #8450:
URL: https://github.com/apache/skywalking/issues/8450


   


-- 
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: notifications-unsubscribe@skywalking.apache.org

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



[GitHub] [skywalking] sunOnly commented on issue #8450: [Feature] Support collecting database connection pool metric

Posted by GitBox <gi...@apache.org>.
sunOnly commented on issue #8450:
URL: https://github.com/apache/skywalking/issues/8450#issuecomment-1017070226


   > You need to follow that discussion. We prefer the final metrics as labeled values. Then you could list all metrics on the dashboard by using one metric name, which means we only need one row in the database per timebucket + entity.
   > 
   > Right now, if you have 10 metrics, then one service causes 10 rows in the database per timebucket.
   
   We prefer the final metrics as labeled values,Cannot process when multiple data sources。
   As shown in the figure below, multiple data sources use this scheme
   ![企业微信截图_16426466739742](https://user-images.githubusercontent.com/22111568/150262805-d5392382-3585-4821-826c-49cfb76c685f.png)
   ![image](https://user-images.githubusercontent.com/22111568/150263248-88162297-34ce-463d-b91d-6411cc5cfb9a.png)
   


-- 
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: notifications-unsubscribe@skywalking.apache.org

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



[GitHub] [skywalking] sunOnly edited a comment on issue #8450: [Feature] Support collecting database connection pool metric

Posted by GitBox <gi...@apache.org>.
sunOnly edited a comment on issue #8450:
URL: https://github.com/apache/skywalking/issues/8450#issuecomment-1017070226


   > You need to follow that discussion. We prefer the final metrics as labeled values. Then you could list all metrics on the dashboard by using one metric name, which means we only need one row in the database per timebucket + entity.
   > 
   > Right now, if you have 10 metrics, then one service causes 10 rows in the database per timebucket.
   
   final metrics as labeled values,. Now multiple data sources use this scheme. How to deal with multiple data sources in this way?
   ![企业微信截图_16426466739742](https://user-images.githubusercontent.com/22111568/150262805-d5392382-3585-4821-826c-49cfb76c685f.png)
   ![image](https://user-images.githubusercontent.com/22111568/150263248-88162297-34ce-463d-b91d-6411cc5cfb9a.png)
   


-- 
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: notifications-unsubscribe@skywalking.apache.org

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



[GitHub] [skywalking] sunOnly edited a comment on issue #8450: [Feature] Support collecting database connection pool metric

Posted by GitBox <gi...@apache.org>.
sunOnly edited a comment on issue #8450:
URL: https://github.com/apache/skywalking/issues/8450#issuecomment-1017070226


   > You need to follow that discussion. We prefer the final metrics as labeled values. Then you could list all metrics on the dashboard by using one metric name, which means we only need one row in the database per timebucket + entity.
   > 
   > Right now, if you have 10 metrics, then one service causes 10 rows in the database per timebucket.
   
   final metrics as labeled values,. Now multiple data sources use this scheme. How to deal with multiple data sources in this way?
   ![企业微信截图_16426466739742](https://user-images.githubusercontent.com/22111568/150262805-d5392382-3585-4821-826c-49cfb76c685f.png)
   ![image](https://user-images.githubusercontent.com/22111568/150263248-88162297-34ce-463d-b91d-6411cc5cfb9a.png)
   ![image](https://user-images.githubusercontent.com/22111568/150264501-9a3dafef-d018-406f-8826-483fa51a4520.png)
   


-- 
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: notifications-unsubscribe@skywalking.apache.org

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



[GitHub] [skywalking] sunOnly edited a comment on issue #8450: [Feature] Support collecting database connection pool metric

Posted by GitBox <gi...@apache.org>.
sunOnly edited a comment on issue #8450:
URL: https://github.com/apache/skywalking/issues/8450#issuecomment-1017431365


   > Why do you set labels as `0,1,2,3,4,5`? Have no clue what do you mean to do so. Counts of idle, using, max are as same as undertow discussion. I could recommend you to take a look at the issue I pointed to you, it has shown a good demo to you.
   
   It is modified as follows:
    instance add global  Datasource metric
   ![image](https://user-images.githubusercontent.com/22111568/150333855-cd4aa158-c20e-4b32-a684-38bd868dc9fa.png)
   
    View specific detail of Datasource metric
   ![企业微信截图_16426806742109](https://user-images.githubusercontent.com/22111568/150336479-23385030-ad7e-4458-9d86-2210e533cb2f.png)
   
   
   


-- 
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: notifications-unsubscribe@skywalking.apache.org

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



[GitHub] [skywalking] wu-sheng commented on issue #8450: [Feature] Support collecting database connection pool metric

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #8450:
URL: https://github.com/apache/skywalking/issues/8450#issuecomment-1019427986


   > Is it better to add the function to the apm-agent-core module or create a new module?
   
   No, you don't. Meter or/and tracing have no difference to the agent core
   
   > Is it reasonable to put mal analysis statements in the meter analyzer config directory?
   
   Yes, it is. And mostly, I think you have to. Otherwise, you can't activate it through meter receiver.


-- 
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: notifications-unsubscribe@skywalking.apache.org

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