com.mongodb.connection.ServerId Java Examples

The following examples show how to use com.mongodb.connection.ServerId. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KamonConnectionPoolListener.java    From ditto with Eclipse Public License 2.0 6 votes vote down vote up
private PoolMetric(final ServerId serverId) {
    final String clusterId = serverId.getClusterId().getValue();
    poolSizeGauge = DittoMetrics.gauge(metricName + POOL_PREFIX + POOL_SIZE)
            .tag(CLUSTER_ID_TAG, clusterId);
    poolSizeGauge.set(0L);

    checkOutCountGauge =
            DittoMetrics.gauge(metricName + POOL_PREFIX + CHECKED_OUT_COUNT)
                    .tag(CLUSTER_ID_TAG, clusterId);
    checkOutCountGauge.set(0L);

    waitQueueGauge =
            DittoMetrics.gauge(metricName + POOL_PREFIX + WAIT_QUEUE_SIZE)
                    .tag(CLUSTER_ID_TAG, clusterId);
    waitQueueGauge.set(0L);
}
 
Example #2
Source File: MongoMetricsConnectionPoolListener.java    From micrometer with Apache License 2.0 5 votes vote down vote up
@Override
public void connectionPoolClosed(ConnectionPoolClosedEvent event) {
    ServerId serverId = event.getServerId();
    for (Meter meter : meters.get(serverId)) {
        registry.remove(meter);
    }
    meters.remove(serverId);
    poolSize.remove(serverId);
    checkedOutCount.remove(serverId);
    waitQueueSize.remove(serverId);
}
 
Example #3
Source File: MongoMetricsConnectionPoolListener.java    From micrometer with Apache License 2.0 5 votes vote down vote up
private Gauge registerGauge(ServerId serverId, String metricName, String description, Map<ServerId, AtomicInteger> metrics) {
    AtomicInteger value = new AtomicInteger();
    metrics.put(serverId, value);
    return Gauge.builder(metricName, value, AtomicInteger::doubleValue)
                .description(description)
                .tag("cluster.id", serverId.getClusterId().getValue())
                .tag("server.address", serverId.getAddress().toString())
                .register(registry);
}
 
Example #4
Source File: MongoMetricsConnectionPoolListener.java    From quarkus with Apache License 2.0 4 votes vote down vote up
private Tag[] createTags(ServerId server) {
    return new Tag[] {
            new Tag("host", server.getAddress().getHost()),
            new Tag("port", String.valueOf(server.getAddress().getPort())),
    };
}
 
Example #5
Source File: MongoMetricsConnectionPoolListener.java    From quarkus with Apache License 2.0 4 votes vote down vote up
private MetricID createMetricID(String metricName, ServerId server) {
    return new MetricID(metricName, createTags(server));
}
 
Example #6
Source File: TraceMongoCommandListenerTest.java    From brave with Apache License 2.0 4 votes vote down vote up
ConnectionDescription createConnectionDescription() {
  return new ConnectionDescription(new ServerId(new ClusterId(), new ServerAddress()));
}