def wrap_iterator_inc_counter(iterator, counter, grpc_type,
    grpc_service_name, grpc_method_name):
    """Wraps an iterator and collect metrics."""
    for item in iterator:
        counter.labels(grpc_type=grpc_type, grpc_service=grpc_service_name,
            grpc_method=grpc_method_name).inc()
        yield item
