Şö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@RequiredArgsConstructorpublic class HazelcastMetricBinder {public static String My_CACHE_NAME = "MyCacheName";private final MeterRegistry meterRegistry;private final HazelcastInstance hazelcastInstance;@PostConstructvoid 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