19 Temmuz 2023 Çarşamba

Micrometer HazelcastCacheMetrics Sınıfı

Örnek
Şöyle yaparız
import com.hazelcast.core.HazelcastInstance;
import io.micrometer.core.instrument.ImmutableTag;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Tag;
import io.micrometer.core.instrument.binder.cache.HazelcastCacheMetrics;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.List;


@Component
@RequiredArgsConstructor
public class HazelcastMetricBinder {
  public static String My_CACHE_NAME = "MyCacheName";
  private final MeterRegistry meterRegistry;
  private final HazelcastInstance hazelcastInstance;

  @PostConstruct
  void monitorHazelcastCacheMetrics() {
    List<Tag> tags = List.of(new ImmutableTag("cacheName", My_CACHE_NAME));
    HazelcastCacheMetrics.monitor(meterRegistry, 
          hazelcastInstance.getMap(My_CACHE_NAME), tags);
  }
}


Hiç yorum yok:

Yorum Gönder

THIRD-PARTY.txt Dosyası

Kullanılan harici kütüphanelerin sürümleri bu dosyada Dosyanın yolu şöyle hazelcast/licenses/THIRD-PARTY.txt