Not thread safe increment of counterName. Counter doesn't exist unless incremented once
430397
public static void incr(String counterName) {
    org.apache.heron.api.metric.GlobalMetrics.incr(counterName);
  }
962425
def increment(self, counter_name, delta):
    
    current_value = self.counters.get(counter_name, 0)
    new_value = current_value + delta
    self.counters[counter_name] = new_value
    return new_value
730949
@Override
	protected void save(List<Counter> counters) {
		if (_logger == null)
			return;
		if (counters.size() == 0)
			return;

		Collections.sort(counters, (c1, c2) -> c1.getName().compareTo(c2.getName()));

		for (Counter counter : counters) {
			_logger.info("counters", counterToString(counter));
		}
	}
1128627
protected StrongCounter getCounterOrCreateIt(String counterName, int initialValue) {
		CounterManager counterManager = EmbeddedCounterManagerFactory.asCounterManager( cacheManager );
		if ( !counterManager.isDefined( counterName ) ) {
			LOG.tracef( "Counter %s is not defined, creating it", counterName );

			// global configuration is mandatory in order to define
			// a new clustered counter with persistent storage
			validateGlobalConfiguration();

			counterManager.defineCounter( counterName,
				CounterConfiguration.builder(
					CounterType.UNBOUNDED_STRONG )
						.initialValue( initialValue )
						.storage( Storage.PERSISTENT )
						.build() );
		}

		StrongCounter strongCounter = counterManager.getStrongCounter( counterName );
		return strongCounter;
	}
185287
def set_to(cls, name, num):
        """"""
        if num < 0:
            raise CounterValueError('Counter[%s] can not be set to %s' % (
                                    name, num))
        else:
            counter = cls.collection.find_and_modify(
                {'name': name},
                {'$set': {'seq': num}},
                new=True,
                upsert=True
            )
            return counter['seq']
277634
public static void removeWeakCounter(Cache<WeakCounterKey, CounterValue> cache, CounterConfiguration configuration,
         String counterName) {
      ByteString counterNameByteString = ByteString.fromString(counterName);
      for (int i = 0; i < configuration.concurrencyLevel(); ++i) {
         cache.remove(new WeakCounterKey(counterNameByteString, i));
      }
   }
532508
private CounterColumn prepareCounterColumn(String value, byte[] name)
    {
        CounterColumn counterColumn = new CounterColumn();
        counterColumn.setName(name);
        LongAccessor accessor = new LongAccessor();
        counterColumn.setValue(accessor.fromString(LongAccessor.class, value));
        return counterColumn;
    }
790957
public void add(Counter<? extends T> counter) {
        for (Map.Entry<? extends T,Integer> e : counter) {
            T t = e.getKey();
            Integer cur = counts.get(t);
            counts.put(t, (cur == null) ? e.getValue() : cur + e.getValue());
        }
    }
101973
@Override
  public void onThreadBegin()
  {
    _threadCount.incrementAndGet();
    
    int startCount = _startingCount.decrementAndGet();

    if (startCount < 0) {
      _startingCount.set(0);
      
      new IllegalStateException().printStackTrace();
    }

    _createCountTotal.incrementAndGet();
    
    update();
  }
366294
private void updateInstances(List<InstanceContext> instances, final CountingCompletionHandler<Void> counter) {
    for (final InstanceContext instance : instances) {
      data.put(instance.address(), Contexts.serialize(instance).encode(), new Handler<AsyncResult<String>>() {
        @Override
        public void handle(AsyncResult<String> result) {
          if (result.failed()) {
            counter.fail(result.cause());
          } else {
            counter.succeed();
          }
        }
      });
    }
  }
501410
def _save(self, counters):
        
        if self._logger == None:
            return
        if len(counters) == 0:
            return

        # Sort counters by name
        counters = sorted(counters, key=LogCounters._get_counter_name)

        for counter in counters:
            self._logger.info("counters", self._counter_to_string(counter))
870152
void writeLock(int count) {
      if (count > 0 && counter != null)
         counter.acquireShared(count);
      sync.acquireShared(1);
   }
90057
def do_counter_reset(self, element, decl, pseudo):
        """"""
        step = self.state[self.state['current_step']]
        counter_name = ''
        for term in decl.value:
            if type(term) is ast.WhitespaceToken:
                continue

            elif type(term) is ast.IdentToken:
                if counter_name:
                    step['counters'][counter_name] = 0
                counter_name = term.value

            elif type(term) is ast.LiteralToken:
                if counter_name:
                    step['counters'][counter_name] = 0
                    counter_name = ''

            elif type(term) is ast.NumberToken:
                if counter_name:
                    step['counters'][counter_name] = int(term.value)
                    counter_name = ''

            else:
                log(WARN, u"Unrecognized counter-reset term {}"
                    .format(type(term)).encode('utf-8'))
        if counter_name:
            step['counters'][counter_name] = 0
703272
void increment() {
        long id = rand.nextInt(config.tuples);
        long toIncrement = rand.nextInt(5); // 0 - 4

        try {
            client.callProcedure(new CMCallback(), "Increment", toIncrement, id);
        }
        catch (IOException e) {
            // This is not ideal error handling for production, but should be
            // harmless in a benchmark like this
            try { Thread.sleep(50); } catch (Exception e2) {}
        }
    }
1029466
public void add(Counter<? extends T> counter) {
        for (Map.Entry<? extends T,Integer> e : counter)
            count(e.getKey(), e.getValue());
    }
    
    /**
     * Counts the object, increasing its total count by 1.
     */
    public int count(T obj) {
        int objIndex = (allowNewIndices) 
            ? objectIndices.index(obj)
            : objectIndices.find(obj);
        if (objIndex < 0)
            return 0;
        int curCount = indexToCount.get(objIndex);
        indexToCount.put(objIndex, curCount + 1);
        sum++;
        return curCount + 1;
    }
694613
private void incrementCurrentValue() {
    currentValues[currentValues.length - 1]++;
    int i = currentValues.length - 1;
    while (i > 0 &&
        currentValues[i] > finalValues[i]) {
      currentValues[i] = 0;
      currentValues[i - 1]++;
      i--;
    }
  }
615584
function incrementCounter() {
            for (var i = innerLen-1; i >= innerLen-4; i--) {
                inner[i]++;
                if (inner[i] <= 0xff) return;
                inner[i] = 0;
            }
        }