com.netflix.spectator.api.patterns.PolledMeter Java Examples

The following examples show how to use com.netflix.spectator.api.patterns.PolledMeter. 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: MesosStateTracker.java    From titus-control-plane with Apache License 2.0 6 votes vote down vote up
MesosStateTracker(MasterConfiguration configuration, TitusRuntime titusRuntime, Scheduler scheduler) {

        this.knownTasks = CacheBuilder.newBuilder()
                .expireAfterWrite(configuration.getMesosTaskReconciliationIntervalSecs() * 2, TimeUnit.SECONDS)
                .build();
        this.unknownTasks = CacheBuilder.newBuilder()
                .expireAfterWrite(configuration.getMesosTaskReconciliationIntervalSecs() * 4, TimeUnit.SECONDS)
                .build();
        this.titusRuntime = titusRuntime;

        Registry registry = titusRuntime.getRegistry();
        PolledMeter.using(registry).withId(registry.createId(TASKS_METRIC_ID, "known", "true")).monitorValue(this, self -> self.knownTasks.size());
        PolledMeter.using(registry).withId(registry.createId(TASKS_METRIC_ID, "known", "false", "onlyStable", "false")).monitorValue(this, self -> self.unknownTasks.size());
        PolledMeter.using(registry).withId(registry.createId(TASKS_METRIC_ID, "known", "false", "onlyStable", "true")).monitorValue(this, self -> countStableUnknown());

        this.reporterSubscription = ObservableExt.schedule(
                "titus.mesos.stateTracker",
                registry,
                "mesosStateTrackerReporter",
                Completable.fromAction(this::doReport),
                REPORTING_INTERVAL_MS,
                REPORTING_INTERVAL_MS,
                TimeUnit.MILLISECONDS,
                scheduler
        ).subscribe();
    }
 
Example #2
Source File: ReconciliationEngineMetrics.java    From titus-control-plane with Apache License 2.0 6 votes vote down vote up
ReconciliationEngineMetrics(Function<ChangeAction, List<Tag>> extraChangeActionTags,
                            Function<EVENT, List<Tag>> extraModelActionTags,
                            Registry registry,
                            Clock clock) {
    this.extraChangeActionTags = extraChangeActionTags;
    this.extraModelActionTags = extraModelActionTags;
    this.registry = registry;
    this.clock = clock;

    List<Tag> commonTags = Collections.emptyList();
    this.evaluationId = registry.createId(EVALUATIONS, commonTags);
    this.startedChangeActionsId = registry.createId(STARTED_CHANGE_ACTIONS, commonTags);
    this.finishedChangeActionId = registry.createId(FINISHED_CHANGE_ACTIONS, commonTags);
    this.emittedEventId = registry.createId(EMITTED_EVENTS, commonTags);

    this.changeActionQueueSize = registry.gauge(registry.createId(ROOT_NAME + "changeActionQueueSize", commonTags));
    PolledMeter.using(registry).withName(PENDING_CHANGE_ACTIONS).withTags(commonTags).monitorValue(pendingChangeActions);
}
 
Example #3
Source File: CuratorServiceImpl.java    From titus-control-plane with Apache License 2.0 6 votes vote down vote up
@Inject
public CuratorServiceImpl(ZookeeperConfiguration configs, ZookeeperClusterResolver clusterResolver, Registry registry) {
    isConnectedGauge = PolledMeter.using(registry).withName("titusMaster.curator.isConnected").monitorValue(new AtomicInteger());

    Optional<String> connectString = clusterResolver.resolve();
    if (!connectString.isPresent()) {
        // Fail early if connection to zookeeper not defined
        LOG.error("Zookeeper connectivity details not found");
        throw new IllegalStateException("Zookeeper connectivity details not found");
    }
    curator = CuratorFrameworkFactory.builder()
            .compressionProvider(new GzipCompressionProvider())
            .connectionTimeoutMs(configs.getZkConnectionTimeoutMs())
            .retryPolicy(new ExponentialBackoffRetry(configs.getZkConnectionRetrySleepMs(), configs.getZkConnectionMaxRetries()))
            .connectString(connectString.get())
            .build();
}
 
Example #4
Source File: FiatStatus.java    From fiat with 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 #5
Source File: KubeInformerMetrics.java    From titus-control-plane with Apache License 2.0 6 votes vote down vote up
public KubeInformerMetrics(String type,
                           SharedIndexInformer<ApiType> informer,
                           TitusRuntime titusRuntime) {
    this.titusRuntime = titusRuntime;
    this.sizeGaugeId = titusRuntime.getRegistry().createId(METRICS_INFORMER, "type", type);
    this.syncedGaugeId = titusRuntime.getRegistry().createId(METRICS_INFORMER_SYNCED, "type", type);
    this.stalenessGaugeId = titusRuntime.getRegistry().createId(METRICS_INFORMER_STALENESS, "type", type);

    PolledMeter.using(titusRuntime.getRegistry())
            .withId(sizeGaugeId)
            .monitorValue(informer, i -> i.getIndexer().list().size());
    PolledMeter.using(titusRuntime.getRegistry())
            .withId(syncedGaugeId)
            .monitorValue(informer, i -> i.hasSynced() ? 1 : 0);
    PolledMeter.using(titusRuntime.getRegistry())
            .withId(stalenessGaugeId)
            .monitorValue(informer, i -> informer.hasSynced() ? 0 : -1);
}
 
Example #6
Source File: PipelineCache.java    From echo with Apache License 2.0 6 votes vote down vote up
@PostConstruct
public void start() {
  running = true;

  executorService.scheduleWithFixedDelay(
      new Runnable() {
        @Override
        public void run() {
          pollPipelineConfigs();
        }
      },
      0,
      pollingIntervalMs,
      TimeUnit.MILLISECONDS);

  PolledMeter.using(registry)
      .withName("front50.lastPoll")
      .monitorValue(this, PipelineCache::getDurationSeconds);
}
 
Example #7
Source File: ClusterMembershipServiceMetrics.java    From titus-control-plane with Apache License 2.0 6 votes vote down vote up
ClusterMembershipServiceMetrics(TitusRuntime titusRuntime) {
    // known members count
    this.registry = titusRuntime.getRegistry();
    this.clock = titusRuntime.getClock();
    this.healthFsmMetrics = SpectatorExt.fsmMetrics(
            registry.createId(METRIC_ROOT + "localHealthState"),
            s -> false,
            HealthState.Unknown,
            registry
    );
    this.leadershipFsmMetrics = SpectatorExt.fsmMetrics(
            registry.createId(METRIC_ROOT + "localLeadershipState"),
            s -> false,
            ClusterMemberLeadershipState.Unknown,
            registry
    );

    this.knownSiblingsId = registry.createId(METRIC_ROOT + "knownSiblings");
    this.siblingStalenessId = registry.createId(METRIC_ROOT + "siblingStaleness");
    PolledMeter.using(registry).withId(knownSiblingsId).monitorValue(knownSiblingsCounter);
}
 
Example #8
Source File: TitusClientImpl.java    From titus-control-plane with Apache License 2.0 6 votes vote down vote up
private void configureMetrics() {
    PolledMeter.using(registry)
            .withId(registry.createId(EsTaskPublisherMetrics.METRIC_ES_PUBLISHER + "titusApi.errors"))
            .monitorValue(apiErrors);
    PolledMeter.using(registry)
            .withId(registry.createId(EsTaskPublisherMetrics.METRIC_ES_PUBLISHER + "titusApi.numSnapshotUpdates"))
            .monitorValue(numSnapshotUpdates);
    PolledMeter.using(registry)
            .withId(registry.createId(EsTaskPublisherMetrics.METRIC_ES_PUBLISHER + "titusApi.numTaskUpdates"))
            .monitorValue(numTaskUpdates);
    PolledMeter.using(registry)
            .withId(registry.createId(EsTaskPublisherMetrics.METRIC_ES_PUBLISHER + "titusApi.numJobUpdates"))
            .monitorValue(numJobUpdates);
    PolledMeter.using(registry)
            .withId(registry.createId(EsTaskPublisherMetrics.METRIC_ES_PUBLISHER + "titusApi.numMissingJobUpdate"))
            .monitorValue(numMissingJobUpdate);
}
 
