Java Code Examples for org.apache.samza.metrics.MetricsRegistry#newCounter()

The following examples show how to use org.apache.samza.metrics.MetricsRegistry#newCounter() . 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: BlockingEnvelopeMap.java    From samza with Apache License 2.0 5 votes vote down vote up
public BlockingEnvelopeMapMetrics(String group, MetricsRegistry metricsRegistry) {
  this.group = group;
  this.metricsRegistry = metricsRegistry;
  this.noMoreMessageGaugeMap = new ConcurrentHashMap<SystemStreamPartition, Gauge<Integer>>();
  this.blockingPollCountMap = new ConcurrentHashMap<SystemStreamPartition, Counter>();
  this.blockingPollTimeoutCountMap = new ConcurrentHashMap<SystemStreamPartition, Counter>();
  this.pollCount = metricsRegistry.newCounter(group, "poll-count");
}
 
Example 2
Source File: AzureBlobBasicMetrics.java    From samza with Apache License 2.0 5 votes vote down vote up
public AzureBlobBasicMetrics(String group, MetricsRegistry metricsRegistry) {
  writeMetrics = metricsRegistry.newCounter(group, EVENT_WRITE_RATE);
  errorMetrics = metricsRegistry.newCounter(group, EVENT_PRODUCE_ERROR);
  writeByteMetrics = metricsRegistry.newCounter(group, EVENT_WRITE_BYTE_RATE);
  compressByteMetrics = metricsRegistry.newCounter(group, EVENT_COMPRESS_BYTE_RATE);
  azureUploadMetrics = metricsRegistry.newCounter(group, AZURE_BLOCK_UPLOAD_RATE);
  azureCommitMetrics = metricsRegistry.newCounter(group, AZURE_BLOB_COMMIT_RATE);
}
 
Example 3
Source File: AzureBlobSystemProducerMetrics.java    From samza with Apache License 2.0 5 votes vote down vote up
public AzureBlobSystemProducerMetrics(String systemName, String accountName, MetricsRegistry metricsRegistry) {
  this.metricsRegistry = metricsRegistry;
  this.systemName = systemName;
  this.accountName = accountName;

  sourceMetricsMap = new HashMap<>();
  aggregateMetrics = new AzureBlobBasicMetrics(AGGREGATE, metricsRegistry);
  systemMetrics = new AzureBlobBasicMetrics(String.format(SYSTEM_METRIC_FORMAT, accountName, systemName), metricsRegistry);
  aggregateAzureContainerErrorMetrics = metricsRegistry.newCounter(AGGREGATE, AZURE_CONTAINER_ERROR);
  systemAzureContainerErrorMetrics = metricsRegistry.newCounter(String.format(SYSTEM_METRIC_FORMAT, accountName, systemName), AZURE_CONTAINER_ERROR);
}
 
Example 4
Source File: EventHubSystemConsumer.java    From samza with Apache License 2.0 5 votes vote down vote up
EventHubSystemConsumer(EventHubConfig config, String systemName,
    EventHubClientManagerFactory eventHubClientManagerFactory, Map<String, Interceptor> interceptors,
    MetricsRegistry registry, Clock clock) {
  super(registry, clock);

  this.config = config;
  this.clock = clock;
  this.systemName = systemName;
  this.interceptors = interceptors;
  this.eventHubClientManagerFactory = eventHubClientManagerFactory;
  List<String> streamIds = config.getStreams(systemName);
  prefetchCount = config.getPrefetchCount(systemName);

  recentRetryAttempts = new SlidingTimeWindowReservoir(config.getRetryWindowMs(systemName), clock);

  // Initiate metrics
  eventReadRates =
      streamIds.stream().collect(Collectors.toMap(Function.identity(), x -> registry.newCounter(x, EVENT_READ_RATE)));
  eventByteReadRates = streamIds.stream()
      .collect(Collectors.toMap(Function.identity(), x -> registry.newCounter(x, EVENT_BYTE_READ_RATE)));
  consumptionLagMs = streamIds.stream()
      .collect(Collectors.toMap(Function.identity(), x -> new SamzaHistogram(registry, x, CONSUMPTION_LAG_MS)));
  readErrors =
      streamIds.stream().collect(Collectors.toMap(Function.identity(), x -> registry.newCounter(x, READ_ERRORS)));

  // Locking to ensure that these aggregated metrics will be created only once across multiple system consumers.
  synchronized (AGGREGATE_METRICS_LOCK) {
    if (aggEventReadRate == null) {
      aggEventReadRate = registry.newCounter(AGGREGATE, EVENT_READ_RATE);
      aggEventByteReadRate = registry.newCounter(AGGREGATE, EVENT_BYTE_READ_RATE);
      aggConsumptionLagMs = new SamzaHistogram(registry, AGGREGATE, CONSUMPTION_LAG_MS);
      aggReadErrors = registry.newCounter(AGGREGATE, READ_ERRORS);
    }
  }
}
 
Example 5
Source File: OperatorImpl.java    From samza with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize this {@link OperatorImpl} and its user-defined functions.
 *
 * @param internalTaskContext the {@link InternalTaskContext} for the task
 */
public final void init(InternalTaskContext internalTaskContext) {
  final Context context = internalTaskContext.getContext();

  String opId = getOpImplId();

  if (initialized) {
    throw new IllegalStateException(String.format("Attempted to initialize Operator %s more than once.", opId));
  }

  if (closed) {
    throw new IllegalStateException(String.format("Attempted to initialize Operator %s after it was closed.", opId));
  }

  this.highResClock = createHighResClock(context.getJobContext().getConfig());
  registeredOperators = new HashSet<>();
  prevOperators = new HashSet<>();
  inputStreams = new HashSet<>();

  final ContainerContext containerContext = context.getContainerContext();
  final MetricsRegistry metricsRegistry = containerContext.getContainerMetricsRegistry();
  this.numMessage = metricsRegistry.newCounter(METRICS_GROUP, opId + "-messages");
  this.handleMessageNs = metricsRegistry.newTimer(METRICS_GROUP, opId + "-handle-message-ns");
  this.handleTimerNs = metricsRegistry.newTimer(METRICS_GROUP, opId + "-handle-timer-ns");

  final TaskContext taskContext =  context.getTaskContext();
  this.taskName = taskContext.getTaskModel().getTaskName();
  this.eosStates = (EndOfStreamStates) internalTaskContext.fetchObject(EndOfStreamStates.class.getName());
  this.watermarkStates = (WatermarkStates) internalTaskContext.fetchObject(WatermarkStates.class.getName());
  this.controlMessageSender = new ControlMessageSender(internalTaskContext.getStreamMetadataCache());
  this.taskModel = taskContext.getTaskModel();
  this.callbackScheduler = taskContext.getCallbackScheduler();
  handleInit(context);

  initialized = true;
}
 
Example 6
Source File: HdfsSystemConsumer.java    From samza with Apache License 2.0 4 votes vote down vote up
public HdfsSystemConsumerMetrics(MetricsRegistry metricsRegistry) {
  this.metricsRegistry = metricsRegistry;
  this.numEventsCounterMap = new ConcurrentHashMap<>();
  this.numTotalEventsCounter = metricsRegistry.newCounter(METRICS_GROUP_NAME, "num-total-events");
}