Helper method instantiating a counters manager
556450
private void createCountersManager() {
        UnsafeBuffer counterLabelsBuffer = monitorFileWriter.createGatewayCounterLabelsBuffer();
        UnsafeBuffer counterValuesBuffer = monitorFileWriter.createGatewayCounterValuesBuffer();

        countersManager = new CountersManager(counterLabelsBuffer, counterValuesBuffer);
    }
1104439
def consumer_stats_counter():
        
        return {
            process.Process.ERROR: 0,
            process.Process.PROCESSED: 0,
            process.Process.REDELIVERED: 0
        }
1261269
Counter counter(Meter.Id id) {
        return registerMeterIfNecessary(Counter.class, id, this::newCounter, NoopCounter::new);
    }
85130
private void doCounterGet(final Message<JsonObject> message) {
    final String name = message.body().getString("name");
    if (name == null) {
      message.reply(new JsonObject().putString("status", "error").putString("message", "No name specified."));
      return;
    }

    context.execute(new Action<Long>() {
      @Override
      public Long perform() {
        Map<Object, Long> counters = data.getMap(formatKey("counters"));
        Long value = counters.get(name);
        if (value == null) {
          value = 0L;
        }
        return value;
      }
    }, new Handler<AsyncResult<Long>>() {
      @Override
      public void handle(AsyncResult<Long> result) {
        if (result.failed()) {
          message.reply(new JsonObject().putString("status", "error").putString("message", result.cause().getMessage()));
        } else {
          message.reply(new JsonObject().putString("status", "ok").putNumber("result", result.result()));
        }
      }
    });
  }
460704
def increment(handler, increment, item_id, counter_name):
    """"""
    data = {'operation': 'increment_counter',
            'id': item_id,
            'counter_name': counter_name,
            'increment': increment}
    handler.invoke(data)
390005
protected Counter findCounter(String counterName, String displayName) {
    Counter result = counters.get(counterName);
    if (result == null) {
      result = new Counter(counterName, displayName);
      counters.put(counterName, result);
    }
    return result;
  }
662300
@Override
  public Counter counter(String name) {
    final com.codahale.metrics.Counter counter = registry.counter(name);
    return new Counter() {
      @Override
      public void inc() {
        counter.inc();
      }

      @Override
      public void dec() {
        counter.dec();
      }
    };
  }
149784
private static <E> Counter<Integer> collectCountCounts(Counter<E> counts) {
    Counter<Integer> cc = new ClassicCounter<Integer>(); // counts of counts
    for (Map.Entry<E, Double> entry : counts.entrySet()) {
      //E item = entry.getKey();
      Integer count = (int) Math.round(entry.getValue());
      cc.incrementCount(count);
    }
    return cc;
  }
261283
private org.javasimon.jmx.CounterSample sampleCounter(Simon counter) {
		return new CounterSample((org.javasimon.CounterSample) counter.sample());
	}
682189
def status_counter(self):
        
        counter = collections.Counter()

        for task in self:
            counter[str(task.status)] += 1

        return counter
669126
function Counter() {
  this.total = 0;
  this.executed = 0;
  this.passed = 0;
  this.error = 0;
  this.failed = 0;
  this.timeout = 0;
  this.aborted = 0;
  this.inconclusive = 0;
  this.passedButRunAborted = 0;
  this.notRunnable = 0;
  this.notExecuted = 0;
  this.disconnected = 0;
  this.warning = 0;
  this.completed = 0;
  this.inProgress = 0;
  this.pending = 0;
}
1281773
def _parse_general_counters(self, init_config):
        
        job_counter = {}

        if init_config.get('general_counters'):

            # Parse the custom metrics
            for counter_group in init_config['general_counters']:
                counter_group_name = counter_group.get('counter_group_name')
                counters = counter_group.get('counters')

                if not counter_group_name:
                    raise Exception('"general_counters" must contain a valid "counter_group_name"')

                if not counters:
                    raise Exception('"general_counters" must contain a list of "counters"')

                # Add the counter_group to the job_counters if it doesn't already exist
                if counter_group_name not in job_counter:
                    job_counter[counter_group_name] = []

                for counter in counters:
                    counter_name = counter.get('counter_name')

                    if not counter_name:
                        raise Exception('At least one "counter_name" should be specified in the list of "counters"')

                    job_counter[counter_group_name].append(counter_name)

        return job_counter
446953
def monitor_counters(mc, output, counters, detailed, f):
    """"""
    # Print CSV header
    output.write("time,{}{}\n".format("x,y," if detailed else "",
                                      ",".join(counters)))

    system_info = mc.get_system_info()

    # Make an initial sample of the counters
    last_counter_values = sample_counters(mc, system_info)

    start_time = time.time()

    for _ in f():
        # Snapshot the change in counter values
        counter_values = sample_counters(mc, system_info)
        delta = deltas(last_counter_values, counter_values)
        last_counter_values = counter_values

        now = time.time() - start_time

        # Output the changes
        if detailed:
            for x, y in sorted(system_info):
                output.write("{:0.1f},{},{},{}\n".format(
                    now, x, y,
                    ",".join(str(getattr(delta[(x, y)], c))
                             for c in counters)))
        else:
            totals = [0 for _ in counters]
            for xy in sorted(system_info):
                for i, counter in enumerate(counters):
                    totals[i] += getattr(delta[xy], counter)
            output.write("{:0.1f},{}\n".format(
                now, ",".join(map(str, totals))))
1365748
def counter(items):
    
    results = {}
    for item in items:
        results[item] = results.get(item, 0) + 1
    return results
415067
def get_counters(counter_list):
    '''
    
    '''
    if not isinstance(counter_list, list):
        raise CommandExecutionError('counter_list must be a list of tuples')

    try:
        # Start a Query instances
        query = win32pdh.OpenQuery()

        # Build the counters
        counters = build_counter_list(counter_list)

        # Add counters to the Query
        for counter in counters:
            counter.add_to_query(query)

        # https://docs.microsoft.com/en-us/windows/desktop/perfctrs/collecting-performance-data
        win32pdh.CollectQueryData(query)
        # The sleep here is required for counters that require more than 1
        # reading
        time.sleep(1)
        win32pdh.CollectQueryData(query)
        ret = {}

        for counter in counters:
            try:
                ret.update({counter.path: counter.value()})
            except pywintypes.error as exc:
                if exc.strerror == 'No data to return.':
                    # Some counters are not active and will throw an error if
                    # there is no data to return
                    continue
                else:
                    raise

    finally:
        win32pdh.CloseQuery(query)

    return ret
1108067
function cloneCounterValues(counters) {
        const result = {};
        Object.keys(counters).forEach(name => {
            result[name] = Array.from(counters[name]);
        });
        return result;
    }
1082590
public static Counter newCounter(String name, TaggingContext context) {
    final MonitorConfig config = MonitorConfig.builder(name).build();
    return new ContextualCounter(config, context, COUNTER_FUNCTION);
  }