Example #9
Source File: ThreadPoolMetersInitializer.java    From servicecomb-java-chassis with Apache License 2.0 6 votes vote down vote up
protected void createThreadPoolMeters(String threadPoolName, Executor executor) {
  if (!ThreadPoolExecutor.class.isInstance(executor)) {
    return;
  }

  ThreadPoolMonitor.attach(registry, (ThreadPoolExecutor) executor, threadPoolName);

  if (executor instanceof ThreadPoolExecutorEx) {
    Tag idTag = new BasicTag("id", threadPoolName);

    PolledMeter.using(registry)
        .withName(REJECTED_COUNT)
        .withTag(idTag)
        .monitorMonotonicCounter((ThreadPoolExecutorEx) executor, ThreadPoolExecutorEx::getRejectedCount);
  }
}
 
Example #10
Source File: MultiNodeClusterMemberResolverMetrics.java    From titus-control-plane with Apache License 2.0 6 votes vote down vote up
private DirectConnection(String ipAddress, DirectClusterMemberResolver directResolver) {
    this.startTime = clock.wallTime();
    this.directResolver = directResolver;

    this.connectionHealthId = registry.createId(
            ROOT + "directConnection.health",
            "service", serviceName,
            "memberIp", ipAddress
    );
    this.connectionTimeId = registry.createId(
            ROOT + "directConnection.time",
            "service", serviceName,
            "memberIp", ipAddress
    );

    PolledMeter.using(registry).withId(connectionHealthId).monitorValue(this, self ->
            closed ? 0 : (self.directResolver.isHealthy() ? 1 : 0)
    );
    PolledMeter.using(registry).withId(connectionTimeId).monitorValue(this, self ->
            closed ? 0 : (clock.wallTime() - self.startTime)
    );
}
 
Example #11
Source File: SystemQuotaMetrics.java    From titus-control-plane with Apache License 2.0 6 votes vote down vote up
SystemQuotaMetrics(SystemQuotaController systemQuotaController, TitusRuntime titusRuntime) {
    this.registry = titusRuntime.getRegistry();

    this.tokenBucketCapacityId = registry.createId(ROOT_NAME + "tokenBucket.capacity");
    PolledMeter.using(registry)
            .withId(tokenBucketCapacityId)
            .monitorValue(systemQuotaController, sqc -> systemQuotaController.getDisruptionBudget().getTokenBucketPolicy().getCapacity());
    this.tokenBucketRefillRateId = registry.createId(ROOT_NAME + "tokenBucket.refillRatePerSec");
    PolledMeter.using(registry)
            .withId(tokenBucketRefillRateId)
            .monitorValue(systemQuotaController, sqc -> {
                TokenBucketRefillPolicy refillPolicy = systemQuotaController.getDisruptionBudget().getTokenBucketPolicy().getRefillPolicy();
                if (refillPolicy instanceof FixedIntervalTokenBucketRefillPolicy) {
                    FixedIntervalTokenBucketRefillPolicy fixed = (FixedIntervalTokenBucketRefillPolicy) refillPolicy;
                    return fixed.getNumberOfTokensPerInterval() / (fixed.getIntervalMs() / 1000D);
                }
                return 0;
            });

    this.quotaLevelId = registry.createId(ROOT_NAME + "available");
    PolledMeter.using(registry)
            .withId(quotaLevelId)
            .monitorValue(systemQuotaController, sqc -> systemQuotaController.getQuota(Reference.system()).getQuota());
}
 
Example #12
Source File: DirectMemoryMonitor.java    From zuul with Apache License 2.0 6 votes vote down vote up
@Inject
public DirectMemoryMonitor(Registry registry) {
    if (reservedMemoryGetter != null) {
        PolledMeter.using(registry)
                .withName(PROP_PREFIX + ".reserved")
                .withDelay(Duration.ofSeconds(TASK_DELAY_PROP.get()))
                .scheduleOn(service)
                .monitorValue(DirectMemoryMonitor.class, DirectMemoryMonitor::getReservedMemory);
    }
    if (directMemoryLimitGetter != null) {
        PolledMeter.using(registry)
                .withName(PROP_PREFIX + ".max")
                .withDelay(Duration.ofSeconds(TASK_DELAY_PROP.get()))
                .scheduleOn(service)
                .monitorValue(DirectMemoryMonitor.class, DirectMemoryMonitor::getMaxMemory);
    }
}
 
