简体   繁体   English

Mongo C# 驱动程序指标

[英]Mongo C# Driver metrics

We're having problems with connection pooling and the wait queue with mongo using the mongo c# driver.我们在连接池和使用 mongo c# 驱动程序的 mongo 中遇到了问题。

Is there any way to get metrics from the MongoClient at all?有没有办法从 MongoClient 获取指标? Things like number of active connections, size of connection pool, size of wait queue etc.活动连接的数量、连接池的大小、等待队列的大小等。

There are loads of connection pool events that you can subscribe to which might help you.您可以订阅大量连接池事件,这可能会对您有所帮助。 These are:这些是:

  • ConnectionPoolCheckingOutConnectionEvent ConnectionPoolCheckingOutConnectionEvent
  • ConnectionPoolCheckedOutConnectionEvent ConnectionPoolCheckedOutConnectionEvent
  • ConnectionPoolCheckingOutConnectionFailedEvent ConnectionPoolCheckingOutConnectionFailedEvent
  • ConnectionPoolCheckingInConnectionEvent ConnectionPoolCheckingInConnectionEvent
  • ConnectionPoolCheckedInConnectionEvent ConnectionPoolCheckedInConnectionEvent
  • ConnectionPoolAddingConnectionEvent连接池添加连接事件
  • ConnectionPoolAddedConnectionEvent ConnectionPoolAddedConnectionEvent
  • ConnectionPoolOpeningEvent ConnectionPoolOpeningEvent
  • ConnectionPoolOpenedEvent ConnectionPoolOpenedEvent
  • ConnectionPoolClosingEvent连接池关闭事件
  • ConnectionPoolClosedEvent连接池关闭事件
  • ConnectionPoolClearingEvent连接池清除事件
  • ConnectionPoolClearedEvent ConnectionPoolClearedEvent
  • ConnectionCreatedEvent连接创建事件

You can subscribe to these when you setup the MongoClient您可以在设置 MongoClient 时订阅这些

    var mongoClientSettings = MongoClientSettings.FromUrl(new MongoUrl("mongodb://localhost"));

    mongoClientSettings.ClusterConfigurator = clusterConfigurator =>
    {
        clusterConfigurator.Subscribe<ConnectionPoolCheckingOutConnectionEvent>(e =>
        {
            
        });
    };

    var mongoClient = new MongoClient(mongoClientSettings);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM