Java Code Examples for com.netflix.spectator.api.Registry

The following examples show how to use com.netflix.spectator.api.Registry. These examples are extracted from open source projects. 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
@Test
public void builderWithDifferentThresholds() {
  Registry r = newRegistry();
  PercentileDistributionSummary t1 = PercentileDistributionSummary.builder(r)
      .withName("test")
      .withRange(10, 50)
      .build();
  PercentileDistributionSummary t2 = PercentileDistributionSummary.builder(r)
      .withName("test")
      .withRange(100, 200)
      .build();

  t1.record(5);
  checkValue(t1, t2, 10.0);

  t1.record(500);
  checkValue(t1, t2, 50.0);

  t2.record(5);
  checkValue(t1, t2, 100.0);

  t2.record(500);
  checkValue(t1, t2, 200.0);
}
 
Example 2
Source Project: zuul   Source File: BaseServerStartup.java    License: Apache License 2.0 6 votes vote down vote up
@Inject
public BaseServerStartup(ServerStatusManager serverStatusManager, FilterLoader filterLoader,
                         SessionContextDecorator sessionCtxDecorator, FilterUsageNotifier usageNotifier,
                         RequestCompleteHandler reqCompleteHandler, Registry registry,
                         DirectMemoryMonitor directMemoryMonitor, EventLoopGroupMetrics eventLoopGroupMetrics,
                         EurekaClient discoveryClient, ApplicationInfoManager applicationInfoManager,
                         AccessLogPublisher accessLogPublisher)
{
    this.serverStatusManager = serverStatusManager;
    this.registry = registry;
    this.directMemoryMonitor = directMemoryMonitor;
    this.eventLoopGroupMetrics = eventLoopGroupMetrics;
    this.discoveryClient = discoveryClient;
    this.applicationInfoManager = applicationInfoManager;
    this.accessLogPublisher = accessLogPublisher;
    this.sessionCtxDecorator = sessionCtxDecorator;
    this.reqCompleteHandler = reqCompleteHandler;
    this.filterLoader = filterLoader;
    this.usageNotifier = usageNotifier;
}
 
Example 3
Source Project: fiat   Source File: FiatStatus.java    License: Apache License 2.0 6 votes vote down vote up
@Autowired
public FiatStatus(
    Registry registry,
    DynamicConfigService dynamicConfigService,
    FiatClientConfigurationProperties fiatClientConfigurationProperties) {
  this.dynamicConfigService = dynamicConfigService;
  this.fiatClientConfigurationProperties = fiatClientConfigurationProperties;

  this.enabled = new AtomicBoolean(fiatClientConfigurationProperties.isEnabled());
  this.legacyFallbackEnabled =
      new AtomicBoolean(fiatClientConfigurationProperties.isLegacyFallback());

  PolledMeter.using(registry)
      .withName("fiat.enabled")
      .monitorValue(enabled, value -> enabled.get() ? 1 : 0);
  PolledMeter.using(registry)
      .withName("fiat.legacyFallback.enabled")
      .monitorValue(legacyFallbackEnabled, value -> legacyFallbackEnabled.get() ? 1 : 0);
}
 
Example 4
Source Project: spectator   Source File: CassandraTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void readLatency() throws Exception {
  Registry r = new DefaultRegistry(new ManualClock());
  List<JmxConfig> configs = configs();

  JmxData data = timer("keyspace=test,name=ReadLatency,scope=foo,type=ColumnFamily", 0);
  List<Measurement> ms = measure(r, configs, data);
  Assertions.assertEquals(7, ms.size());
  Assertions.assertEquals(
      50.0e-4,
      Utils.first(ms, "statistic", "percentile_50").value(),
      1e-12);

  data = timer("keyspace=test,name=ReadLatency,scope=foo,type=ColumnFamily", 1);
  ms = measure(r, configs, data);
  Assertions.assertEquals(7, ms.size());
  Assertions.assertEquals(
      50.01e-4,
      Utils.first(ms, "statistic", "percentile_50").value(),
      1e-12);
}
 
Example 5
Source Project: kork   Source File: AmazonPubsubConfig.java    License: Apache License 2.0 6 votes vote down vote up
@Bean
SQSSubscriberProvider subscriberProvider(
    AWSCredentialsProvider awsCredentialsProvider,
    AmazonPubsubProperties properties,
    PubsubSubscribers subscribers,
    AmazonPubsubMessageHandlerFactory messageHandlerFactory,
    AmazonMessageAcknowledger messageAcknowledger,
    Registry registry,
    EurekaStatusListener eurekaStatus,
    DynamicConfigService dynamicConfig) {
  return new SQSSubscriberProvider(
      awsCredentialsProvider,
      properties,
      subscribers,
      messageHandlerFactory,
      messageAcknowledger,
      registry,
      eurekaStatus,
      dynamicConfig);
}
 
Example 6
Source Project: kayenta   Source File: ExecutionMapper.java    License: Apache License 2.0 6 votes vote down vote up
@Autowired
public ExecutionMapper(
    ObjectMapper objectMapper,
    Registry registry,
    String currentInstanceId,
    Optional<List<CanaryScopeFactory>> canaryScopeFactories,
    ExecutionLauncher executionLauncher,
    ExecutionRepository executionRepository) {
  this.objectMapper = objectMapper;
  this.registry = registry;
  this.currentInstanceId = currentInstanceId;
  this.canaryScopeFactories = canaryScopeFactories.orElseGet(Collections::emptyList);
  this.executionLauncher = executionLauncher;
  this.executionRepository = executionRepository;

  this.pipelineRunId = registry.createId("canary.pipelines.initiated");
  this.failureId = registry.createId("canary.pipelines.startupFailed");
}
 
Example 7
Source Project: kork   Source File: SQSSubscriber.java    License: Apache License 2.0 6 votes vote down vote up
public SQSSubscriber(
    AmazonPubsubProperties.AmazonPubsubSubscription subscription,
    AmazonPubsubMessageHandler messageHandler,
    AmazonMessageAcknowledger messageAcknowledger,
    AmazonSNS amazonSNS,
    AmazonSQS amazonSQS,
    Supplier<Boolean> isEnabled,
    Registry registry) {
  this.subscription = subscription;
  this.messageHandler = messageHandler;
  this.messageAcknowledger = messageAcknowledger;
  this.amazonSNS = amazonSNS;
  this.amazonSQS = amazonSQS;
  this.isEnabled = isEnabled;
  this.registry = registry;

  this.queueARN = new ARN(subscription.getQueueARN());
  this.topicARN = new ARN(subscription.getTopicARN());
}
 
Example 8
Source Project: front50   Source File: CommonStorageServiceDAOConfig.java    License: Apache License 2.0 6 votes vote down vote up
@Bean
ApplicationPermissionDAO applicationPermissionDAO(
    StorageService storageService,
    StorageServiceConfigurationProperties storageServiceConfigurationProperties,
    ObjectKeyLoader objectKeyLoader,
    Registry registry,
    CircuitBreakerRegistry circuitBreakerRegistry) {
  return new DefaultApplicationPermissionDAO(
      storageService,
      Schedulers.from(
          Executors.newFixedThreadPool(
              storageServiceConfigurationProperties.getApplicationPermission().getThreadPool())),
      objectKeyLoader,
      storageServiceConfigurationProperties.getApplicationPermission().getRefreshMs(),
      storageServiceConfigurationProperties.getApplicationPermission().getShouldWarmCache(),
      registry,
      circuitBreakerRegistry);
}
 
Example 9
Source Project: kork   Source File: SQSSubscriberProvider.java    License: Apache License 2.0 6 votes vote down vote up
@Autowired
public SQSSubscriberProvider(
    AWSCredentialsProvider awsCredentialsProvider,
    AmazonPubsubProperties properties,
    PubsubSubscribers pubsubSubscribers,
    AmazonPubsubMessageHandlerFactory pubsubMessageHandlerFactory,
    AmazonMessageAcknowledger messageAcknowledger,
    Registry registry,
    EurekaStatusListener eurekaStatus,
    DynamicConfigService dynamicConfig) {
  this.awsCredentialsProvider = awsCredentialsProvider;
  this.properties = properties;
  this.pubsubSubscribers = pubsubSubscribers;
  this.pubsubMessageHandlerFactory = pubsubMessageHandlerFactory;
  this.messageAcknowledger = messageAcknowledger;
  this.registry = registry;
  this.eurekaStatus = eurekaStatus;
  this.dynamicConfig = dynamicConfig;
}
 
Example 10
Source Project: spectator   Source File: LongTaskTimer.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates a timer for tracking long running tasks.
 *
 * @param registry
 *     Registry to use.
 * @param id
 *     Identifier for the metric being registered.
 * @return
 *     Timer instance.
 */
public static LongTaskTimer get(Registry registry, Id id) {
  ConcurrentMap<Id, Object> state = registry.state();
  Object obj = Utils.computeIfAbsent(state, id, i -> {
    LongTaskTimer timer = new LongTaskTimer(registry, id);
    PolledMeter.using(registry)
        .withId(id)
        .withTag(Statistic.activeTasks)
        .monitorValue(timer, LongTaskTimer::activeTasks);
    PolledMeter.using(registry)
        .withId(id)
        .withTag(Statistic.duration)
        .monitorValue(timer, t -> t.duration() / NANOS_PER_SECOND);
    return timer;
  });
  if (!(obj instanceof LongTaskTimer)) {
    Utils.propagateTypeError(registry, id, LongTaskTimer.class, obj.getClass());
    obj = new LongTaskTimer(new NoopRegistry(), id);
  }
  return (LongTaskTimer) obj;
}
 
Example 11
Source Project: front50   Source File: CommonStorageServiceDAOConfig.java    License: Apache License 2.0 6 votes vote down vote up
@Bean
PipelineDAO pipelineDAO(
    StorageService storageService,
    StorageServiceConfigurationProperties storageServiceConfigurationProperties,
    ObjectKeyLoader objectKeyLoader,
    Registry registry,
    CircuitBreakerRegistry circuitBreakerRegistry) {
  return new DefaultPipelineDAO(
      storageService,
      Schedulers.from(
          Executors.newFixedThreadPool(
              storageServiceConfigurationProperties.getPipeline().getThreadPool())),
      objectKeyLoader,
      storageServiceConfigurationProperties.getPipeline().getRefreshMs(),
      storageServiceConfigurationProperties.getPipeline().getShouldWarmCache(),
      registry,
      circuitBreakerRegistry);
}
 
Example 12
Source Project: metacat   Source File: ElasticSearchConfig.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Traversal action implementation for ElasticSearch refresh.
 *
 * @param config              System config
 * @param eventBus            Event bus
 * @param databaseService     Database service
 * @param tableService        Table service
 * @param userMetadataService User metadata  service
 * @param tagService          Tag service
 * @param elasticSearchUtil   ElasticSearch client wrapper
 * @param registry            registry of spectator
 * @return The refresh bean
 */
@Bean
public ElasticSearchCatalogTraversalAction elasticSearchCatalogTraversalAction(
    final Config config,
    final MetacatEventBus eventBus,
    final DatabaseService databaseService,
    final TableService tableService,
    final UserMetadataService userMetadataService,
    final TagService tagService,
    final ElasticSearchUtil elasticSearchUtil,
    final Registry registry
) {
    return new ElasticSearchCatalogTraversalAction(
        config,
        eventBus,
        databaseService,
        tableService,
        userMetadataService,
        tagService,
        elasticSearchUtil,
        registry
    );
}
 
Example 13
@Override
public void init(GlobalRegistry globalRegistry, EventBus eventBus, MetricsBootstrapConfig config) {
  Registry registry = globalRegistry.getDefaultRegistry();

  Id endpointsId = registry.createId(VERTX_ENDPOINTS);
  VertxEndpointsMeter clientMeter = new HttpClientEndpointsMeter(
      endpointsId.withTag(ENDPOINTS_TYPE, ENDPOINTS_CLINET),
      SharedVertxFactory.getMetricsFactory()
          .getVertxMetrics()
          .getClientEndpointMetricManager()
          .getClientEndpointMetricMap());
  SpectatorUtils.registerMeter(registry, clientMeter);

  VertxEndpointsMeter serverMeter = new ServerEndpointsMeter(
      endpointsId.withTag(ENDPOINTS_TYPE, ENDPOINTS_SERVER),
      SharedVertxFactory.getMetricsFactory()
          .getVertxMetrics()
          .getServerEndpointMetricMap());
  SpectatorUtils.registerMeter(registry, serverMeter);
}
 
Example 14
Source Project: front50   Source File: DefaultProjectDAO.java    License: Apache License 2.0 6 votes vote down vote up
public DefaultProjectDAO(
    StorageService service,
    Scheduler scheduler,
    ObjectKeyLoader objectKeyLoader,
    long refreshIntervalMs,
    boolean shouldWarmCache,
    Registry registry,
    CircuitBreakerRegistry circuitBreakerRegistry) {
  super(
      ObjectType.PROJECT,
      service,
      scheduler,
      objectKeyLoader,
      refreshIntervalMs,
      shouldWarmCache,
      registry,
      circuitBreakerRegistry);
}
 
Example 15
Source Project: metacat   Source File: MetadataService.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Constructor.
 *
 * @param config              configuration
 * @param tableService        table service
 * @param partitionService    partition service
 * @param userMetadataService user metadata service
 * @param tagService          tag service
 * @param helper              service helper
 * @param registry            registry
 */
public MetadataService(final Config config,
                       final TableService tableService,
                       final PartitionService partitionService,
                       final UserMetadataService userMetadataService,
                       final TagService tagService,
                       final MetacatServiceHelper helper,
                       final Registry registry) {
    this.config = config;
    this.tableService = tableService;
    this.partitionService = partitionService;
    this.userMetadataService = userMetadataService;
    this.tagService = tagService;
    this.helper = helper;
    this.registry = registry;
}
 
Example 16
Source Project: front50   Source File: S3Config.java    License: Apache License 2.0 6 votes vote down vote up
@Bean
@ConditionalOnProperty("spinnaker.s3.eventing.enabled")
public ObjectKeyLoader eventingS3ObjectKeyLoader(
    ObjectMapper objectMapper,
    S3MetadataStorageProperties s3Properties,
    StorageService storageService,
    TemporarySQSQueue temporaryQueueSupport,
    Registry registry) {
  return new EventingS3ObjectKeyLoader(
      Executors.newFixedThreadPool(1),
      objectMapper,
      s3Properties,
      temporaryQueueSupport,
      storageService,
      registry,
      true);
}
 
Example 17
Source Project: metacat   Source File: ServicesConfig.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Partition service bean.
 *
 * @param catalogService       catalog service
 * @param connectorManager     connector manager
 * @param tableService         table service
 * @param userMetadataService  user metadata service
 * @param threadServiceManager thread manager
 * @param config               configurations
 * @param eventBus             Internal event bus
 * @param converterUtil        utility to convert to/from Dto to connector resources
 * @param registry             registry handle
 * @return The partition service implementation to use
 */
@Bean
public PartitionService partitionService(
    final CatalogService catalogService,
    final ConnectorManager connectorManager,
    final TableService tableService,
    final UserMetadataService userMetadataService,
    final ThreadServiceManager threadServiceManager,
    final Config config,
    final MetacatEventBus eventBus,
    final ConverterUtil converterUtil,
    final Registry registry
) {
    return new PartitionServiceImpl(
        catalogService,
        connectorManager,
        tableService,
        userMetadataService,
        threadServiceManager,
        config,
        eventBus,
        converterUtil,
        registry
    );
}
 
Example 18
Source Project: echo   Source File: SQSSubscriber.java    License: Apache License 2.0 6 votes vote down vote up
public SQSSubscriber(
    ObjectMapper objectMapper,
    AmazonPubsubProperties.AmazonPubsubSubscription subscription,
    PubsubMessageHandler pubsubMessageHandler,
    AmazonSNS amazonSNS,
    AmazonSQS amazonSQS,
    Supplier<Boolean> isEnabled,
    Registry registry) {
  this.objectMapper = objectMapper;
  this.subscription = subscription;
  this.pubsubMessageHandler = pubsubMessageHandler;
  this.amazonSNS = amazonSNS;
  this.amazonSQS = amazonSQS;
  this.isEnabled = isEnabled;
  this.registry = registry;

  this.queueARN = new ARN(subscription.getQueueARN());
  this.topicARN = new ARN(subscription.getTopicARN());
}
 
Example 19
Source Project: kork   Source File: StackdriverWriter.java    License: Apache License 2.0 6 votes vote down vote up
/** Add a TimeSeries for each appropriate meter measurement. */
void addMeterToTimeSeries(Registry registry, Meter meter, List<TimeSeries> tsList) {
  Iterable<Measurement> measurements = meter.measure();
  boolean applyFilter = true;

  if (cache.meterIsTimer(registry, meter)) {
    measurements = transformTimerMeasurements(measurements);
    applyFilter = false;
  }
  for (Measurement measurement : measurements) {
    if (applyFilter && !measurementFilter.test(measurement)) {
      continue;
    }

    String descriptorType = cache.idToDescriptorType(measurement.id());
    tsList.add(measurementToTimeSeries(descriptorType, registry, meter, measurement));
  }
}
 
Example 20
Source Project: front50   Source File: CommonStorageServiceDAOConfig.java    License: Apache License 2.0 6 votes vote down vote up
@Bean
ServiceAccountDAO serviceAccountDAO(
    StorageService storageService,
    StorageServiceConfigurationProperties storageServiceConfigurationProperties,
    ObjectKeyLoader objectKeyLoader,
    Registry registry,
    CircuitBreakerRegistry circuitBreakerRegistry) {
  return new DefaultServiceAccountDAO(
      storageService,
      Schedulers.from(
          Executors.newFixedThreadPool(
              storageServiceConfigurationProperties.getServiceAccount().getThreadPool())),
      objectKeyLoader,
      storageServiceConfigurationProperties.getServiceAccount().getRefreshMs(),
      storageServiceConfigurationProperties.getServiceAccount().getShouldWarmCache(),
      registry,
      circuitBreakerRegistry);
}
 
Example 21
Source Project: spectator   Source File: BucketDistributionSummaryTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void basic() {
  Registry r = new DefaultRegistry();
  BucketDistributionSummary c = BucketDistributionSummary.get(
      r, r.createId("test"), BucketFunctions.latency(4, TimeUnit.SECONDS));

  c.record(TimeUnit.MILLISECONDS.toNanos(3750));
  Assertions.assertEquals(1, r.distributionSummaries().count());
  Assertions.assertEquals(1, sum(r, "test"));

  c.record(TimeUnit.MILLISECONDS.toNanos(4221));
  Assertions.assertEquals(2, r.distributionSummaries().count());
  Assertions.assertEquals(2, sum(r, "test"));

  c.record(TimeUnit.MILLISECONDS.toNanos(4221));
  Assertions.assertEquals(2, r.distributionSummaries().count());
  Assertions.assertEquals(3, sum(r, "test"));
}
 
Example 22
Source Project: front50   Source File: DefaultNotificationDAO.java    License: Apache License 2.0 6 votes vote down vote up
public DefaultNotificationDAO(
    StorageService service,
    Scheduler scheduler,
    ObjectKeyLoader objectKeyLoader,
    long refreshIntervalMs,
    boolean shouldWarmCache,
    Registry registry,
    CircuitBreakerRegistry circuitBreakerRegistry) {
  super(
      ObjectType.NOTIFICATION,
      service,
      scheduler,
      objectKeyLoader,
      refreshIntervalMs,
      shouldWarmCache,
      registry,
      circuitBreakerRegistry);
}
 
Example 23
Source Project: mantis   Source File: GaugeCallback.java    License: Apache License 2.0 5 votes vote down vote up
public GaugeCallback(final MetricId metricId,
                     final Func0<Double> valueCallback,
                     final Registry registry) {
    this.metricId = metricId;
    this.spectatorId = metricId.getSpectatorId(registry);
    PolledMeter.using(registry).withId(spectatorId).monitorValue(this, GaugeCallback::doubleValue);
    this.valueCallback = valueCallback;
}
 
Example 24
@VisibleForTesting
DefaultAvailableCapacityService(CapacityManagementConfiguration configuration,
                                ServerInfoResolver serverInfoResolver,
                                AgentManagementService agentManagementService,
                                Registry registry,
                                Scheduler scheduler) {
    this.configuration = configuration;
    this.serverInfoResolver = serverInfoResolver;
    this.agentManagementService = agentManagementService;
    this.worker = scheduler.createWorker();
    this.metrics = new ExecutionMetrics(METRIC_AVAILABLE_CAPACITY_UPDATE, DefaultAvailableCapacityService.class, registry);
}
 
Example 25
Source Project: titus-control-plane   Source File: FsmMetricsImpl.java    License: Apache License 2.0 5 votes vote down vote up
FsmMetricsImpl(Id rootId,
               Function<S, String> nameOf,
               Function<S, Boolean> finalStateEval,
               S initialState,
               Registry registry) {
    this.nameOf = nameOf;
    this.finalStateEval = finalStateEval;
    this.registry = registry;

    String effectiveRootName = rootId.name().endsWith(".") ? rootId.name() : rootId.name() + '.';
    this.baseStateId = registry.createId(effectiveRootName + "currentState", rootId.tags());
    this.baseUpdatesId = registry.createId(effectiveRootName + "updates", rootId.tags());
    this.currentState = new AtomicReference<>(new StateHolder(initialState, ""));
}
 
Example 26
Source Project: spectator   Source File: Main.java    License: Apache License 2.0 5 votes vote down vote up
/** Run a test and output the memory footprint of the registry. */
@SuppressWarnings("PMD")
public static void main(String[] args) {
  if (args.length < 2) {
    System.out.println("Usage: perf <registry> <test>");
    System.exit(1);
  }

  Registry registry = run(args[0], args[1]);

  GraphLayout igraph = GraphLayout.parseInstance(registry);
  System.out.println(igraph.toFootprint());
}
 
Example 27
Source Project: titus-control-plane   Source File: ScheduleMetrics.java    License: Apache License 2.0 5 votes vote down vote up
ScheduleMetrics(Schedule schedule, Clock clock, Registry registry) {
    this.lastSchedule = schedule;
    this.clock = clock;
    this.registry = registry;

    this.currentState = SpectatorExt.fsmMetrics(
            registry.createId(ROOT_NAME + "scheduleState", "scheduleName", schedule.getDescriptor().getName()),
            SchedulingState::isFinal,
            SchedulingState.Waiting,
            registry
    );
    this.successes = registry.counter(ROOT_NAME + "executions",
            "scheduleName", schedule.getDescriptor().getName(),
            "status", "succeeded"
    );
    this.failures = registry.counter(ROOT_NAME + "executions",
            "scheduleName", schedule.getDescriptor().getName(),
            "status", "failed"
    );

    this.waitingId = registry.createId(ROOT_NAME + "waitingTimeMs", "scheduleName", schedule.getDescriptor().getName());
    PolledMeter.using(registry)
            .withId(waitingId)
            .monitorValue(this, self -> howLongInState(SchedulingState.Waiting));
    this.runningId = registry.createId(ROOT_NAME + "runningTimeMs", "scheduleName", schedule.getDescriptor().getName());
    PolledMeter.using(registry)
            .withId(runningId)
            .monitorValue(this, self -> howLongInState(SchedulingState.Running));
    this.cancellingId = registry.createId(ROOT_NAME + "cancellingTimeMs", "scheduleName", schedule.getDescriptor().getName());
    PolledMeter.using(registry)
            .withId(cancellingId)
            .monitorValue(this, self -> howLongInState(SchedulingState.Cancelling));
}
 
Example 28
public SpectatorTokenBucketDecorator(TokenBucket delegate, TitusRuntime titusRuntime) {
    super(delegate);

    Registry registry = titusRuntime.getRegistry();

    this.takeSuccessCounter = registry.counter(
            NAME_PREFIX + "tokenRequest",
            "bucketName", delegate.getName(),
            "success", "true"
    );
    this.takeFailureCounter = registry.counter(
            NAME_PREFIX + "tokenRequest",
            "bucketName", delegate.getName(),
            "success", "false"
    );

    PolledMeter.using(registry).withId(registry.createId(
            NAME_PREFIX + "capacity",
            "bucketName", delegate.getName(),
            "available", "false"
    )).monitorValue(this, self -> self.getCapacity() - self.getNumberOfTokens());
    PolledMeter.using(registry).withId(registry.createId(
            NAME_PREFIX + "capacity",
            "bucketName", delegate.getName(),
            "available", "true"
    )).monitorValue(this, TokenBucketDelegate::getNumberOfTokens);
}
 
Example 29
Source Project: spectator   Source File: PolledMeterTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void monitorStaticMethodMonotonicCounter() {
  Registry r = new DefaultRegistry();
  Id id = r.createId("test");

  PolledMeter.using(r)
      .withId(id)
      .monitorStaticMethodMonotonicCounter(PolledMeterTest::testCounter);
  PolledMeter.update(r);
  PolledMeter.update(r);
  PolledMeter.update(r);
  PolledMeter.update(r);

  Assertions.assertEquals(4, r.counter(id).count());
}
 
Example 30
Source Project: metacat   Source File: ElasticSearchEventHandlers.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Constructor.
 *
 * @param es       elastic search util
 * @param registry registry to spectator
 * @param config   configurations
 */
public ElasticSearchEventHandlers(final ElasticSearchUtil es,
                                  final Registry registry,
                                  final Config config) {
    this.es = es;
    this.metacatJsonLocator = new MetacatJsonLocator();
    this.config = config;
    this.databaseCreateEventsDelayTimer = registry.timer(Metrics.TimerElasticSearchEventsDelay.getMetricName(),
        Metrics.TagEventsType.getMetricName(), "database.create");
    this.databaseCreateTimer = registry.timer(Metrics.TimerElasticSearchDatabaseCreate.getMetricName());
    this.tableCreateEventsDelayTimer = registry.timer(Metrics.TimerElasticSearchEventsDelay.getMetricName(),
        Metrics.TagEventsType.getMetricName(), "table.create");
    this.tableCreateTimer = registry.timer(Metrics.TimerElasticSearchTableCreate.getMetricName());
    this.databaseDeleteEventsDelayTimer = registry.timer(Metrics.TimerElasticSearchEventsDelay.getMetricName(),
        Metrics.TagEventsType.getMetricName(), "database.delete");
    this.databaseDeleteTimer = registry.timer(Metrics.TimerElasticSearchDatabaseDelete.getMetricName());
    this.tableDeleteEventsDelayTimer = registry.timer(Metrics.TimerElasticSearchEventsDelay.getMetricName(),
        Metrics.TagEventsType.getMetricName(), "table.delete");
    this.tableDeleteTimer = registry.timer(Metrics.TimerElasticSearchTableDelete.getMetricName());
    this.partitionDeleteEventsDelayTimer = registry.timer(Metrics.TimerElasticSearchEventsDelay.getMetricName(),
        Metrics.TagEventsType.getMetricName(), "partition.delete");
    this.partitionDeleteTimer = registry.timer(Metrics.TimerElasticSearchPartitionDelete.getMetricName());
    this.tableRenameEventsDelayTimer = registry.timer(Metrics.TimerElasticSearchEventsDelay.getMetricName(),
        Metrics.TagEventsType.getMetricName(), "table.rename");
    this.tableRenameTimer = registry.timer(Metrics.TimerElasticSearchTableRename.getMetricName());
    this.tableUpdateEventsDelayTimer = registry.timer(Metrics.TimerElasticSearchEventsDelay.getMetricName(),
        Metrics.TagEventsType.getMetricName(), "table.update");
    this.tableUpdateTimer = registry.timer(Metrics.TimerElasticSearchTableUpdate.getMetricName());
    this.partitionSaveEventsDelayTimer = registry.timer(Metrics.TimerElasticSearchEventsDelay.getMetricName(),
        Metrics.TagEventsType.getMetricName(), "partition.save");
    this.partitionSaveTimer = registry.timer(Metrics.TimerElasticSearchPartitionSave.getMetricName());
}