Example #13
Source File: MetricsControllerTest.java    From spectator with Apache License 2.0 6 votes vote down vote up
@Test
public void testEncodeCombinedRegistry() {
  // Multiple occurrences of measurements in the same registry
  // (confirm these are handled within the registry itself).
  Measurement measureBXY2 = new Measurement(idBXY, 5, 5.5);
  Meter meterB2 = new TestMeter("ignoreB", measureBXY2);

  DefaultRegistry registry = new DefaultRegistry(clock);
  registry.register(meterB);
  registry.register(meterB2);

  List<TaggedDataPoints> expectedTaggedDataPoints = Arrays.asList(
     new TaggedDataPoints(
           Arrays.asList(new BasicTag("tagA", "X"),
                         new BasicTag("tagB", "Y")),
           Arrays.asList(new DataPoint(clock.wallTime(), 50.5 + 5.5))));

  HashMap<String, MetricValues> expect = new HashMap<>();
  expect.put("idB", new MetricValues("Counter", expectedTaggedDataPoints));

  PolledMeter.update(registry);
  Assertions.assertEquals(expect, controller.encodeRegistry(registry, allowAll));
}
 
Example #14
Source File: SpectatorRefillStrategyDecorator.java    From titus-control-plane with Apache License 2.0 6 votes vote down vote up
public SpectatorRefillStrategyDecorator(String bucketName,
                                        RefillStrategy delegate,
                                        TitusRuntime titusRuntime) {
    this.delegate = delegate;

    this.registry = titusRuntime.getRegistry();
    this.refillCounter = registry.counter(
            NAME_PREFIX + "refillCount",
            "bucketName", bucketName
    );
    this.timeUntilNextRefillId = registry.createId(
            NAME_PREFIX + "timeUntilNextRefill",
            "bucketName", bucketName
    );
    PolledMeter.using(registry)
            .withId(timeUntilNextRefillId)
            .monitorValue(this, self -> self.getTimeUntilNextRefill(TimeUnit.MILLISECONDS));
}
 
Example #15
Source File: SchedulerMetrics.java    From titus-control-plane with Apache License 2.0 6 votes vote down vote up
SchedulerMetrics(DefaultLocalScheduler scheduler, Clock clock, Registry registry) {
    this.clock = clock;
    this.registry = registry;
    this.scheduler = scheduler;
    this.lastEvaluationTime = clock.wallTime();

    this.activeSchedulesId = registry.createId(ScheduleMetrics.ROOT_NAME + "active");
    PolledMeter.using(registry)
            .withId(activeSchedulesId)
            .monitorValue(this, self -> self.scheduler.getActiveSchedules().size());
    this.archivedSchedulesId = registry.createId(ScheduleMetrics.ROOT_NAME + "archived");
    PolledMeter.using(registry)
            .withId(activeSchedulesId)
            .monitorValue(this, self -> self.scheduler.getArchivedSchedules().size());

    this.evaluationTimer = registry.timer(ScheduleMetrics.ROOT_NAME + "evaluationTime");
    this.lastEvaluationId = registry.createId(ScheduleMetrics.ROOT_NAME + "lastEvaluationMs");
    PolledMeter.using(registry)
            .withId(lastEvaluationId)
            .monitorValue(this, self -> self.clock.wallTime() - self.lastEvaluationTime);
}
 
Example #16
Source File: RegistryTest.java    From spectator with Apache License 2.0 5 votes vote down vote up
@Test
public void uncaughtExceptionFromGaugeFunction() {
  Assertions.assertThrows(RuntimeException.class, () -> {
    Registry registry = new DefaultRegistry();
    PolledMeter.using(registry)
        .withName("test")
        .monitorValue(new RuntimeException("failure"), value -> {
          throw value;
        });
    PolledMeter.update(registry);
  });
}
 
Example #17
Source File: CompositeRegistryTest.java    From spectator with Apache License 2.0 5 votes vote down vote up
@Test
public void testRegister() {
  Registry r = newRegistry(5, true);
  Counter c = new DefaultCounter(clock, r.createId("foo"));
  r.register(c);
  c.increment();
  Assertions.assertEquals(c.count(), 1L);
  r.register(c);
  PolledMeter.update(r);
  Meter meter = r.get(c.id());
  for (Measurement m : meter.measure()) {
    Assertions.assertEquals(m.value(), 2.0, 1e-12);
  }
}
 
Example #18
Source File: MetricsControllerTest.java    From spectator with Apache License 2.0 5 votes vote down vote up
@Test
public void testEncodeCompositeRegistry() {
  // Multiple occurrences of measurements in the same registry
  // (confirm these are handled within the registry itself).
  // Here measurements are duplicated but meters have different sets.
  Measurement measureAXY2 = new Measurement(idAXY, 20, 20.20);
  Meter meterA2 = new TestMeter("ignoreA", measureAXY2);

  DefaultRegistry registry = new DefaultRegistry(clock);
  registry.register(meterA);
  registry.register(meterA2);

  List<TaggedDataPoints> expectedDataPoints = Arrays.asList(
      new TaggedDataPoints(
          Arrays.asList(new BasicTag("tagA", "X"), new BasicTag("tagZ", "Z")),
          Arrays.asList(new DataPoint(clock.wallTime(), 13.13))),
      new TaggedDataPoints(
          Arrays.asList(new BasicTag("tagA", "X"), new BasicTag("tagB", "Y")),
          Arrays.asList(new DataPoint(clock.wallTime(), 11.11 + 20.20))),
      new TaggedDataPoints(
          Arrays.asList(new BasicTag("tagA", "Y"), new BasicTag("tagB", "X")),
          Arrays.asList(new DataPoint(clock.wallTime(), 12.12)))
  );

  HashMap<String, MetricValues> expect = new HashMap<>();
  expect.put("idA", new MetricValues("Counter", expectedDataPoints));

  PolledMeter.update(registry);
  Assertions.assertEquals(expect, controller.encodeRegistry(registry, allowAll));
}
 
Example #19
Source File: RegistryTest.java    From spectator with Apache License 2.0 5 votes vote down vote up
@Test
public void defaultResetRemovesState() {
  DefaultRegistry r = newRegistry(true, 10000);
  AtomicInteger v = new AtomicInteger();
  PolledMeter.using(r).withName("test").monitorValue(v);
  PolledMeter.update(r);
  Assertions.assertEquals(1, r.stream().count());
  Assertions.assertEquals(1, r.state().size());
  r.reset();
  PolledMeter.update(r);
  Assertions.assertEquals(0, r.stream().count());
  Assertions.assertEquals(0, r.state().size());
}
 
Example #20
Source File: RegistryTest.java    From spectator with Apache License 2.0 5 votes vote down vote up
private void assertLongTaskTimer(Registry r, Id id, long timestamp, int activeTasks, double duration) {
  PolledMeter.update(r);

  Gauge g = r.gauge(id.withTag(Statistic.activeTasks));
  Assertions.assertEquals(timestamp, g.measure().iterator().next().timestamp());
  Assertions.assertEquals(activeTasks, g.value(), 1.0e-12);

  g = r.gauge(id.withTag(Statistic.duration));
  Assertions.assertEquals(timestamp, g.measure().iterator().next().timestamp());
  Assertions.assertEquals(duration, g.value(), 1.0e-12);
}
 
Example #21
Source File: MetricsControllerTest.java    From spectator with Apache License 2.0 5 votes vote down vote up
@Test
public void testIgnoreNan() {
  Id id = idB.withTag("tagA", "Z");
  Measurement measure = new Measurement(id, 100, Double.NaN);
  Meter meter = new TestMeter("ignoreZ", measure);

  DefaultRegistry registry = new DefaultRegistry(clock);
  registry.register(meter);

  HashMap<String, MetricValues> expect = new HashMap<>();
  PolledMeter.update(registry);
  Assertions.assertEquals(expect, controller.encodeRegistry(registry, allowAll));
}
 
Example #22
Source File: MultiNodeClusterMemberResolverMetrics.java    From titus-control-plane with Apache License 2.0 5 votes vote down vote up
@Override
public void close() {
    closed = true;
    PolledMeter.update(registry);

    PolledMeter.remove(registry, leaderTimeId);
}
 
Example #23
Source File: SpectatorTokenBucketDecorator.java    From titus-control-plane with Apache License 2.0 5 votes vote down vote up
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 #24
Source File: RateLimitedBatcher.java    From titus-control-plane with Apache License 2.0 5 votes vote down vote up
/**
 * start the continuous loop
 */
public void run() {
    PolledMeter.using(registry)
            .withName(metricsRoot + ".pending")
            // TODO: size() does a O(N) scan, optimize it
            .monitorValue(pending, ConcurrentHashMultimap::size);
    worker.schedule(ACTION_FLUSH, this::flushPending, currentDelayMs.get(), TimeUnit.MILLISECONDS);
}
 
Example #25
Source File: ErrorStatsData.java    From zuul with Apache License 2.0 5 votes vote down vote up
/**
 * create a counter by route and cause of error
 * @param route
 * @param cause
 */
public ErrorStatsData(String route, String cause) {
    if(null == route || "".equals(route)){
        route = "UNKNOWN";
    }
    id = route + "_" + cause;

    this.errorCause = cause;
    Registry registry = Spectator.globalRegistry();
    PolledMeter.using(registry)
            .withId(registry.createId("zuul.ErrorStatsData", "ID", id))
            .monitorValue(this, ErrorStatsData::getCount);
}
 
Example #26
Source File: InstrumentedEventLoop.java    From titus-control-plane with Apache License 2.0 5 votes vote down vote up
public InstrumentedEventLoop(String metricNameRoot, Registry registry, Scheduler scheduler) {
    this.metricNameRoot = metricNameRoot;
    this.registry = registry;
    this.worker = scheduler.createWorker();
    this.actionMetrics = new ConcurrentHashMap<>();
    this.actionsRemaining = new AtomicLong(0);
    this.actionsRemainingId = registry.createId(metricNameRoot + ".eventLoop.actionsRemaining");

    PolledMeter.using(registry)
            .withId(this.actionsRemainingId)
            .monitorValue(this.actionsRemaining);
}
 
Example #27
Source File: ExecutionMetrics.java    From titus-control-plane with Apache License 2.0 5 votes vote down vote up
public ExecutionMetrics(String root, Class<?> aClass, Registry registry, List<Tag> additionalTags) {
    this.root = root;
    this.registry = registry;
    this.commonTags = CollectionsExt.copyAndAdd(additionalTags, new BasicTag("class", aClass.getSimpleName()));

    this.successCounter = registry.counter(registry.createId(root, commonTags).withTag("status", "success"));
    this.errorCounter = registry.counter(registry.createId(root, commonTags).withTag("status", "failure"));

    Id successLatencyId = registry.createId(root + ".latency", commonTags).withTag("status", "success");
    PolledMeter.using(registry).withId(successLatencyId).monitorValue(successLatency);
    Id failureLatencyId = registry.createId(root + ".latency", commonTags).withTag("status", "failure");
    PolledMeter.using(registry).withId(failureLatencyId).monitorValue(failureLatency);
}
 
Example #28
Source File: GaugeCallback.java    From mantis with 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 #29
Source File: ContinuousSubscriptionMetrics.java    From titus-control-plane with Apache License 2.0 5 votes vote down vote up
ContinuousSubscriptionMetrics(String root, List<Tag> commonTags, Registry registry) {
    this.registry = registry;
    this.latency = registry.timer(root + ".latency", commonTags);
    this.shouldRemove = new AtomicBoolean(false);
    this.hasSubscribed = new AtomicBoolean(false);
    this.latencyStart = new AtomicLong(0);
    this.lastCompleteTimestamp = new AtomicLong(registry.clock().wallTime());
    this.timeSinceLastCompleteId = registry.createId(root + ".timeSinceLastComplete", commonTags);

    PolledMeter.using(registry)
            .withId(timeSinceLastCompleteId)
            .monitorValue(this, ContinuousSubscriptionMetrics::getTimeSinceLastComplete);

    asCompletable = new CompletableTransformer();
}
 
Example #30
Source File: ActionMetrics.java    From titus-control-plane with Apache License 2.0 5 votes vote down vote up
public ActionMetrics(Id rootId, Registry registry) {
    this.root = rootId.name();
    this.commonTags = rootId.tags();
    this.registry = registry;
    this.successCounter = registry.counter(registry.createId(root, commonTags).withTag("status", "success"));

    this.latencyTimerOnSuccess = registry.timer(registry.createId(root + ".latency", commonTags).withTag("status", "success"));
    this.latencyTimerOnError = registry.timer(registry.createId(root + ".latency", commonTags).withTag("status", "failure"));

    this.sinceLastExecutionId = registry.createId(root + ".sinceLastCompletion", commonTags);
    this.lastCompletionRef = new AtomicLong(registry.clock().wallTime());
    PolledMeter.using(registry).withId(sinceLastExecutionId).monitorValue(lastCompletionRef);
}